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

    // Create a request and dependent object(s).
    const createTaskDetails = {
      modelType: "SQL_TASK",
      script: {
        key: "EXAMPLE-key-Value",
        modelType: "EXAMPLE-modelType-Value",
        modelVersion: "EXAMPLE-modelVersion-Value",
        parentRef: {
          parent: "EXAMPLE-parent-Value",
          rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
        },
        objectStatus: 859
      },
      sqlScriptType: dataintegration.models.CreateTaskFromSQLTask.SqlScriptType.SqlCode,
      operation: "EXAMPLE-operation-Value",
      key: "EXAMPLE-key-Value",
      modelVersion: "EXAMPLE-modelVersion-Value",
      parentRef: {
        parent: "EXAMPLE-parent-Value",
        rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
      },
      name: "EXAMPLE-name-Value",
      description: "EXAMPLE-description-Value",
      objectStatus: 92,
      identifier: "EXAMPLE-identifier-Value",
      inputPorts: [
        {
          modelType: "INPUT_PORT",
          portType: dataintegration.models.InputPort.PortType.Data,
          fields: [
            {
              modelType: "DYNAMIC_PROXY_FIELD",
              type: {
                modelType: "MAP_TYPE",
                keyElementType: "EXAMPLE-keyElementType-Value",
                valueElementType: "EXAMPLE-valueElementType-Value",
                containsNull: true,
                key: "EXAMPLE-key-Value",
                modelVersion: "EXAMPLE-modelVersion-Value",
                parentRef: {
                  parent: "EXAMPLE-parent-Value",
                  rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
                },
                name: "EXAMPLE-name-Value",
                objectStatus: 335,
                description: "EXAMPLE-description-Value"
              },
              labels: ["EXAMPLE--Value"],
              key: "EXAMPLE-key-Value",
              modelVersion: "EXAMPLE-modelVersion-Value",
              parentRef: {
                parent: "EXAMPLE-parent-Value",
                rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
              },
              configValues: {
                configParamValues: {
                  EXAMPLE_KEY_aMHqo: {
                    stringValue: "EXAMPLE-stringValue-Value",
                    intValue: 988,
                    objectValue: "EXAMPLE-objectValue-Value",
                    refValue: "EXAMPLE-refValue-Value",
                    parameterValue: "EXAMPLE-parameterValue-Value",
                    rootObjectValue: "EXAMPLE-rootObjectValue-Value"
                  }
                },
                parentRef: {
                  parent: "EXAMPLE-parent-Value",
                  rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
                }
              },
              objectStatus: 595,
              name: "EXAMPLE-name-Value",
              description: "EXAMPLE-description-Value"
            }
          ],
          key: "EXAMPLE-key-Value",
          modelVersion: "EXAMPLE-modelVersion-Value",
          parentRef: {
            parent: "EXAMPLE-parent-Value",
            rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
          },
          configValues: {
            configParamValues: {
              EXAMPLE_KEY_1Kmru: {
                stringValue: "EXAMPLE-stringValue-Value",
                intValue: 870,
                objectValue: "EXAMPLE-objectValue-Value",
                refValue: "EXAMPLE-refValue-Value",
                parameterValue: "EXAMPLE-parameterValue-Value",
                rootObjectValue: "EXAMPLE-rootObjectValue-Value"
              }
            },
            parentRef: {
              parent: "EXAMPLE-parent-Value",
              rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
            }
          },
          objectStatus: 3,
          name: "EXAMPLE-name-Value",
          description: "EXAMPLE-description-Value"
        }
      ],
      outputPorts: [
        {
          modelType: "OUTPUT_PORT",
          portType: dataintegration.models.OutputPort.PortType.Control,
          fields: [
            {
              modelType: "DERIVED_FIELD",
              expr: {
                key: "EXAMPLE-key-Value",
                modelType: "EXAMPLE-modelType-Value",
                modelVersion: "EXAMPLE-modelVersion-Value",
                parentRef: {
                  parent: "EXAMPLE-parent-Value",
                  rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
                },
                exprString: "EXAMPLE-exprString-Value",
                configValues: {
                  configParamValues: {
                    EXAMPLE_KEY_LTByO: {
                      stringValue: "EXAMPLE-stringValue-Value",
                      intValue: 417,
                      objectValue: "EXAMPLE-objectValue-Value",
                      refValue: "EXAMPLE-refValue-Value",
                      parameterValue: "EXAMPLE-parameterValue-Value",
                      rootObjectValue: "EXAMPLE-rootObjectValue-Value"
                    }
                  },
                  parentRef: {
                    parent: "EXAMPLE-parent-Value",
                    rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
                  }
                },
                objectStatus: 904
              },
              type: "EXAMPLE-type-Value",
              isUseInferredType: true,
              labels: ["EXAMPLE--Value"],
              key: "EXAMPLE-key-Value",
              modelVersion: "EXAMPLE-modelVersion-Value",
              parentRef: {
                parent: "EXAMPLE-parent-Value",
                rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
              },
              configValues: {
                configParamValues: {
                  EXAMPLE_KEY_HCBFP: {
                    stringValue: "EXAMPLE-stringValue-Value",
                    intValue: 564,
                    objectValue: "EXAMPLE-objectValue-Value",
                    refValue: "EXAMPLE-refValue-Value",
                    parameterValue: "EXAMPLE-parameterValue-Value",
                    rootObjectValue: "EXAMPLE-rootObjectValue-Value"
                  }
                },
                parentRef: {
                  parent: "EXAMPLE-parent-Value",
                  rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
                }
              },
              objectStatus: 189,
              name: "EXAMPLE-name-Value",
              description: "EXAMPLE-description-Value"
            }
          ],
          key: "EXAMPLE-key-Value",
          modelVersion: "EXAMPLE-modelVersion-Value",
          parentRef: {
            parent: "EXAMPLE-parent-Value",
            rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
          },
          configValues: {
            configParamValues: {
              EXAMPLE_KEY_OysNd: {
                stringValue: "EXAMPLE-stringValue-Value",
                intValue: 745,
                objectValue: "EXAMPLE-objectValue-Value",
                refValue: "EXAMPLE-refValue-Value",
                parameterValue: "EXAMPLE-parameterValue-Value",
                rootObjectValue: "EXAMPLE-rootObjectValue-Value"
              }
            },
            parentRef: {
              parent: "EXAMPLE-parent-Value",
              rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
            }
          },
          objectStatus: 217,
          name: "EXAMPLE-name-Value",
          description: "EXAMPLE-description-Value"
        }
      ],
      parameters: [
        {
          modelType: "PARAMETER",
          type: "EXAMPLE-type-Value",
          defaultValue: "EXAMPLE-defaultValue-Value",
          rootObjectDefaultValue: "EXAMPLE-rootObjectDefaultValue-Value",
          isInput: true,
          isOutput: false,
          outputAggregationType: dataintegration.models.Parameter.OutputAggregationType.Count,
          typeName: "EXAMPLE-typeName-Value",
          usedFor: "EXAMPLE-usedFor-Value",
          key: "EXAMPLE-key-Value",
          modelVersion: "EXAMPLE-modelVersion-Value",
          parentRef: {
            parent: "EXAMPLE-parent-Value",
            rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
          },
          configValues: {
            configParamValues: {
              EXAMPLE_KEY_oxubz: {
                stringValue: "EXAMPLE-stringValue-Value",
                intValue: 12,
                objectValue: "EXAMPLE-objectValue-Value",
                refValue: "EXAMPLE-refValue-Value",
                parameterValue: "EXAMPLE-parameterValue-Value",
                rootObjectValue: "EXAMPLE-rootObjectValue-Value"
              }
            },
            parentRef: {
              parent: "EXAMPLE-parent-Value",
              rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
            }
          },
          objectStatus: 804,
          name: "EXAMPLE-name-Value",
          description: "EXAMPLE-description-Value"
        }
      ],
      opConfigValues: {
        configParamValues: {
          EXAMPLE_KEY_Yu7rv: {
            stringValue: "EXAMPLE-stringValue-Value",
            intValue: 637,
            objectValue: "EXAMPLE-objectValue-Value",
            refValue: "EXAMPLE-refValue-Value",
            parameterValue: "EXAMPLE-parameterValue-Value",
            rootObjectValue: "EXAMPLE-rootObjectValue-Value"
          }
        },
        parentRef: {
          parent: "EXAMPLE-parent-Value",
          rootDocId: "ocid1.test.oc1..<unique_ID>EXAMPLE-rootDocId-Value"
        }
      },
      configProviderDelegate: {
        bindings: {
          EXAMPLE_KEY_DQ51q: {
            simpleValue: "EXAMPLE-simpleValue-Value",
            rootObjectValue: "EXAMPLE-rootObjectValue-Value"
          }
        }
      },
      isConcurrentAllowed: false,
      registryMetadata: {
        aggregatorKey: "EXAMPLE-aggregatorKey-Value",
        labels: ["EXAMPLE--Value"],
        registryVersion: 436,
        key: "EXAMPLE-key-Value",
        isFavorite: false
      }
    };

    const createTaskRequest: dataintegration.requests.CreateTaskRequest = {
      workspaceId: "ocid1.test.oc1..<unique_ID>EXAMPLE-workspaceId-Value",
      createTaskDetails: createTaskDetails,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value",
      opcRequestId: "0ABT87JQGVGXR7CCR4VJ<unique_ID>"
    };

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