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

    // Create a request and dependent object(s).
    const createNetworkLoadBalancerDetails = {
      compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
      displayName: "EXAMPLE-displayName-Value",
      isPreserveSourceDestination: false,
      isSymmetricHashEnabled: true,
      reservedIps: [
        {
          id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"
        }
      ],
      isPrivate: true,
      subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
      networkSecurityGroupIds: ["EXAMPLE--Value"],
      nlbIpVersion: networkloadbalancer.models.NlbIpVersion.Ipv4,
      listeners: {
        EXAMPLE_KEY_qMoGS: {
          name: "EXAMPLE-name-Value",
          defaultBackendSetName: "EXAMPLE-defaultBackendSetName-Value",
          ipVersion: networkloadbalancer.models.IpVersion.Ipv6,
          port: 718,
          protocol: networkloadbalancer.models.ListenerProtocols.Any
        }
      },
      backendSets: {
        EXAMPLE_KEY_xSRTu: {
          policy: networkloadbalancer.models.NetworkLoadBalancingPolicy.ThreeTuple,
          ipVersion: networkloadbalancer.models.IpVersion.Ipv6,
          isPreserveSource: true,
          backends: [
            {
              name: "EXAMPLE-name-Value",
              ipAddress: "EXAMPLE-ipAddress-Value",
              targetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-targetId-Value",
              port: 720,
              weight: 80,
              isDrain: true,
              isBackup: false,
              isOffline: false
            }
          ],
          healthChecker: {
            protocol: networkloadbalancer.models.HealthCheckProtocols.Http,
            port: 233,
            retries: 587,
            timeoutInMillis: 161,
            intervalInMillis: 263,
            urlPath: "EXAMPLE-urlPath-Value",
            responseBodyRegex: "EXAMPLE-responseBodyRegex-Value",
            returnCode: 67,
            requestData: "some Byte data",
            responseData: "some Byte data"
          }
        }
      },
      freeformTags: {
        EXAMPLE_KEY_liUF8: "EXAMPLE_VALUE_Hbs7OhTGEqvRVF3A3vAz"
      },
      definedTags: {
        EXAMPLE_KEY_hPLeo: {
          EXAMPLE_KEY_9SGEc: "EXAMPLE--Value"
        }
      }
    };

    const createNetworkLoadBalancerRequest: networkloadbalancer.requests.CreateNetworkLoadBalancerRequest = {
      createNetworkLoadBalancerDetails: createNetworkLoadBalancerDetails,
      opcRetryToken: "EXAMPLE-opcRetryToken-Value",
      opcRequestId: "LRVXEKZNNEQ5O0Q8OUMM<unique_ID>"
    };

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