// 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).

import * as core from "oci-core";
import common = require("oci-common");

// 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.

const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();

(async () => {
  try {
    // Create a service client
    const client = new core.ComputeClient({ authenticationDetailsProvider: provider });

    // Create a request and dependent object(s).
    const launchInstanceDetails = {
      availabilityDomain: "EXAMPLE-availabilityDomain-Value",
      capacityReservationId: "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
      compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
      createVnicDetails: {
        assignIpv6Ip: true,
        assignPublicIp: true,
        assignPrivateDnsRecord: false,
        definedTags: {
          EXAMPLE_KEY_d7qSe: {
            EXAMPLE_KEY_UwHFL: "EXAMPLE--Value"
          }
        },
        displayName: "EXAMPLE-displayName-Value",
        freeformTags: {
          EXAMPLE_KEY_pltCT: "EXAMPLE_VALUE_8WY49bidM42zHrAznDAx"
        },
        hostnameLabel: "EXAMPLE-hostnameLabel-Value",
        ipv6AddressIpv6SubnetCidrPairDetails: [
          {
            ipv6SubnetCidr: "EXAMPLE-ipv6SubnetCidr-Value",
            ipv6Address: "EXAMPLE-ipv6Address-Value"
          }
        ],
        nsgIds: ["EXAMPLE--Value"],
        privateIp: "EXAMPLE-privateIp-Value",
        skipSourceDestCheck: true,
        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: {
        EXAMPLE_KEY_XtJro: {
          EXAMPLE_KEY_jibuR: "EXAMPLE--Value"
        }
      },
      displayName: "EXAMPLE-displayName-Value",
      extendedMetadata: {
        EXAMPLE_KEY_u88Nz: "EXAMPLE--Value"
      },
      faultDomain: "EXAMPLE-faultDomain-Value",
      clusterPlacementGroupId: "ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value",
      freeformTags: {
        EXAMPLE_KEY_39FwN: "EXAMPLE_VALUE_s5Ght81OAB1JjaPHIn83"
      },
      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: {
        bootVolumeType: core.models.LaunchOptions.BootVolumeType.Iscsi,
        firmware: core.models.LaunchOptions.Firmware.Uefi64,
        networkType: core.models.LaunchOptions.NetworkType.Paravirtualized,
        remoteDataVolumeType: core.models.LaunchOptions.RemoteDataVolumeType.Ide,
        isPvEncryptionInTransitEnabled: true,
        isConsistentVolumeNamingEnabled: true
      },
      instanceOptions: {
        areLegacyImdsEndpointsDisabled: false
      },
      availabilityConfig: {
        isLiveMigrationPreferred: false,
        recoveryAction:
          core.models.LaunchInstanceAvailabilityConfigDetails.RecoveryAction.StopInstance
      },
      preemptibleInstanceConfig: {
        preemptionAction: {
          type: "TERMINATE",
          preserveBootVolume: false
        }
      },
      metadata: {
        EXAMPLE_KEY_JhWbU: "EXAMPLE_VALUE_q2CgMvKzKZHef6ax54Bx"
      },
      agentConfig: {
        isMonitoringDisabled: true,
        isManagementDisabled: true,
        areAllPluginsDisabled: false,
        pluginsConfig: [
          {
            name: "EXAMPLE-name-Value",
            desiredState: core.models.InstanceAgentPluginConfigDetails.DesiredState.Disabled
          }
        ]
      },
      shape: "EXAMPLE-shape-Value",
      shapeConfig: {
        ocpus: 1770.9791,
        vcpus: 250,
        memoryInGBs: 3181.5088,
        baselineOcpuUtilization:
          core.models.LaunchInstanceShapeConfigDetails.BaselineOcpuUtilization.Baseline11,
        nvmes: 2
      },
      sourceDetails: {
        sourceType: "bootVolume",
        bootVolumeId: "ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"
      },
      subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
      launchVolumeAttachments: [
        {
          type: "iscsi",
          useChap: true,
          encryptionInTransitType: core.models.EncryptionInTransitType.BmEncryptionInTransit,
          isAgentAutoIscsiLoginEnabled: false,
          device: "EXAMPLE-device-Value",
          displayName: "EXAMPLE-displayName-Value",
          isReadOnly: false,
          isShareable: false,
          volumeId: "ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value",
          launchCreateVolumeDetails: {
            volumeCreationType: "ATTRIBUTES",
            compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
            displayName: "EXAMPLE-displayName-Value",
            kmsKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
            vpusPerGB: 725,
            sizeInGBs: 120
          }
        }
      ],
      isPvEncryptionInTransitEnabled: true,
      platformConfig: {
        type: "AMD_MILAN_BM",
        numaNodesPerSocket:
          core.models.AmdMilanBmLaunchInstancePlatformConfig.NumaNodesPerSocket.Nps4,
        isSymmetricMultiThreadingEnabled: false,
        isAccessControlServiceEnabled: true,
        areVirtualInstructionsEnabled: true,
        isInputOutputMemoryManagementUnitEnabled: true,
        percentageOfCoresEnabled: 93,
        configMap: {
          EXAMPLE_KEY_KV0BF: "EXAMPLE_VALUE_A8Fl5rUazAEpzxHGusgV"
        },
        isSecureBootEnabled: true,
        isTrustedPlatformModuleEnabled: false,
        isMeasuredBootEnabled: false,
        isMemoryEncryptionEnabled: true
      },
      instanceConfigurationId: "ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value"
    };

    const launchInstanceRequest: core.requests.LaunchInstanceRequest = {
      launchInstanceDetails: launchInstanceDetails,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value"
    };

    // Send request to the Client.
    const launchInstanceResponse = await client.launchInstance(launchInstanceRequest);
  } catch (error) {
    console.log("launchInstance Failed with error  " + error);
  }
})();