// 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 cloudmigrations from "oci-cloudmigrations";
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 cloudmigrations.MigrationClient({ authenticationDetailsProvider: provider });

    // Create a request and dependent object(s).
    const createTargetAssetDetails = {
      type: "INSTANCE",
      preferredShapeType: cloudmigrations.models.VmTargetAsset.PreferredShapeType.VmIntelDensIo,
      blockVolumesPerformance: 70,
      msLicense: "EXAMPLE-msLicense-Value",
      userSpec: {
        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_OrJlz: {
              EXAMPLE_KEY_VvLo7: "EXAMPLE--Value"
            }
          },
          displayName: "EXAMPLE-displayName-Value",
          freeformTags: {
            EXAMPLE_KEY_0QwEa: "EXAMPLE_VALUE_1NnlR9qFNY7bEIqsKstg"
          },
          hostnameLabel: "EXAMPLE-hostnameLabel-Value",
          nsgIds: ["EXAMPLE--Value"],
          privateIp: "EXAMPLE-privateIp-Value",
          skipSourceDestCheck: false,
          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_su8Dd: {
            EXAMPLE_KEY_gQHvl: "EXAMPLE--Value"
          }
        },
        displayName: "EXAMPLE-displayName-Value",
        faultDomain: "EXAMPLE-faultDomain-Value",
        freeformTags: {
          EXAMPLE_KEY_Ntsvt: "EXAMPLE_VALUE_AggeKKO2s0ylHGRfMyFF"
        },
        hostnameLabel: "EXAMPLE-hostnameLabel-Value",
        ipxeScript: "EXAMPLE-ipxeScript-Value",
        instanceOptions: {
          areLegacyImdsEndpointsDisabled: true
        },
        preemptibleInstanceConfig: {
          preemptionAction: {
            type: "TERMINATE",
            preserveBootVolume: true
          }
        },
        agentConfig: {
          isMonitoringDisabled: true,
          isManagementDisabled: true,
          areAllPluginsDisabled: false,
          pluginsConfig: [
            {
              name: "EXAMPLE-name-Value",
              desiredState:
                cloudmigrations.models.InstanceAgentPluginConfigDetails.DesiredState.Disabled
            }
          ]
        },
        shape: "EXAMPLE-shape-Value",
        shapeConfig: {
          ocpus: 176.78082,
          memoryInGBs: 1456.831,
          baselineOcpuUtilization:
            cloudmigrations.models.LaunchInstanceShapeConfigDetails.BaselineOcpuUtilization
              .Baseline18
        },
        sourceDetails: {
          sourceType: "image",
          bootVolumeSizeInGBs: 597,
          imageId: "ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
          kmsKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
          bootVolumeVpusPerGB: 778
        },
        isPvEncryptionInTransitEnabled: true
      },
      migrationPlanId: "ocid1.test.oc1..<unique_ID>EXAMPLE-migrationPlanId-Value",
      isExcludedFromExecution: true
    };

    const createTargetAssetRequest: cloudmigrations.requests.CreateTargetAssetRequest = {
      createTargetAssetDetails: createTargetAssetDetails,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value",
      opcRequestId: "G5BPRYEWEGTI78Y4FNNL<unique_ID>"
    };

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