func()

in v2/api/containerservice/v1api20240402preview/managed_clusters_agent_pool_types_gen.go [468:846]


func (pool *ManagedClustersAgentPool_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
	if pool == nil {
		return nil, nil
	}
	result := &arm.ManagedClustersAgentPool_Spec{}

	// Set property "Name":
	result.Name = resolved.Name

	// Set property "Properties":
	if pool.ArtifactStreamingProfile != nil ||
		pool.AvailabilityZones != nil ||
		pool.CapacityReservationGroupReference != nil ||
		pool.Count != nil ||
		pool.CreationData != nil ||
		pool.EnableAutoScaling != nil ||
		pool.EnableCustomCATrust != nil ||
		pool.EnableEncryptionAtHost != nil ||
		pool.EnableFIPS != nil ||
		pool.EnableNodePublicIP != nil ||
		pool.EnableUltraSSD != nil ||
		pool.GatewayProfile != nil ||
		pool.GpuInstanceProfile != nil ||
		pool.GpuProfile != nil ||
		pool.HostGroupReference != nil ||
		pool.KubeletConfig != nil ||
		pool.KubeletDiskType != nil ||
		pool.LinuxOSConfig != nil ||
		pool.MaxCount != nil ||
		pool.MaxPods != nil ||
		pool.MessageOfTheDay != nil ||
		pool.MinCount != nil ||
		pool.Mode != nil ||
		pool.NetworkProfile != nil ||
		pool.NodeInitializationTaints != nil ||
		pool.NodeLabels != nil ||
		pool.NodePublicIPPrefixReference != nil ||
		pool.NodeTaints != nil ||
		pool.OrchestratorVersion != nil ||
		pool.OsDiskSizeGB != nil ||
		pool.OsDiskType != nil ||
		pool.OsSKU != nil ||
		pool.OsType != nil ||
		pool.PodIPAllocationMode != nil ||
		pool.PodSubnetReference != nil ||
		pool.PowerState != nil ||
		pool.ProximityPlacementGroupReference != nil ||
		pool.ScaleDownMode != nil ||
		pool.ScaleSetEvictionPolicy != nil ||
		pool.ScaleSetPriority != nil ||
		pool.SecurityProfile != nil ||
		pool.SpotMaxPrice != nil ||
		pool.Tags != nil ||
		pool.Type != nil ||
		pool.UpgradeSettings != nil ||
		pool.VirtualMachineNodesStatus != nil ||
		pool.VirtualMachinesProfile != nil ||
		pool.VmSize != nil ||
		pool.VnetSubnetReference != nil ||
		pool.WindowsProfile != nil ||
		pool.WorkloadRuntime != nil {
		result.Properties = &arm.ManagedClusterAgentPoolProfileProperties{}
	}
	if pool.ArtifactStreamingProfile != nil {
		artifactStreamingProfile_ARM, err := (*pool.ArtifactStreamingProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		artifactStreamingProfile := *artifactStreamingProfile_ARM.(*arm.AgentPoolArtifactStreamingProfile)
		result.Properties.ArtifactStreamingProfile = &artifactStreamingProfile
	}
	for _, item := range pool.AvailabilityZones {
		result.Properties.AvailabilityZones = append(result.Properties.AvailabilityZones, item)
	}
	if pool.CapacityReservationGroupReference != nil {
		capacityReservationGroupIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.CapacityReservationGroupReference)
		if err != nil {
			return nil, err
		}
		capacityReservationGroupID := capacityReservationGroupIDARMID
		result.Properties.CapacityReservationGroupID = &capacityReservationGroupID
	}
	if pool.Count != nil {
		count := *pool.Count
		result.Properties.Count = &count
	}
	if pool.CreationData != nil {
		creationData_ARM, err := (*pool.CreationData).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		creationData := *creationData_ARM.(*arm.CreationData)
		result.Properties.CreationData = &creationData
	}
	if pool.EnableAutoScaling != nil {
		enableAutoScaling := *pool.EnableAutoScaling
		result.Properties.EnableAutoScaling = &enableAutoScaling
	}
	if pool.EnableCustomCATrust != nil {
		enableCustomCATrust := *pool.EnableCustomCATrust
		result.Properties.EnableCustomCATrust = &enableCustomCATrust
	}
	if pool.EnableEncryptionAtHost != nil {
		enableEncryptionAtHost := *pool.EnableEncryptionAtHost
		result.Properties.EnableEncryptionAtHost = &enableEncryptionAtHost
	}
	if pool.EnableFIPS != nil {
		enableFIPS := *pool.EnableFIPS
		result.Properties.EnableFIPS = &enableFIPS
	}
	if pool.EnableNodePublicIP != nil {
		enableNodePublicIP := *pool.EnableNodePublicIP
		result.Properties.EnableNodePublicIP = &enableNodePublicIP
	}
	if pool.EnableUltraSSD != nil {
		enableUltraSSD := *pool.EnableUltraSSD
		result.Properties.EnableUltraSSD = &enableUltraSSD
	}
	if pool.GatewayProfile != nil {
		gatewayProfile_ARM, err := (*pool.GatewayProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		gatewayProfile := *gatewayProfile_ARM.(*arm.AgentPoolGatewayProfile)
		result.Properties.GatewayProfile = &gatewayProfile
	}
	if pool.GpuInstanceProfile != nil {
		var temp string
		temp = string(*pool.GpuInstanceProfile)
		gpuInstanceProfile := arm.GPUInstanceProfile(temp)
		result.Properties.GpuInstanceProfile = &gpuInstanceProfile
	}
	if pool.GpuProfile != nil {
		gpuProfile_ARM, err := (*pool.GpuProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		gpuProfile := *gpuProfile_ARM.(*arm.AgentPoolGPUProfile)
		result.Properties.GpuProfile = &gpuProfile
	}
	if pool.HostGroupReference != nil {
		hostGroupIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.HostGroupReference)
		if err != nil {
			return nil, err
		}
		hostGroupID := hostGroupIDARMID
		result.Properties.HostGroupID = &hostGroupID
	}
	if pool.KubeletConfig != nil {
		kubeletConfig_ARM, err := (*pool.KubeletConfig).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		kubeletConfig := *kubeletConfig_ARM.(*arm.KubeletConfig)
		result.Properties.KubeletConfig = &kubeletConfig
	}
	if pool.KubeletDiskType != nil {
		var temp string
		temp = string(*pool.KubeletDiskType)
		kubeletDiskType := arm.KubeletDiskType(temp)
		result.Properties.KubeletDiskType = &kubeletDiskType
	}
	if pool.LinuxOSConfig != nil {
		linuxOSConfig_ARM, err := (*pool.LinuxOSConfig).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		linuxOSConfig := *linuxOSConfig_ARM.(*arm.LinuxOSConfig)
		result.Properties.LinuxOSConfig = &linuxOSConfig
	}
	if pool.MaxCount != nil {
		maxCount := *pool.MaxCount
		result.Properties.MaxCount = &maxCount
	}
	if pool.MaxPods != nil {
		maxPods := *pool.MaxPods
		result.Properties.MaxPods = &maxPods
	}
	if pool.MessageOfTheDay != nil {
		messageOfTheDay := *pool.MessageOfTheDay
		result.Properties.MessageOfTheDay = &messageOfTheDay
	}
	if pool.MinCount != nil {
		minCount := *pool.MinCount
		result.Properties.MinCount = &minCount
	}
	if pool.Mode != nil {
		var temp string
		temp = string(*pool.Mode)
		mode := arm.AgentPoolMode(temp)
		result.Properties.Mode = &mode
	}
	if pool.NetworkProfile != nil {
		networkProfile_ARM, err := (*pool.NetworkProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		networkProfile := *networkProfile_ARM.(*arm.AgentPoolNetworkProfile)
		result.Properties.NetworkProfile = &networkProfile
	}
	for _, item := range pool.NodeInitializationTaints {
		result.Properties.NodeInitializationTaints = append(result.Properties.NodeInitializationTaints, item)
	}
	if pool.NodeLabels != nil {
		result.Properties.NodeLabels = make(map[string]string, len(pool.NodeLabels))
		for key, value := range pool.NodeLabels {
			result.Properties.NodeLabels[key] = value
		}
	} else {
		// Set property to empty map, as this resource is set to serialize all collections explicitly
		result.Properties.NodeLabels = make(map[string]string)
	}
	if pool.NodePublicIPPrefixReference != nil {
		nodePublicIPPrefixIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.NodePublicIPPrefixReference)
		if err != nil {
			return nil, err
		}
		nodePublicIPPrefixID := nodePublicIPPrefixIDARMID
		result.Properties.NodePublicIPPrefixID = &nodePublicIPPrefixID
	}
	for _, item := range pool.NodeTaints {
		result.Properties.NodeTaints = append(result.Properties.NodeTaints, item)
	}
	if result.Properties.NodeTaints == nil {
		// Set property to empty map, as this resource is set to serialize all collections explicitly
		result.Properties.NodeTaints = []string{}
	}
	if pool.OrchestratorVersion != nil {
		orchestratorVersion := *pool.OrchestratorVersion
		result.Properties.OrchestratorVersion = &orchestratorVersion
	}
	if pool.OsDiskSizeGB != nil {
		osDiskSizeGB := int(*pool.OsDiskSizeGB)
		result.Properties.OsDiskSizeGB = &osDiskSizeGB
	}
	if pool.OsDiskType != nil {
		var temp string
		temp = string(*pool.OsDiskType)
		osDiskType := arm.OSDiskType(temp)
		result.Properties.OsDiskType = &osDiskType
	}
	if pool.OsSKU != nil {
		var temp string
		temp = string(*pool.OsSKU)
		osSKU := arm.OSSKU(temp)
		result.Properties.OsSKU = &osSKU
	}
	if pool.OsType != nil {
		var temp string
		temp = string(*pool.OsType)
		osType := arm.OSType(temp)
		result.Properties.OsType = &osType
	}
	if pool.PodIPAllocationMode != nil {
		var temp string
		temp = string(*pool.PodIPAllocationMode)
		podIPAllocationMode := arm.PodIPAllocationMode(temp)
		result.Properties.PodIPAllocationMode = &podIPAllocationMode
	}
	if pool.PodSubnetReference != nil {
		podSubnetIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.PodSubnetReference)
		if err != nil {
			return nil, err
		}
		podSubnetID := podSubnetIDARMID
		result.Properties.PodSubnetID = &podSubnetID
	}
	if pool.PowerState != nil {
		powerState_ARM, err := (*pool.PowerState).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		powerState := *powerState_ARM.(*arm.PowerState)
		result.Properties.PowerState = &powerState
	}
	if pool.ProximityPlacementGroupReference != nil {
		proximityPlacementGroupIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.ProximityPlacementGroupReference)
		if err != nil {
			return nil, err
		}
		proximityPlacementGroupID := proximityPlacementGroupIDARMID
		result.Properties.ProximityPlacementGroupID = &proximityPlacementGroupID
	}
	if pool.ScaleDownMode != nil {
		var temp string
		temp = string(*pool.ScaleDownMode)
		scaleDownMode := arm.ScaleDownMode(temp)
		result.Properties.ScaleDownMode = &scaleDownMode
	}
	if pool.ScaleSetEvictionPolicy != nil {
		var temp string
		temp = string(*pool.ScaleSetEvictionPolicy)
		scaleSetEvictionPolicy := arm.ScaleSetEvictionPolicy(temp)
		result.Properties.ScaleSetEvictionPolicy = &scaleSetEvictionPolicy
	}
	if pool.ScaleSetPriority != nil {
		var temp string
		temp = string(*pool.ScaleSetPriority)
		scaleSetPriority := arm.ScaleSetPriority(temp)
		result.Properties.ScaleSetPriority = &scaleSetPriority
	}
	if pool.SecurityProfile != nil {
		securityProfile_ARM, err := (*pool.SecurityProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		securityProfile := *securityProfile_ARM.(*arm.AgentPoolSecurityProfile)
		result.Properties.SecurityProfile = &securityProfile
	}
	if pool.SpotMaxPrice != nil {
		spotMaxPrice := *pool.SpotMaxPrice
		result.Properties.SpotMaxPrice = &spotMaxPrice
	}
	if pool.Tags != nil {
		result.Properties.Tags = make(map[string]string, len(pool.Tags))
		for key, value := range pool.Tags {
			result.Properties.Tags[key] = value
		}
	} else {
		// Set property to empty map, as this resource is set to serialize all collections explicitly
		result.Properties.Tags = make(map[string]string)
	}
	if pool.Type != nil {
		var temp string
		temp = string(*pool.Type)
		typeVar := arm.AgentPoolType(temp)
		result.Properties.Type = &typeVar
	}
	if pool.UpgradeSettings != nil {
		upgradeSettings_ARM, err := (*pool.UpgradeSettings).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		upgradeSettings := *upgradeSettings_ARM.(*arm.AgentPoolUpgradeSettings)
		result.Properties.UpgradeSettings = &upgradeSettings
	}
	for _, item := range pool.VirtualMachineNodesStatus {
		item_ARM, err := item.ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		result.Properties.VirtualMachineNodesStatus = append(result.Properties.VirtualMachineNodesStatus, *item_ARM.(*arm.VirtualMachineNodes))
	}
	if pool.VirtualMachinesProfile != nil {
		virtualMachinesProfile_ARM, err := (*pool.VirtualMachinesProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		virtualMachinesProfile := *virtualMachinesProfile_ARM.(*arm.VirtualMachinesProfile)
		result.Properties.VirtualMachinesProfile = &virtualMachinesProfile
	}
	if pool.VmSize != nil {
		vmSize := *pool.VmSize
		result.Properties.VmSize = &vmSize
	}
	if pool.VnetSubnetReference != nil {
		vnetSubnetIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.VnetSubnetReference)
		if err != nil {
			return nil, err
		}
		vnetSubnetID := vnetSubnetIDARMID
		result.Properties.VnetSubnetID = &vnetSubnetID
	}
	if pool.WindowsProfile != nil {
		windowsProfile_ARM, err := (*pool.WindowsProfile).ConvertToARM(resolved)
		if err != nil {
			return nil, err
		}
		windowsProfile := *windowsProfile_ARM.(*arm.AgentPoolWindowsProfile)
		result.Properties.WindowsProfile = &windowsProfile
	}
	if pool.WorkloadRuntime != nil {
		var temp string
		temp = string(*pool.WorkloadRuntime)
		workloadRuntime := arm.WorkloadRuntime(temp)
		result.Properties.WorkloadRuntime = &workloadRuntime
	}
	return result, nil
}