// This is an automatically generated code sample. 
// To make this code sample work in your Oracle Cloud tenancy, 
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and 
// boolean, number, and enum parameters with values not fitting your use case).

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.CoreService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Core
{
    public class LaunchInstanceExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var launchInstanceDetails = new Oci.CoreService.Models.LaunchInstanceDetails
			{
				AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
				CapacityReservationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				CreateVnicDetails = new Oci.CoreService.Models.CreateVnicDetails
				{
					AssignIpv6Ip = true,
					AssignPublicIp = false,
					AssignPrivateDnsRecord = false,
					DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
					{
						{
							"EXAMPLE_KEY_mQRfq", 
							new Dictionary<string, Object>()
							{
								{
									"EXAMPLE_KEY_qtK6L", 
									"EXAMPLE--Value"
								}
							}
						}
					},
					DisplayName = "EXAMPLE-displayName-Value",
					FreeformTags = new Dictionary<string, string>()
					{
						{
							"EXAMPLE_KEY_GQLE2", 
							"EXAMPLE_VALUE_XFFYDmRCJ7TiQyK6Jgpx"
						}
					},
					SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
					{
						{
							"EXAMPLE_KEY_EzCfw", 
							new Dictionary<string, Object>()
							{
								{
									"EXAMPLE_KEY_njmgf", 
									"EXAMPLE--Value"
								}
							}
						}
					},
					HostnameLabel = "EXAMPLE-hostnameLabel-Value",
					Ipv6AddressIpv6SubnetCidrPairDetails = new List<Oci.CoreService.Models.Ipv6AddressIpv6SubnetCidrPairDetails>
					{
						new Oci.CoreService.Models.Ipv6AddressIpv6SubnetCidrPairDetails
						{
							Ipv6Id = "ocid1.test.oc1..<unique_ID>EXAMPLE-ipv6Id-Value",
							Ipv6SubnetCidr = "EXAMPLE-ipv6SubnetCidr-Value",
							Ipv6Address = "EXAMPLE-ipv6Address-Value"
						}
					},
					SubnetCidr = "EXAMPLE-subnetCidr-Value",
					NsgIds = new List<string>
					{
						"EXAMPLE--Value"
					},
					PrivateIp = "EXAMPLE-privateIp-Value",
					PrivateIpId = "ocid1.test.oc1..<unique_ID>EXAMPLE-privateIpId-Value",
					SkipSourceDestCheck = false,
					SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
					VlanId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vlanId-Value"
				},
				DedicatedVmHostId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value",
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_2dMr1", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_EQrhZ", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_avov8", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_Ixm8a", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				DisplayName = "EXAMPLE-displayName-Value",
				ExtendedMetadata = new Dictionary<string, Object>()
				{
					{
						"EXAMPLE_KEY_V6Xpl", 
						"EXAMPLE--Value"
					}
				},
				FaultDomain = "EXAMPLE-faultDomain-Value",
				ClusterPlacementGroupId = "ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_KPH35", 
						"EXAMPLE_VALUE_gAd6bkjf9lPt41kLXsuH"
					}
				},
				ComputeClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-computeClusterId-Value",
				HostnameLabel = "EXAMPLE-hostnameLabel-Value",
				ImageId = "ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
				IpxeScript = "EXAMPLE-ipxeScript-Value",
				LaunchOptions = new Oci.CoreService.Models.LaunchOptions
				{
					BootVolumeType = Oci.CoreService.Models.LaunchOptions.BootVolumeTypeEnum.Scsi,
					Firmware = Oci.CoreService.Models.LaunchOptions.FirmwareEnum.Bios,
					NetworkType = Oci.CoreService.Models.LaunchOptions.NetworkTypeEnum.E1000,
					RemoteDataVolumeType = Oci.CoreService.Models.LaunchOptions.RemoteDataVolumeTypeEnum.Scsi,
					IsPvEncryptionInTransitEnabled = true,
					IsConsistentVolumeNamingEnabled = true
				},
				InstanceOptions = new Oci.CoreService.Models.InstanceOptions
				{
					AreLegacyImdsEndpointsDisabled = false
				},
				AvailabilityConfig = new Oci.CoreService.Models.LaunchInstanceAvailabilityConfigDetails
				{
					IsLiveMigrationPreferred = false,
					RecoveryAction = Oci.CoreService.Models.LaunchInstanceAvailabilityConfigDetails.RecoveryActionEnum.RestoreInstance
				},
				PreemptibleInstanceConfig = new Oci.CoreService.Models.PreemptibleInstanceConfigDetails
				{
					PreemptionAction = new Oci.CoreService.Models.TerminatePreemptionAction
					{
						PreserveBootVolume = false
					}
				},
				Metadata = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_mrFek", 
						"EXAMPLE_VALUE_jQLLV1aXuqzKntYEf8Ej"
					}
				},
				AgentConfig = new Oci.CoreService.Models.LaunchInstanceAgentConfigDetails
				{
					IsMonitoringDisabled = true,
					IsManagementDisabled = true,
					AreAllPluginsDisabled = true,
					PluginsConfig = new List<Oci.CoreService.Models.InstanceAgentPluginConfigDetails>
					{
						new Oci.CoreService.Models.InstanceAgentPluginConfigDetails
						{
							Name = "EXAMPLE-name-Value",
							DesiredState = Oci.CoreService.Models.InstanceAgentPluginConfigDetails.DesiredStateEnum.Disabled
						}
					}
				},
				Shape = "EXAMPLE-shape-Value",
				ShapeConfig = new Oci.CoreService.Models.LaunchInstanceShapeConfigDetails
				{
					Ocpus = (float)4785.45,
					Vcpus = 962,
					MemoryInGBs = (float)5762.477,
					BaselineOcpuUtilization = Oci.CoreService.Models.LaunchInstanceShapeConfigDetails.BaselineOcpuUtilizationEnum.Baseline11,
					Nvmes = 5,
					ResourceManagement = Oci.CoreService.Models.LaunchInstanceShapeConfigDetails.ResourceManagementEnum.Dynamic,
					LocalVolumeSizeInGBs = 12989
				},
				SourceDetails = new Oci.CoreService.Models.InstanceSourceViaImageDetails
				{
					BootVolumeSizeInGBs = 508,
					ImageId = "ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
					KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
					BootVolumeVpusPerGB = 824,
					InstanceSourceImageFilterDetails = new Oci.CoreService.Models.InstanceSourceImageFilterDetails
					{
						CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
						DefinedTagsFilter = new Dictionary<string, Dictionary<string, Object>>()
						{
							{
								"EXAMPLE_KEY_mPI4d", 
								new Dictionary<string, Object>()
								{
									{
										"EXAMPLE_KEY_CGvSe", 
										"EXAMPLE--Value"
									}
								}
							}
						},
						OperatingSystem = "EXAMPLE-operatingSystem-Value",
						OperatingSystemVersion = "EXAMPLE-operatingSystemVersion-Value"
					}
				},
				SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
				LaunchVolumeAttachments = new List<Oci.CoreService.Models.LaunchAttachVolumeDetails>
				{
					new Oci.CoreService.Models.LaunchAttachParavirtualizedVolumeDetails
					{
						IsPvEncryptionInTransitEnabled = false,
						Device = "EXAMPLE-device-Value",
						DisplayName = "EXAMPLE-displayName-Value",
						IsReadOnly = true,
						IsShareable = false,
						VolumeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value",
						LaunchCreateVolumeDetails = new Oci.CoreService.Models.LaunchCreateVolumeFromAttributes
						{
							CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
							DisplayName = "EXAMPLE-displayName-Value",
							KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
							VpusPerGB = 202,
							SizeInGBs = 718
						}
					}
				},
				IsPvEncryptionInTransitEnabled = false,
				PlatformConfig = new Oci.CoreService.Models.IntelSkylakeBmLaunchInstancePlatformConfig
				{
					NumaNodesPerSocket = Oci.CoreService.Models.IntelSkylakeBmLaunchInstancePlatformConfig.NumaNodesPerSocketEnum.Nps1,
					IsSymmetricMultiThreadingEnabled = true,
					IsInputOutputMemoryManagementUnitEnabled = true,
					PercentageOfCoresEnabled = 41,
					ConfigMap = new Dictionary<string, string>()
					{
						{
							"EXAMPLE_KEY_DB5iI", 
							"EXAMPLE_VALUE_4TOat93kpogQ8XYl2g68"
						}
					},
					IsSecureBootEnabled = true,
					IsTrustedPlatformModuleEnabled = false,
					IsMeasuredBootEnabled = true,
					IsMemoryEncryptionEnabled = true
				},
				PlacementConstraintDetails = new Oci.CoreService.Models.ComputeBareMetalHostPlacementConstraintDetails
				{
					ComputeBareMetalHostId = "ocid1.test.oc1..<unique_ID>EXAMPLE-computeBareMetalHostId-Value"
				},
				IsAIEnterpriseEnabled = true,
				InstanceConfigurationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value",
				LicensingConfigs = new List<Oci.CoreService.Models.LaunchInstanceLicensingConfig>
				{
					new Oci.CoreService.Models.LaunchInstanceWindowsLicensingConfig
					{
						LicenseType = Oci.CoreService.Models.LaunchInstanceLicensingConfig.LicenseTypeEnum.OciProvided
					}
				}
			};
			var launchInstanceRequest = new Oci.CoreService.Requests.LaunchInstanceRequest
			{
				LaunchInstanceDetails = launchInstanceDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value"
			};

            // Create a default authentication provider that uses the DEFAULT
            // profile in the configuration file.
            // Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file. 
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            try
            {
                // Create a service client and send the request.
				using (var client = new ComputeClient(provider, new ClientConfiguration()))
				{
					var response = await client.LaunchInstance(launchInstanceRequest);
					// Retrieve value from the response.
					var id = response.Instance.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"LaunchInstance Failed with {e.Message}");
                throw e;
            }
        }

    }
}