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

    // Create a request and dependent object(s).
    const createModelDeploymentDetails = {
      displayName: "EXAMPLE-displayName-Value",
      description: "EXAMPLE-description-Value",
      projectId: "ocid1.test.oc1..<unique_ID>EXAMPLE-projectId-Value",
      compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
      modelDeploymentConfigurationDetails: {
        deploymentType: "SINGLE_MODEL",
        modelConfigurationDetails: {
          modelId: "ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value",
          instanceConfiguration: {
            instanceShapeName: "EXAMPLE-instanceShapeName-Value",
            modelDeploymentInstanceShapeConfigDetails: {
              ocpus: 0.80296326,
              memoryInGBs: 700.02454,
              cpuBaseline:
                datascience.models.ModelDeploymentInstanceShapeConfigDetails.CpuBaseline.Baseline18
            },
            subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
          },
          scalingPolicy: {
            policyType: "AUTOSCALING",
            coolDownInSeconds: 665,
            isEnabled: false,
            autoScalingPolicies: [
              {
                autoScalingPolicyType: "THRESHOLD",
                rules: [
                  {
                    metricExpressionRuleType: "CUSTOM_EXPRESSION",
                    scaleInConfiguration: {
                      scalingConfigurationType: "QUERY",
                      query: "EXAMPLE-query-Value",
                      pendingDuration: "EXAMPLE-pendingDuration-Value",
                      instanceCountAdjustment: 559
                    }
                  }
                ],
                maximumInstanceCount: 2,
                minimumInstanceCount: 493,
                initialInstanceCount: 287
              }
            ]
          },
          bandwidthMbps: 7087,
          maximumBandwidthMbps: 4325
        },
        environmentConfigurationDetails: {
          environmentConfigurationType: "OCIR_CONTAINER",
          image: "EXAMPLE-image-Value",
          imageDigest: "EXAMPLE-imageDigest-Value",
          cmd: ["EXAMPLE--Value"],
          entrypoint: ["EXAMPLE--Value"],
          serverPort: 244,
          healthCheckPort: 274,
          environmentVariables: {
            EXAMPLE_KEY_WpiB2: "EXAMPLE_VALUE_pURJsVOzA40IVRW8KS2R"
          }
        }
      },
      categoryLogDetails: {
        access: {
          logId: "ocid1.test.oc1..<unique_ID>EXAMPLE-logId-Value",
          logGroupId: "ocid1.test.oc1..<unique_ID>EXAMPLE-logGroupId-Value"
        },
        predict: {
          logId: "ocid1.test.oc1..<unique_ID>EXAMPLE-logId-Value",
          logGroupId: "ocid1.test.oc1..<unique_ID>EXAMPLE-logGroupId-Value"
        }
      },
      freeformTags: {
        EXAMPLE_KEY_sY8lR: "EXAMPLE_VALUE_42aPf7XrW1FmYKKDmnfi"
      },
      definedTags: {
        EXAMPLE_KEY_yef7o: {
          EXAMPLE_KEY_aX8jL: "EXAMPLE--Value"
        }
      }
    };

    const createModelDeploymentRequest: datascience.requests.CreateModelDeploymentRequest = {
      createModelDeploymentDetails: createModelDeploymentDetails,
      opcRequestId: "QTMXJIX68E6SEQC3PO9F<unique_ID>",
      opcRetryToken: "EXAMPLE-opcRetryToken-Value"
    };

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