// 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 createInstanceConfigurationBase = {
      source: "NONE",
      instanceDetails: {
        instanceType: "compute",
        blockVolumes: [
          {
            attachDetails: {
              type: "iscsi",
              useChap: 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_P6Tkd: {
                  EXAMPLE_KEY_f3SkM: "EXAMPLE--Value"
                }
              },
              displayName: "EXAMPLE-displayName-Value",
              freeformTags: {
                EXAMPLE_KEY_oiAsQ: "EXAMPLE_VALUE_xCNyfkDzNpaJ8NlEjeSp"
              },
              kmsKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
              vpusPerGB: 145,
              sizeInGBs: 102,
              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: false,
            definedTags: {
              EXAMPLE_KEY_inpeY: {
                EXAMPLE_KEY_n6b1A: "EXAMPLE--Value"
              }
            },
            displayName: "EXAMPLE-displayName-Value",
            freeformTags: {
              EXAMPLE_KEY_BdgsQ: "EXAMPLE_VALUE_zvOaMbhhxuMM54WQ7jB5"
            },
            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_X4UeF: {
              EXAMPLE_KEY_v7PWD: "EXAMPLE--Value"
            }
          },
          displayName: "EXAMPLE-displayName-Value",
          extendedMetadata: {
            EXAMPLE_KEY_22mzC: "EXAMPLE--Value"
          },
          freeformTags: {
            EXAMPLE_KEY_fGjtH: "EXAMPLE_VALUE_A3KnmtC0U1ZOMUTxjRtC"
          },
          ipxeScript: "EXAMPLE-ipxeScript-Value",
          metadata: {
            EXAMPLE_KEY_w0rGF: "EXAMPLE_VALUE_3eTtDV5Ju8PPVOTy8vyk"
          },
          shape: "EXAMPLE-shape-Value",
          shapeConfig: {
            ocpus: 7594.81,
            memoryInGBs: 1580.1406,
            baselineOcpuUtilization:
              core.models.InstanceConfigurationLaunchInstanceShapeConfigDetails
                .BaselineOcpuUtilization.Baseline18
          },
          platformConfig: {
            type: "AMD_ROME_BM",
            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.Paravirtualized,
            remoteDataVolumeType:
              core.models.InstanceConfigurationLaunchOptions.RemoteDataVolumeType.Ide,
            isPvEncryptionInTransitEnabled: true,
            isConsistentVolumeNamingEnabled: true
          },
          agentConfig: {
            isMonitoringDisabled: false,
            isManagementDisabled: false,
            areAllPluginsDisabled: false,
            pluginsConfig: [
              {
                name: "EXAMPLE-name-Value",
                desiredState: core.models.InstanceAgentPluginConfigDetails.DesiredState.Enabled
              }
            ]
          },
          isPvEncryptionInTransitEnabled: false,
          preferredMaintenanceAction:
            core.models.InstanceConfigurationLaunchInstanceDetails.PreferredMaintenanceAction
              .LiveMigrate,
          instanceOptions: {
            areLegacyImdsEndpointsDisabled: false
          },
          availabilityConfig: {
            recoveryAction:
              core.models.InstanceConfigurationAvailabilityConfig.RecoveryAction.StopInstance
          },
          preemptibleInstanceConfig: {
            preemptionAction: {
              type: "TERMINATE",
              preserveBootVolume: false
            }
          }
        },
        secondaryVnics: [
          {
            createVnicDetails: {
              assignPublicIp: false,
              assignPrivateDnsRecord: true,
              definedTags: {
                EXAMPLE_KEY_D66ET: {
                  EXAMPLE_KEY_dFPAo: "EXAMPLE--Value"
                }
              },
              displayName: "EXAMPLE-displayName-Value",
              freeformTags: {
                EXAMPLE_KEY_77UbT: "EXAMPLE_VALUE_LJhgWzXLuqF5dqoei2cG"
              },
              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: 872
          }
        ]
      },
      compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
      definedTags: {
        EXAMPLE_KEY_JqIT1: {
          EXAMPLE_KEY_lqOku: "EXAMPLE--Value"
        }
      },
      displayName: "EXAMPLE-displayName-Value",
      freeformTags: {
        EXAMPLE_KEY_1kttC: "EXAMPLE_VALUE_kEnaAsOkf8cMA4Vv3bpf"
      }
    };

    const createInstanceConfigurationRequest: core.requests.CreateInstanceConfigurationRequest = {
      createInstanceConfiguration: createInstanceConfigurationBase,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value"
    };

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