// 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.ComputeManagementClient({ authenticationDetailsProvider: provider });

    // Create a request and dependent object(s).
    const instanceConfigurationInstanceDetails = {
      instanceType: "compute",
      blockVolumes: [
        {
          attachDetails: {
            type: "paravirtualized",
            isPvEncryptionInTransitEnabled: true,
            displayName: "EXAMPLE-displayName-Value",
            isReadOnly: false,
            device: "EXAMPLE-device-Value",
            isShareable: true
          },
          createDetails: {
            availabilityDomain: "EXAMPLE-availabilityDomain-Value",
            backupPolicyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-backupPolicyId-Value",
            compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
            definedTags: {
              EXAMPLE_KEY_3BumP: {
                EXAMPLE_KEY_FWycU: "EXAMPLE--Value"
              }
            },
            displayName: "EXAMPLE-displayName-Value",
            freeformTags: {
              EXAMPLE_KEY_pCSuv: "EXAMPLE_VALUE_NZOcClwsoqLIX0D3Jmrf"
            },
            kmsKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
            vpusPerGB: 549,
            sizeInGBs: 311,
            sourceDetails: {
              type: "volumeBackup",
              id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"
            }
          },
          volumeId: "ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value"
        }
      ],
      launchDetails: {
        availabilityDomain: "EXAMPLE-availabilityDomain-Value",
        capacityReservationId: "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
        compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        createVnicDetails: {
          assignPublicIp: false,
          assignPrivateDnsRecord: false,
          definedTags: {
            EXAMPLE_KEY_w73T7: {
              EXAMPLE_KEY_JKdYv: "EXAMPLE--Value"
            }
          },
          displayName: "EXAMPLE-displayName-Value",
          freeformTags: {
            EXAMPLE_KEY_ZKyaU: "EXAMPLE_VALUE_4ebDz4rnKA7YNKbWg1yB"
          },
          hostnameLabel: "EXAMPLE-hostnameLabel-Value",
          nsgIds: ["EXAMPLE--Value"],
          privateIp: "EXAMPLE-privateIp-Value",
          skipSourceDestCheck: true,
          subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
        },
        definedTags: {
          EXAMPLE_KEY_9J2ED: {
            EXAMPLE_KEY_KyQqk: "EXAMPLE--Value"
          }
        },
        displayName: "EXAMPLE-displayName-Value",
        extendedMetadata: {
          EXAMPLE_KEY_KWHrG: "EXAMPLE--Value"
        },
        freeformTags: {
          EXAMPLE_KEY_ALknJ: "EXAMPLE_VALUE_vHUeTjsO5LiwCqaYkaCA"
        },
        ipxeScript: "EXAMPLE-ipxeScript-Value",
        metadata: {
          EXAMPLE_KEY_P600B: "EXAMPLE_VALUE_ztk4Ak4H8BgytR86LxMV"
        },
        shape: "EXAMPLE-shape-Value",
        shapeConfig: {
          ocpus: 3668.5378,
          memoryInGBs: 4382.036,
          baselineOcpuUtilization:
            core.models.InstanceConfigurationLaunchInstanceShapeConfigDetails
              .BaselineOcpuUtilization.Baseline11
        },
        platformConfig: {
          type: "INTEL_VM",
          isSecureBootEnabled: true,
          isTrustedPlatformModuleEnabled: true,
          isMeasuredBootEnabled: true
        },
        sourceDetails: {
          sourceType: "bootVolume",
          bootVolumeId: "ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"
        },
        faultDomain: "EXAMPLE-faultDomain-Value",
        dedicatedVmHostId: "ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value",
        launchMode:
          core.models.InstanceConfigurationLaunchInstanceDetails.LaunchMode.Paravirtualized,
        launchOptions: {
          bootVolumeType: core.models.InstanceConfigurationLaunchOptions.BootVolumeType.Ide,
          firmware: core.models.InstanceConfigurationLaunchOptions.Firmware.Bios,
          networkType: core.models.InstanceConfigurationLaunchOptions.NetworkType.Vfio,
          remoteDataVolumeType:
            core.models.InstanceConfigurationLaunchOptions.RemoteDataVolumeType.Ide,
          isPvEncryptionInTransitEnabled: false,
          isConsistentVolumeNamingEnabled: false
        },
        agentConfig: {
          isMonitoringDisabled: true,
          isManagementDisabled: false,
          areAllPluginsDisabled: true,
          pluginsConfig: [
            {
              name: "EXAMPLE-name-Value",
              desiredState: core.models.InstanceAgentPluginConfigDetails.DesiredState.Disabled
            }
          ]
        },
        isPvEncryptionInTransitEnabled: true,
        preferredMaintenanceAction:
          core.models.InstanceConfigurationLaunchInstanceDetails.PreferredMaintenanceAction.Reboot,
        instanceOptions: {
          areLegacyImdsEndpointsDisabled: true
        },
        availabilityConfig: {
          recoveryAction:
            core.models.InstanceConfigurationAvailabilityConfig.RecoveryAction.StopInstance
        },
        preemptibleInstanceConfig: {
          preemptionAction: {
            type: "TERMINATE",
            preserveBootVolume: false
          }
        }
      },
      secondaryVnics: [
        {
          createVnicDetails: {
            assignPublicIp: false,
            assignPrivateDnsRecord: false,
            definedTags: {
              EXAMPLE_KEY_wIOsV: {
                EXAMPLE_KEY_kSci3: "EXAMPLE--Value"
              }
            },
            displayName: "EXAMPLE-displayName-Value",
            freeformTags: {
              EXAMPLE_KEY_6M0ZB: "EXAMPLE_VALUE_YRmj2estPwLZAHEDJx6l"
            },
            hostnameLabel: "EXAMPLE-hostnameLabel-Value",
            nsgIds: ["EXAMPLE--Value"],
            privateIp: "EXAMPLE-privateIp-Value",
            skipSourceDestCheck: false,
            subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
          },
          displayName: "EXAMPLE-displayName-Value",
          nicIndex: 755
        }
      ]
    };

    const launchInstanceConfigurationRequest: core.requests.LaunchInstanceConfigurationRequest = {
      instanceConfigurationId: "ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value",
      instanceConfiguration: instanceConfigurationInstanceDetails,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value"
    };

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