// 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: "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_FlrCi: {
                  EXAMPLE_KEY_8tpel: "EXAMPLE--Value"
                }
              },
              displayName: "EXAMPLE-displayName-Value",
              freeformTags: {
                EXAMPLE_KEY_m44ne: "EXAMPLE_VALUE_Dbl6QItoVM5ObNGKy6CN"
              },
              kmsKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
              vpusPerGB: 794,
              sizeInGBs: 986,
              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: true,
            definedTags: {
              EXAMPLE_KEY_xERPT: {
                EXAMPLE_KEY_os3lR: "EXAMPLE--Value"
              }
            },
            displayName: "EXAMPLE-displayName-Value",
            freeformTags: {
              EXAMPLE_KEY_NnCs1: "EXAMPLE_VALUE_lvPB1yRbErdoWo31tizP"
            },
            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_nMCRQ: {
              EXAMPLE_KEY_yDUME: "EXAMPLE--Value"
            }
          },
          displayName: "EXAMPLE-displayName-Value",
          extendedMetadata: {
            EXAMPLE_KEY_UyeoO: "EXAMPLE--Value"
          },
          freeformTags: {
            EXAMPLE_KEY_PYRaj: "EXAMPLE_VALUE_LgqdjJJPQFHnTiCjZtsH"
          },
          ipxeScript: "EXAMPLE-ipxeScript-Value",
          metadata: {
            EXAMPLE_KEY_Fbvkr: "EXAMPLE_VALUE_ZWmtUCc6DMPbUNp4sYsh"
          },
          shape: "EXAMPLE-shape-Value",
          shapeConfig: {
            ocpus: 6836.542,
            memoryInGBs: 9262.28,
            baselineOcpuUtilization:
              core.models.InstanceConfigurationLaunchInstanceShapeConfigDetails
                .BaselineOcpuUtilization.Baseline12
          },
          platformConfig: {
            type: "AMD_VM",
            isSecureBootEnabled: false,
            isTrustedPlatformModuleEnabled: false,
            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.Scsi,
            firmware: core.models.InstanceConfigurationLaunchOptions.Firmware.Uefi64,
            networkType: core.models.InstanceConfigurationLaunchOptions.NetworkType.Vfio,
            remoteDataVolumeType:
              core.models.InstanceConfigurationLaunchOptions.RemoteDataVolumeType.Scsi,
            isPvEncryptionInTransitEnabled: true,
            isConsistentVolumeNamingEnabled: true
          },
          agentConfig: {
            isMonitoringDisabled: false,
            isManagementDisabled: false,
            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: true,
              assignPrivateDnsRecord: false,
              definedTags: {
                EXAMPLE_KEY_EaeU8: {
                  EXAMPLE_KEY_mfx0q: "EXAMPLE--Value"
                }
              },
              displayName: "EXAMPLE-displayName-Value",
              freeformTags: {
                EXAMPLE_KEY_ZEfHz: "EXAMPLE_VALUE_w1CejNBGesPGzY8z3h7u"
              },
              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: 398
          }
        ]
      },
      compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
      definedTags: {
        EXAMPLE_KEY_nS3Av: {
          EXAMPLE_KEY_05cKB: "EXAMPLE--Value"
        }
      },
      displayName: "EXAMPLE-displayName-Value",
      freeformTags: {
        EXAMPLE_KEY_MBL9D: "EXAMPLE_VALUE_apuB3jtnkJOFNK1KPPtq"
      }
    };

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