// 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 = true,
					AssignPrivateDnsRecord = true,
					DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
					{
						{
							"EXAMPLE_KEY_vw5Zf", 
							new Dictionary<string, Object>()
							{
								{
									"EXAMPLE_KEY_GdyYE", 
									"EXAMPLE--Value"
								}
							}
						}
					},
					DisplayName = "EXAMPLE-displayName-Value",
					FreeformTags = new Dictionary<string, string>()
					{
						{
							"EXAMPLE_KEY_UlIhj", 
							"EXAMPLE_VALUE_blqNuQsOuTONtDNGVTdF"
						}
					},
					SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
					{
						{
							"EXAMPLE_KEY_EYCqH", 
							new Dictionary<string, Object>()
							{
								{
									"EXAMPLE_KEY_jtims", 
									"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_clbA0", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_pJHKg", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_aDDGZ", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_11uWz", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				DisplayName = "EXAMPLE-displayName-Value",
				ExtendedMetadata = new Dictionary<string, Object>()
				{
					{
						"EXAMPLE_KEY_np1rL", 
						"EXAMPLE--Value"
					}
				},
				FaultDomain = "EXAMPLE-faultDomain-Value",
				ClusterPlacementGroupId = "ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_Ghp4Z", 
						"EXAMPLE_VALUE_Kiu7AVCYql1TElwH9tAl"
					}
				},
				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.Paravirtualized,
					Firmware = Oci.CoreService.Models.LaunchOptions.FirmwareEnum.Bios,
					NetworkType = Oci.CoreService.Models.LaunchOptions.NetworkTypeEnum.Acceleratedpv,
					RemoteDataVolumeType = Oci.CoreService.Models.LaunchOptions.RemoteDataVolumeTypeEnum.Paravirtualized,
					IsPvEncryptionInTransitEnabled = true,
					IsConsistentVolumeNamingEnabled = true
				},
				InstanceOptions = new Oci.CoreService.Models.InstanceOptions
				{
					AreLegacyImdsEndpointsDisabled = true
				},
				AvailabilityConfig = new Oci.CoreService.Models.LaunchInstanceAvailabilityConfigDetails
				{
					IsLiveMigrationPreferred = false,
					RecoveryAction = Oci.CoreService.Models.LaunchInstanceAvailabilityConfigDetails.RecoveryActionEnum.StopInstance
				},
				PreemptibleInstanceConfig = new Oci.CoreService.Models.PreemptibleInstanceConfigDetails
				{
					PreemptionAction = new Oci.CoreService.Models.TerminatePreemptionAction
					{
						PreserveBootVolume = false
					}
				},
				Metadata = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_LF8ga", 
						"EXAMPLE_VALUE_c6FCwdSINj3luqsFvOS8"
					}
				},
				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.Enabled
						}
					}
				},
				Shape = "EXAMPLE-shape-Value",
				ShapeConfig = new Oci.CoreService.Models.LaunchInstanceShapeConfigDetails
				{
					Ocpus = (float)3011.331,
					Vcpus = 848,
					MemoryInGBs = (float)8240.731,
					BaselineOcpuUtilization = Oci.CoreService.Models.LaunchInstanceShapeConfigDetails.BaselineOcpuUtilizationEnum.Baseline18,
					Nvmes = 6,
					ResourceManagement = Oci.CoreService.Models.LaunchInstanceShapeConfigDetails.ResourceManagementEnum.Static,
					LocalVolumeSizeInGBs = 5567
				},
				SourceDetails = new Oci.CoreService.Models.InstanceSourceViaBootVolumeDetails
				{
					BootVolumeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-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 = true,
						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 = 986,
							SizeInGBs = 136
						}
					}
				},
				IsPvEncryptionInTransitEnabled = true,
				PlatformConfig = new Oci.CoreService.Models.AmdMilanBmGpuLaunchInstancePlatformConfig
				{
					NumaNodesPerSocket = Oci.CoreService.Models.AmdMilanBmGpuLaunchInstancePlatformConfig.NumaNodesPerSocketEnum.Nps2,
					IsSymmetricMultiThreadingEnabled = false,
					IsAccessControlServiceEnabled = true,
					AreVirtualInstructionsEnabled = true,
					IsInputOutputMemoryManagementUnitEnabled = false,
					ConfigMap = new Dictionary<string, string>()
					{
						{
							"EXAMPLE_KEY_gNoQK", 
							"EXAMPLE_VALUE_DysOSU1cq2ZcQWXwUGIj"
						}
					},
					IsSecureBootEnabled = false,
					IsTrustedPlatformModuleEnabled = true,
					IsMeasuredBootEnabled = false,
					IsMemoryEncryptionEnabled = false
				},
				PlacementConstraintDetails = new Oci.CoreService.Models.HostGroupPlacementConstraintDetails
				{
					ComputeHostGroupId = "ocid1.test.oc1..<unique_ID>EXAMPLE-computeHostGroupId-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.PartnerProvided
					}
				}
			};
			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;
            }
        }

    }
}