func UnstructuredToService()

in unstructured/google/run/alpha/service.go [376:1105]


func UnstructuredToService(u *unstructured.Resource) (*dclService.Service, error) {
	r := &dclService.Service{}
	if _, ok := u.Object["annotations"]; ok {
		if rAnnotations, ok := u.Object["annotations"].(map[string]interface{}); ok {
			m := make(map[string]string)
			for k, v := range rAnnotations {
				if s, ok := v.(string); ok {
					m[k] = s
				}
			}
			r.Annotations = m
		} else {
			return nil, fmt.Errorf("r.Annotations: expected map[string]interface{}")
		}
	}
	if _, ok := u.Object["binaryAuthorization"]; ok {
		if rBinaryAuthorization, ok := u.Object["binaryAuthorization"].(map[string]interface{}); ok {
			r.BinaryAuthorization = &dclService.ServiceBinaryAuthorization{}
			if _, ok := rBinaryAuthorization["breakglassJustification"]; ok {
				if s, ok := rBinaryAuthorization["breakglassJustification"].(string); ok {
					r.BinaryAuthorization.BreakglassJustification = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.BinaryAuthorization.BreakglassJustification: expected string")
				}
			}
			if _, ok := rBinaryAuthorization["useDefault"]; ok {
				if b, ok := rBinaryAuthorization["useDefault"].(bool); ok {
					r.BinaryAuthorization.UseDefault = dcl.Bool(b)
				} else {
					return nil, fmt.Errorf("r.BinaryAuthorization.UseDefault: expected bool")
				}
			}
		} else {
			return nil, fmt.Errorf("r.BinaryAuthorization: expected map[string]interface{}")
		}
	}
	if _, ok := u.Object["client"]; ok {
		if s, ok := u.Object["client"].(string); ok {
			r.Client = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Client: expected string")
		}
	}
	if _, ok := u.Object["clientVersion"]; ok {
		if s, ok := u.Object["clientVersion"].(string); ok {
			r.ClientVersion = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.ClientVersion: expected string")
		}
	}
	if _, ok := u.Object["createTime"]; ok {
		if s, ok := u.Object["createTime"].(string); ok {
			r.CreateTime = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.CreateTime: expected string")
		}
	}
	if _, ok := u.Object["creator"]; ok {
		if s, ok := u.Object["creator"].(string); ok {
			r.Creator = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Creator: expected string")
		}
	}
	if _, ok := u.Object["deleteTime"]; ok {
		if s, ok := u.Object["deleteTime"].(string); ok {
			r.DeleteTime = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.DeleteTime: expected string")
		}
	}
	if _, ok := u.Object["description"]; ok {
		if s, ok := u.Object["description"].(string); ok {
			r.Description = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Description: expected string")
		}
	}
	if _, ok := u.Object["etag"]; ok {
		if s, ok := u.Object["etag"].(string); ok {
			r.Etag = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Etag: expected string")
		}
	}
	if _, ok := u.Object["expireTime"]; ok {
		if s, ok := u.Object["expireTime"].(string); ok {
			r.ExpireTime = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.ExpireTime: expected string")
		}
	}
	if _, ok := u.Object["generation"]; ok {
		if i, ok := u.Object["generation"].(int64); ok {
			r.Generation = dcl.Int64(i)
		} else {
			return nil, fmt.Errorf("r.Generation: expected int64")
		}
	}
	if _, ok := u.Object["ingress"]; ok {
		if s, ok := u.Object["ingress"].(string); ok {
			r.Ingress = dclService.ServiceIngressEnumRef(s)
		} else {
			return nil, fmt.Errorf("r.Ingress: expected string")
		}
	}
	if _, ok := u.Object["labels"]; ok {
		if rLabels, ok := u.Object["labels"].(map[string]interface{}); ok {
			m := make(map[string]string)
			for k, v := range rLabels {
				if s, ok := v.(string); ok {
					m[k] = s
				}
			}
			r.Labels = m
		} else {
			return nil, fmt.Errorf("r.Labels: expected map[string]interface{}")
		}
	}
	if _, ok := u.Object["lastModifier"]; ok {
		if s, ok := u.Object["lastModifier"].(string); ok {
			r.LastModifier = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.LastModifier: expected string")
		}
	}
	if _, ok := u.Object["latestCreatedRevision"]; ok {
		if s, ok := u.Object["latestCreatedRevision"].(string); ok {
			r.LatestCreatedRevision = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.LatestCreatedRevision: expected string")
		}
	}
	if _, ok := u.Object["latestReadyRevision"]; ok {
		if s, ok := u.Object["latestReadyRevision"].(string); ok {
			r.LatestReadyRevision = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.LatestReadyRevision: expected string")
		}
	}
	if _, ok := u.Object["launchStage"]; ok {
		if s, ok := u.Object["launchStage"].(string); ok {
			r.LaunchStage = dclService.ServiceLaunchStageEnumRef(s)
		} else {
			return nil, fmt.Errorf("r.LaunchStage: expected string")
		}
	}
	if _, ok := u.Object["location"]; ok {
		if s, ok := u.Object["location"].(string); ok {
			r.Location = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Location: expected string")
		}
	}
	if _, ok := u.Object["name"]; ok {
		if s, ok := u.Object["name"].(string); ok {
			r.Name = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Name: expected string")
		}
	}
	if _, ok := u.Object["project"]; ok {
		if s, ok := u.Object["project"].(string); ok {
			r.Project = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Project: expected string")
		}
	}
	if _, ok := u.Object["reconciling"]; ok {
		if b, ok := u.Object["reconciling"].(bool); ok {
			r.Reconciling = dcl.Bool(b)
		} else {
			return nil, fmt.Errorf("r.Reconciling: expected bool")
		}
	}
	if _, ok := u.Object["template"]; ok {
		if rTemplate, ok := u.Object["template"].(map[string]interface{}); ok {
			r.Template = &dclService.ServiceTemplate{}
			if _, ok := rTemplate["annotations"]; ok {
				if rTemplateAnnotations, ok := rTemplate["annotations"].(map[string]interface{}); ok {
					m := make(map[string]string)
					for k, v := range rTemplateAnnotations {
						if s, ok := v.(string); ok {
							m[k] = s
						}
					}
					r.Template.Annotations = m
				} else {
					return nil, fmt.Errorf("r.Template.Annotations: expected map[string]interface{}")
				}
			}
			if _, ok := rTemplate["containerConcurrency"]; ok {
				if i, ok := rTemplate["containerConcurrency"].(int64); ok {
					r.Template.ContainerConcurrency = dcl.Int64(i)
				} else {
					return nil, fmt.Errorf("r.Template.ContainerConcurrency: expected int64")
				}
			}
			if _, ok := rTemplate["containers"]; ok {
				if s, ok := rTemplate["containers"].([]interface{}); ok {
					for _, o := range s {
						if objval, ok := o.(map[string]interface{}); ok {
							var rTemplateContainers dclService.ServiceTemplateContainers
							if _, ok := objval["args"]; ok {
								if s, ok := objval["args"].([]interface{}); ok {
									for _, ss := range s {
										if strval, ok := ss.(string); ok {
											rTemplateContainers.Args = append(rTemplateContainers.Args, strval)
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Args: expected []interface{}")
								}
							}
							if _, ok := objval["command"]; ok {
								if s, ok := objval["command"].([]interface{}); ok {
									for _, ss := range s {
										if strval, ok := ss.(string); ok {
											rTemplateContainers.Command = append(rTemplateContainers.Command, strval)
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Command: expected []interface{}")
								}
							}
							if _, ok := objval["env"]; ok {
								if s, ok := objval["env"].([]interface{}); ok {
									for _, o := range s {
										if objval, ok := o.(map[string]interface{}); ok {
											var rTemplateContainersEnv dclService.ServiceTemplateContainersEnv
											if _, ok := objval["name"]; ok {
												if s, ok := objval["name"].(string); ok {
													rTemplateContainersEnv.Name = dcl.String(s)
												} else {
													return nil, fmt.Errorf("rTemplateContainersEnv.Name: expected string")
												}
											}
											if _, ok := objval["value"]; ok {
												if s, ok := objval["value"].(string); ok {
													rTemplateContainersEnv.Value = dcl.String(s)
												} else {
													return nil, fmt.Errorf("rTemplateContainersEnv.Value: expected string")
												}
											}
											if _, ok := objval["valueSource"]; ok {
												if rTemplateContainersEnvValueSource, ok := objval["valueSource"].(map[string]interface{}); ok {
													rTemplateContainersEnv.ValueSource = &dclService.ServiceTemplateContainersEnvValueSource{}
													if _, ok := rTemplateContainersEnvValueSource["secretKeyRef"]; ok {
														if rTemplateContainersEnvValueSourceSecretKeyRef, ok := rTemplateContainersEnvValueSource["secretKeyRef"].(map[string]interface{}); ok {
															rTemplateContainersEnv.ValueSource.SecretKeyRef = &dclService.ServiceTemplateContainersEnvValueSourceSecretKeyRef{}
															if _, ok := rTemplateContainersEnvValueSourceSecretKeyRef["secret"]; ok {
																if s, ok := rTemplateContainersEnvValueSourceSecretKeyRef["secret"].(string); ok {
																	rTemplateContainersEnv.ValueSource.SecretKeyRef.Secret = dcl.String(s)
																} else {
																	return nil, fmt.Errorf("rTemplateContainersEnv.ValueSource.SecretKeyRef.Secret: expected string")
																}
															}
															if _, ok := rTemplateContainersEnvValueSourceSecretKeyRef["version"]; ok {
																if s, ok := rTemplateContainersEnvValueSourceSecretKeyRef["version"].(string); ok {
																	rTemplateContainersEnv.ValueSource.SecretKeyRef.Version = dcl.String(s)
																} else {
																	return nil, fmt.Errorf("rTemplateContainersEnv.ValueSource.SecretKeyRef.Version: expected string")
																}
															}
														} else {
															return nil, fmt.Errorf("rTemplateContainersEnv.ValueSource.SecretKeyRef: expected map[string]interface{}")
														}
													}
												} else {
													return nil, fmt.Errorf("rTemplateContainersEnv.ValueSource: expected map[string]interface{}")
												}
											}
											rTemplateContainers.Env = append(rTemplateContainers.Env, rTemplateContainersEnv)
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Env: expected []interface{}")
								}
							}
							if _, ok := objval["image"]; ok {
								if s, ok := objval["image"].(string); ok {
									rTemplateContainers.Image = dcl.String(s)
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Image: expected string")
								}
							}
							if _, ok := objval["name"]; ok {
								if s, ok := objval["name"].(string); ok {
									rTemplateContainers.Name = dcl.String(s)
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Name: expected string")
								}
							}
							if _, ok := objval["ports"]; ok {
								if s, ok := objval["ports"].([]interface{}); ok {
									for _, o := range s {
										if objval, ok := o.(map[string]interface{}); ok {
											var rTemplateContainersPorts dclService.ServiceTemplateContainersPorts
											if _, ok := objval["containerPort"]; ok {
												if i, ok := objval["containerPort"].(int64); ok {
													rTemplateContainersPorts.ContainerPort = dcl.Int64(i)
												} else {
													return nil, fmt.Errorf("rTemplateContainersPorts.ContainerPort: expected int64")
												}
											}
											if _, ok := objval["name"]; ok {
												if s, ok := objval["name"].(string); ok {
													rTemplateContainersPorts.Name = dcl.String(s)
												} else {
													return nil, fmt.Errorf("rTemplateContainersPorts.Name: expected string")
												}
											}
											rTemplateContainers.Ports = append(rTemplateContainers.Ports, rTemplateContainersPorts)
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Ports: expected []interface{}")
								}
							}
							if _, ok := objval["resources"]; ok {
								if rTemplateContainersResources, ok := objval["resources"].(map[string]interface{}); ok {
									rTemplateContainers.Resources = &dclService.ServiceTemplateContainersResources{}
									if _, ok := rTemplateContainersResources["cpuIdle"]; ok {
										if b, ok := rTemplateContainersResources["cpuIdle"].(bool); ok {
											rTemplateContainers.Resources.CpuIdle = dcl.Bool(b)
										} else {
											return nil, fmt.Errorf("rTemplateContainers.Resources.CpuIdle: expected bool")
										}
									}
									if _, ok := rTemplateContainersResources["limits"]; ok {
										if rTemplateContainersResourcesLimits, ok := rTemplateContainersResources["limits"].(map[string]interface{}); ok {
											m := make(map[string]string)
											for k, v := range rTemplateContainersResourcesLimits {
												if s, ok := v.(string); ok {
													m[k] = s
												}
											}
											rTemplateContainers.Resources.Limits = m
										} else {
											return nil, fmt.Errorf("rTemplateContainers.Resources.Limits: expected map[string]interface{}")
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateContainers.Resources: expected map[string]interface{}")
								}
							}
							if _, ok := objval["volumeMounts"]; ok {
								if s, ok := objval["volumeMounts"].([]interface{}); ok {
									for _, o := range s {
										if objval, ok := o.(map[string]interface{}); ok {
											var rTemplateContainersVolumeMounts dclService.ServiceTemplateContainersVolumeMounts
											if _, ok := objval["mountPath"]; ok {
												if s, ok := objval["mountPath"].(string); ok {
													rTemplateContainersVolumeMounts.MountPath = dcl.String(s)
												} else {
													return nil, fmt.Errorf("rTemplateContainersVolumeMounts.MountPath: expected string")
												}
											}
											if _, ok := objval["name"]; ok {
												if s, ok := objval["name"].(string); ok {
													rTemplateContainersVolumeMounts.Name = dcl.String(s)
												} else {
													return nil, fmt.Errorf("rTemplateContainersVolumeMounts.Name: expected string")
												}
											}
											rTemplateContainers.VolumeMounts = append(rTemplateContainers.VolumeMounts, rTemplateContainersVolumeMounts)
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateContainers.VolumeMounts: expected []interface{}")
								}
							}
							r.Template.Containers = append(r.Template.Containers, rTemplateContainers)
						}
					}
				} else {
					return nil, fmt.Errorf("r.Template.Containers: expected []interface{}")
				}
			}
			if _, ok := rTemplate["executionEnvironment"]; ok {
				if s, ok := rTemplate["executionEnvironment"].(string); ok {
					r.Template.ExecutionEnvironment = dclService.ServiceTemplateExecutionEnvironmentEnumRef(s)
				} else {
					return nil, fmt.Errorf("r.Template.ExecutionEnvironment: expected string")
				}
			}
			if _, ok := rTemplate["labels"]; ok {
				if rTemplateLabels, ok := rTemplate["labels"].(map[string]interface{}); ok {
					m := make(map[string]string)
					for k, v := range rTemplateLabels {
						if s, ok := v.(string); ok {
							m[k] = s
						}
					}
					r.Template.Labels = m
				} else {
					return nil, fmt.Errorf("r.Template.Labels: expected map[string]interface{}")
				}
			}
			if _, ok := rTemplate["revision"]; ok {
				if s, ok := rTemplate["revision"].(string); ok {
					r.Template.Revision = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.Template.Revision: expected string")
				}
			}
			if _, ok := rTemplate["scaling"]; ok {
				if rTemplateScaling, ok := rTemplate["scaling"].(map[string]interface{}); ok {
					r.Template.Scaling = &dclService.ServiceTemplateScaling{}
					if _, ok := rTemplateScaling["maxInstanceCount"]; ok {
						if i, ok := rTemplateScaling["maxInstanceCount"].(int64); ok {
							r.Template.Scaling.MaxInstanceCount = dcl.Int64(i)
						} else {
							return nil, fmt.Errorf("r.Template.Scaling.MaxInstanceCount: expected int64")
						}
					}
					if _, ok := rTemplateScaling["minInstanceCount"]; ok {
						if i, ok := rTemplateScaling["minInstanceCount"].(int64); ok {
							r.Template.Scaling.MinInstanceCount = dcl.Int64(i)
						} else {
							return nil, fmt.Errorf("r.Template.Scaling.MinInstanceCount: expected int64")
						}
					}
				} else {
					return nil, fmt.Errorf("r.Template.Scaling: expected map[string]interface{}")
				}
			}
			if _, ok := rTemplate["serviceAccount"]; ok {
				if s, ok := rTemplate["serviceAccount"].(string); ok {
					r.Template.ServiceAccount = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.Template.ServiceAccount: expected string")
				}
			}
			if _, ok := rTemplate["timeout"]; ok {
				if s, ok := rTemplate["timeout"].(string); ok {
					r.Template.Timeout = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.Template.Timeout: expected string")
				}
			}
			if _, ok := rTemplate["volumes"]; ok {
				if s, ok := rTemplate["volumes"].([]interface{}); ok {
					for _, o := range s {
						if objval, ok := o.(map[string]interface{}); ok {
							var rTemplateVolumes dclService.ServiceTemplateVolumes
							if _, ok := objval["cloudSqlInstance"]; ok {
								if rTemplateVolumesCloudSqlInstance, ok := objval["cloudSqlInstance"].(map[string]interface{}); ok {
									rTemplateVolumes.CloudSqlInstance = &dclService.ServiceTemplateVolumesCloudSqlInstance{}
									if _, ok := rTemplateVolumesCloudSqlInstance["instances"]; ok {
										if s, ok := rTemplateVolumesCloudSqlInstance["instances"].([]interface{}); ok {
											for _, ss := range s {
												if strval, ok := ss.(string); ok {
													rTemplateVolumes.CloudSqlInstance.Instances = append(rTemplateVolumes.CloudSqlInstance.Instances, strval)
												}
											}
										} else {
											return nil, fmt.Errorf("rTemplateVolumes.CloudSqlInstance.Instances: expected []interface{}")
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateVolumes.CloudSqlInstance: expected map[string]interface{}")
								}
							}
							if _, ok := objval["name"]; ok {
								if s, ok := objval["name"].(string); ok {
									rTemplateVolumes.Name = dcl.String(s)
								} else {
									return nil, fmt.Errorf("rTemplateVolumes.Name: expected string")
								}
							}
							if _, ok := objval["secret"]; ok {
								if rTemplateVolumesSecret, ok := objval["secret"].(map[string]interface{}); ok {
									rTemplateVolumes.Secret = &dclService.ServiceTemplateVolumesSecret{}
									if _, ok := rTemplateVolumesSecret["defaultMode"]; ok {
										if i, ok := rTemplateVolumesSecret["defaultMode"].(int64); ok {
											rTemplateVolumes.Secret.DefaultMode = dcl.Int64(i)
										} else {
											return nil, fmt.Errorf("rTemplateVolumes.Secret.DefaultMode: expected int64")
										}
									}
									if _, ok := rTemplateVolumesSecret["items"]; ok {
										if s, ok := rTemplateVolumesSecret["items"].([]interface{}); ok {
											for _, o := range s {
												if objval, ok := o.(map[string]interface{}); ok {
													var rTemplateVolumesSecretItems dclService.ServiceTemplateVolumesSecretItems
													if _, ok := objval["mode"]; ok {
														if i, ok := objval["mode"].(int64); ok {
															rTemplateVolumesSecretItems.Mode = dcl.Int64(i)
														} else {
															return nil, fmt.Errorf("rTemplateVolumesSecretItems.Mode: expected int64")
														}
													}
													if _, ok := objval["path"]; ok {
														if s, ok := objval["path"].(string); ok {
															rTemplateVolumesSecretItems.Path = dcl.String(s)
														} else {
															return nil, fmt.Errorf("rTemplateVolumesSecretItems.Path: expected string")
														}
													}
													if _, ok := objval["version"]; ok {
														if s, ok := objval["version"].(string); ok {
															rTemplateVolumesSecretItems.Version = dcl.String(s)
														} else {
															return nil, fmt.Errorf("rTemplateVolumesSecretItems.Version: expected string")
														}
													}
													rTemplateVolumes.Secret.Items = append(rTemplateVolumes.Secret.Items, rTemplateVolumesSecretItems)
												}
											}
										} else {
											return nil, fmt.Errorf("rTemplateVolumes.Secret.Items: expected []interface{}")
										}
									}
									if _, ok := rTemplateVolumesSecret["secret"]; ok {
										if s, ok := rTemplateVolumesSecret["secret"].(string); ok {
											rTemplateVolumes.Secret.Secret = dcl.String(s)
										} else {
											return nil, fmt.Errorf("rTemplateVolumes.Secret.Secret: expected string")
										}
									}
								} else {
									return nil, fmt.Errorf("rTemplateVolumes.Secret: expected map[string]interface{}")
								}
							}
							r.Template.Volumes = append(r.Template.Volumes, rTemplateVolumes)
						}
					}
				} else {
					return nil, fmt.Errorf("r.Template.Volumes: expected []interface{}")
				}
			}
			if _, ok := rTemplate["vpcAccess"]; ok {
				if rTemplateVPCAccess, ok := rTemplate["vpcAccess"].(map[string]interface{}); ok {
					r.Template.VPCAccess = &dclService.ServiceTemplateVPCAccess{}
					if _, ok := rTemplateVPCAccess["connector"]; ok {
						if s, ok := rTemplateVPCAccess["connector"].(string); ok {
							r.Template.VPCAccess.Connector = dcl.String(s)
						} else {
							return nil, fmt.Errorf("r.Template.VPCAccess.Connector: expected string")
						}
					}
					if _, ok := rTemplateVPCAccess["egress"]; ok {
						if s, ok := rTemplateVPCAccess["egress"].(string); ok {
							r.Template.VPCAccess.Egress = dclService.ServiceTemplateVPCAccessEgressEnumRef(s)
						} else {
							return nil, fmt.Errorf("r.Template.VPCAccess.Egress: expected string")
						}
					}
				} else {
					return nil, fmt.Errorf("r.Template.VPCAccess: expected map[string]interface{}")
				}
			}
		} else {
			return nil, fmt.Errorf("r.Template: expected map[string]interface{}")
		}
	}
	if _, ok := u.Object["terminalCondition"]; ok {
		if rTerminalCondition, ok := u.Object["terminalCondition"].(map[string]interface{}); ok {
			r.TerminalCondition = &dclService.ServiceTerminalCondition{}
			if _, ok := rTerminalCondition["jobReason"]; ok {
				if s, ok := rTerminalCondition["jobReason"].(string); ok {
					r.TerminalCondition.JobReason = dclService.ServiceTerminalConditionJobReasonEnumRef(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.JobReason: expected string")
				}
			}
			if _, ok := rTerminalCondition["lastTransitionTime"]; ok {
				if s, ok := rTerminalCondition["lastTransitionTime"].(string); ok {
					r.TerminalCondition.LastTransitionTime = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.LastTransitionTime: expected string")
				}
			}
			if _, ok := rTerminalCondition["message"]; ok {
				if s, ok := rTerminalCondition["message"].(string); ok {
					r.TerminalCondition.Message = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.Message: expected string")
				}
			}
			if _, ok := rTerminalCondition["reason"]; ok {
				if s, ok := rTerminalCondition["reason"].(string); ok {
					r.TerminalCondition.Reason = dclService.ServiceTerminalConditionReasonEnumRef(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.Reason: expected string")
				}
			}
			if _, ok := rTerminalCondition["revisionReason"]; ok {
				if s, ok := rTerminalCondition["revisionReason"].(string); ok {
					r.TerminalCondition.RevisionReason = dclService.ServiceTerminalConditionRevisionReasonEnumRef(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.RevisionReason: expected string")
				}
			}
			if _, ok := rTerminalCondition["severity"]; ok {
				if s, ok := rTerminalCondition["severity"].(string); ok {
					r.TerminalCondition.Severity = dclService.ServiceTerminalConditionSeverityEnumRef(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.Severity: expected string")
				}
			}
			if _, ok := rTerminalCondition["state"]; ok {
				if s, ok := rTerminalCondition["state"].(string); ok {
					r.TerminalCondition.State = dclService.ServiceTerminalConditionStateEnumRef(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.State: expected string")
				}
			}
			if _, ok := rTerminalCondition["type"]; ok {
				if s, ok := rTerminalCondition["type"].(string); ok {
					r.TerminalCondition.Type = dcl.String(s)
				} else {
					return nil, fmt.Errorf("r.TerminalCondition.Type: expected string")
				}
			}
		} else {
			return nil, fmt.Errorf("r.TerminalCondition: expected map[string]interface{}")
		}
	}
	if _, ok := u.Object["traffic"]; ok {
		if s, ok := u.Object["traffic"].([]interface{}); ok {
			for _, o := range s {
				if objval, ok := o.(map[string]interface{}); ok {
					var rTraffic dclService.ServiceTraffic
					if _, ok := objval["percent"]; ok {
						if i, ok := objval["percent"].(int64); ok {
							rTraffic.Percent = dcl.Int64(i)
						} else {
							return nil, fmt.Errorf("rTraffic.Percent: expected int64")
						}
					}
					if _, ok := objval["revision"]; ok {
						if s, ok := objval["revision"].(string); ok {
							rTraffic.Revision = dcl.String(s)
						} else {
							return nil, fmt.Errorf("rTraffic.Revision: expected string")
						}
					}
					if _, ok := objval["tag"]; ok {
						if s, ok := objval["tag"].(string); ok {
							rTraffic.Tag = dcl.String(s)
						} else {
							return nil, fmt.Errorf("rTraffic.Tag: expected string")
						}
					}
					if _, ok := objval["type"]; ok {
						if s, ok := objval["type"].(string); ok {
							rTraffic.Type = dclService.ServiceTrafficTypeEnumRef(s)
						} else {
							return nil, fmt.Errorf("rTraffic.Type: expected string")
						}
					}
					r.Traffic = append(r.Traffic, rTraffic)
				}
			}
		} else {
			return nil, fmt.Errorf("r.Traffic: expected []interface{}")
		}
	}
	if _, ok := u.Object["trafficStatuses"]; ok {
		if s, ok := u.Object["trafficStatuses"].([]interface{}); ok {
			for _, o := range s {
				if objval, ok := o.(map[string]interface{}); ok {
					var rTrafficStatuses dclService.ServiceTrafficStatuses
					if _, ok := objval["percent"]; ok {
						if i, ok := objval["percent"].(int64); ok {
							rTrafficStatuses.Percent = dcl.Int64(i)
						} else {
							return nil, fmt.Errorf("rTrafficStatuses.Percent: expected int64")
						}
					}
					if _, ok := objval["revision"]; ok {
						if s, ok := objval["revision"].(string); ok {
							rTrafficStatuses.Revision = dcl.String(s)
						} else {
							return nil, fmt.Errorf("rTrafficStatuses.Revision: expected string")
						}
					}
					if _, ok := objval["tag"]; ok {
						if s, ok := objval["tag"].(string); ok {
							rTrafficStatuses.Tag = dcl.String(s)
						} else {
							return nil, fmt.Errorf("rTrafficStatuses.Tag: expected string")
						}
					}
					if _, ok := objval["type"]; ok {
						if s, ok := objval["type"].(string); ok {
							rTrafficStatuses.Type = dclService.ServiceTrafficStatusesTypeEnumRef(s)
						} else {
							return nil, fmt.Errorf("rTrafficStatuses.Type: expected string")
						}
					}
					if _, ok := objval["uri"]; ok {
						if s, ok := objval["uri"].(string); ok {
							rTrafficStatuses.Uri = dcl.String(s)
						} else {
							return nil, fmt.Errorf("rTrafficStatuses.Uri: expected string")
						}
					}
					r.TrafficStatuses = append(r.TrafficStatuses, rTrafficStatuses)
				}
			}
		} else {
			return nil, fmt.Errorf("r.TrafficStatuses: expected []interface{}")
		}
	}
	if _, ok := u.Object["uid"]; ok {
		if s, ok := u.Object["uid"].(string); ok {
			r.Uid = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Uid: expected string")
		}
	}
	if _, ok := u.Object["updateTime"]; ok {
		if s, ok := u.Object["updateTime"].(string); ok {
			r.UpdateTime = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.UpdateTime: expected string")
		}
	}
	if _, ok := u.Object["uri"]; ok {
		if s, ok := u.Object["uri"].(string); ok {
			r.Uri = dcl.String(s)
		} else {
			return nil, fmt.Errorf("r.Uri: expected string")
		}
	}
	return r, nil
}