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

    // Create a request and dependent object(s).
    const createMigrationDetails = {
      type: databasemigration.models.MigrationTypes.Online,
      displayName: "EXAMPLE-displayName-Value",
      compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
      agentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-agentId-Value",
      sourceDatabaseConnectionId:
        "ocid1.test.oc1..<unique_ID>EXAMPLE-sourceDatabaseConnectionId-Value",
      sourceContainerDatabaseConnectionId:
        "ocid1.test.oc1..<unique_ID>EXAMPLE-sourceContainerDatabaseConnectionId-Value",
      targetDatabaseConnectionId:
        "ocid1.test.oc1..<unique_ID>EXAMPLE-targetDatabaseConnectionId-Value",
      dataTransferMediumDetailsV2: {
        type: "AWS_S3",
        name: "EXAMPLE-name-Value",
        region: "EXAMPLE-region-Value",
        accessKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-accessKeyId-Value",
        secretAccessKey: "EXAMPLE-secretAccessKey-Value",
        objectStorageBucket: {
          namespaceName: "EXAMPLE-namespaceName-Value",
          bucketName: "EXAMPLE-bucketName-Value"
        }
      },
      dataTransferMediumDetails: {
        databaseLinkDetails: {
          name: "EXAMPLE-name-Value",
          walletBucket: {
            namespaceName: "EXAMPLE-namespaceName-Value",
            bucketName: "EXAMPLE-bucketName-Value"
          }
        },
        objectStorageDetails: {
          namespaceName: "EXAMPLE-namespaceName-Value",
          bucketName: "EXAMPLE-bucketName-Value"
        },
        awsS3Details: {
          name: "EXAMPLE-name-Value",
          region: "EXAMPLE-region-Value",
          accessKeyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-accessKeyId-Value",
          secretAccessKey: "EXAMPLE-secretAccessKey-Value"
        }
      },
      dumpTransferDetails: {
        source: {
          kind: "CURL",
          walletLocation: "EXAMPLE-walletLocation-Value"
        },
        target: {
          kind: "OCI_CLI",
          ociHome: "EXAMPLE-ociHome-Value",
          walletLocation: "EXAMPLE-walletLocation-Value"
        },
        sharedStorageMountTargetId:
          "ocid1.test.oc1..<unique_ID>EXAMPLE-sharedStorageMountTargetId-Value"
      },
      datapumpSettings: {
        jobMode: databasemigration.models.DataPumpJobMode.Schema,
        dataPumpParameters: {
          isCluster: false,
          estimate: databasemigration.models.DataPumpEstimate.Statistics,
          tableExistsAction: databasemigration.models.DataPumpTableExistsAction.Truncate,
          excludeParameters: [
            databasemigration.models.DataPumpExcludeParameters.Index,
            databasemigration.models.DataPumpExcludeParameters.MaterializedView,
            databasemigration.models.DataPumpExcludeParameters.MaterializedViewLog
          ],
          importParallelismDegree: 151,
          exportParallelismDegree: 6
        },
        metadataRemaps: [
          {
            type: databasemigration.models.MetadataRemap.Type.Tablespace,
            oldValue: "EXAMPLE-oldValue-Value",
            newValue: "EXAMPLE-newValue-Value"
          }
        ],
        tablespaceDetails: {
          targetType: "NON_ADB_REMAP",
          remapTarget: "EXAMPLE-remapTarget-Value"
        },
        exportDirectoryObject: {
          name: "EXAMPLE-name-Value",
          path: "EXAMPLE-path-Value"
        },
        importDirectoryObject: {
          name: "EXAMPLE-name-Value",
          path: "EXAMPLE-path-Value"
        }
      },
      advisorSettings: {
        isSkipAdvisor: false,
        isIgnoreErrors: false
      },
      excludeObjects: [
        {
          owner: "EXAMPLE-owner-Value",
          objectName: "EXAMPLE-objectName-Value",
          type: "EXAMPLE-type-Value",
          isOmitExcludedTableFromReplication: true
        }
      ],
      includeObjects: [
        {
          owner: "EXAMPLE-owner-Value",
          objectName: "EXAMPLE-objectName-Value",
          type: "EXAMPLE-type-Value",
          isOmitExcludedTableFromReplication: true
        }
      ],
      csvText: "EXAMPLE-csvText-Value",
      goldenGateDetails: {
        hub: {
          restAdminCredentials: {
            username: "EXAMPLE-username-Value",
            password: "EXAMPLE-password-Value"
          },
          url: "EXAMPLE-url-Value",
          sourceMicroservicesDeploymentName: "EXAMPLE-sourceMicroservicesDeploymentName-Value",
          targetMicroservicesDeploymentName: "EXAMPLE-targetMicroservicesDeploymentName-Value",
          computeId: "ocid1.test.oc1..<unique_ID>EXAMPLE-computeId-Value"
        },
        settings: {
          extract: {
            performanceProfile: databasemigration.models.ExtractPerformanceProfile.High,
            longTransDuration: 539
          },
          replicat: {
            performanceProfile: databasemigration.models.ReplicatPerformanceProfile.Low,
            mapParallelism: 94,
            minApplyParallelism: 598,
            maxApplyParallelism: 918
          },
          acceptableLag: 10
        }
      },
      goldenGateServiceDetails: {
        sourceDbCredentials: {
          username: "EXAMPLE-username-Value",
          password: "EXAMPLE-password-Value"
        },
        sourceContainerDbCredentials: {
          username: "EXAMPLE-username-Value",
          password: "EXAMPLE-password-Value"
        },
        targetDbCredentials: {
          username: "EXAMPLE-username-Value",
          password: "EXAMPLE-password-Value"
        },
        settings: {
          extract: {
            performanceProfile: databasemigration.models.ExtractPerformanceProfile.Low,
            longTransDuration: 543
          },
          replicat: {
            performanceProfile: databasemigration.models.ReplicatPerformanceProfile.High,
            mapParallelism: 38,
            minApplyParallelism: 2,
            maxApplyParallelism: 776
          },
          acceptableLag: 25
        }
      },
      vaultDetails: {
        compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        vaultId: "ocid1.test.oc1..<unique_ID>EXAMPLE-vaultId-Value",
        keyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value"
      },
      freeformTags: {
        EXAMPLE_KEY_O0E77: "EXAMPLE_VALUE_Tdr6TsFqVL4dVEW5CDhr"
      },
      definedTags: {
        EXAMPLE_KEY_UDtDy: {
          EXAMPLE_KEY_I70UG: "EXAMPLE--Value"
        }
      }
    };

    const createMigrationRequest: databasemigration.requests.CreateMigrationRequest = {
      createMigrationDetails: createMigrationDetails,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value",
      opcRequestId: "CKRNFDTU9QY3VVUXGMNO<unique_ID>"
    };

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