// 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: true,
            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_IsfJo: {
                EXAMPLE_KEY_FZjXW: "EXAMPLE--Value"
              }
            },
            displayName: "EXAMPLE-displayName-Value",
            freeformTags: {
              EXAMPLE_KEY_rKt6P: "EXAMPLE_VALUE_kr3yvhzAWXHrUt0ZdIyD"
            },
            kmsKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
            vpusPerGB: 809,
            sizeInGBs: 845,
            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: true,
          assignPrivateDnsRecord: true,
          definedTags: {
            EXAMPLE_KEY_KZa0D: {
              EXAMPLE_KEY_O2xnR: "EXAMPLE--Value"
            }
          },
          displayName: "EXAMPLE-displayName-Value",
          freeformTags: {
            EXAMPLE_KEY_e8TVK: "EXAMPLE_VALUE_PEKY2pXdHeWFhJ3LX3Qx"
          },
          hostnameLabel: "EXAMPLE-hostnameLabel-Value",
          nsgIds: ["EXAMPLE--Value"],
          privateIp: "EXAMPLE-privateIp-Value",
          skipSourceDestCheck: false,
          subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
        },
        definedTags: {
          EXAMPLE_KEY_hsGLf: {
            EXAMPLE_KEY_OBS1h: "EXAMPLE--Value"
          }
        },
        displayName: "EXAMPLE-displayName-Value",
        extendedMetadata: {
          EXAMPLE_KEY_WIACW: "EXAMPLE--Value"
        },
        freeformTags: {
          EXAMPLE_KEY_SUNNS: "EXAMPLE_VALUE_jazFkM8LHbeQ3qhc3xro"
        },
        ipxeScript: "EXAMPLE-ipxeScript-Value",
        metadata: {
          EXAMPLE_KEY_5sR2r: "EXAMPLE_VALUE_SjS17uU2AwOhRbkFi4AE"
        },
        shape: "EXAMPLE-shape-Value",
        shapeConfig: {
          ocpus: 4875.8647,
          memoryInGBs: 5819.225,
          baselineOcpuUtilization:
            core.models.InstanceConfigurationLaunchInstanceShapeConfigDetails
              .BaselineOcpuUtilization.Baseline11
        },
        platformConfig: {
          type: "INTEL_VM",
          isSecureBootEnabled: true,
          isTrustedPlatformModuleEnabled: true,
          isMeasuredBootEnabled: false
        },
        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.Emulated,
        launchOptions: {
          bootVolumeType:
            core.models.InstanceConfigurationLaunchOptions.BootVolumeType.Paravirtualized,
          firmware: core.models.InstanceConfigurationLaunchOptions.Firmware.Bios,
          networkType: core.models.InstanceConfigurationLaunchOptions.NetworkType.Vfio,
          remoteDataVolumeType:
            core.models.InstanceConfigurationLaunchOptions.RemoteDataVolumeType.Iscsi,
          isPvEncryptionInTransitEnabled: false,
          isConsistentVolumeNamingEnabled: true
        },
        agentConfig: {
          isMonitoringDisabled: true,
          isManagementDisabled: true,
          areAllPluginsDisabled: true,
          pluginsConfig: [
            {
              name: "EXAMPLE-name-Value",
              desiredState: core.models.InstanceAgentPluginConfigDetails.DesiredState.Enabled
            }
          ]
        },
        isPvEncryptionInTransitEnabled: false,
        preferredMaintenanceAction:
          core.models.InstanceConfigurationLaunchInstanceDetails.PreferredMaintenanceAction.Reboot,
        instanceOptions: {
          areLegacyImdsEndpointsDisabled: true
        },
        availabilityConfig: {
          recoveryAction:
            core.models.InstanceConfigurationAvailabilityConfig.RecoveryAction.RestoreInstance
        },
        preemptibleInstanceConfig: {
          preemptionAction: {
            type: "TERMINATE",
            preserveBootVolume: false
          }
        }
      },
      secondaryVnics: [
        {
          createVnicDetails: {
            assignPublicIp: false,
            assignPrivateDnsRecord: true,
            definedTags: {
              EXAMPLE_KEY_CXczZ: {
                EXAMPLE_KEY_b3INI: "EXAMPLE--Value"
              }
            },
            displayName: "EXAMPLE-displayName-Value",
            freeformTags: {
              EXAMPLE_KEY_ExzRY: "EXAMPLE_VALUE_KzUzt6GxJ0VVijrsW79I"
            },
            hostnameLabel: "EXAMPLE-hostnameLabel-Value",
            nsgIds: ["EXAMPLE--Value"],
            privateIp: "EXAMPLE-privateIp-Value",
            skipSourceDestCheck: true,
            subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
          },
          displayName: "EXAMPLE-displayName-Value",
          nicIndex: 504
        }
      ]
    };

    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);
  }
})();