// 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: false,
subnetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
networkSecurityGroupIds: ["EXAMPLE--Value" ],
nlbIpVersion: networkloadbalancer.models.NlbIpVersion.Ipv4AndIpv6,
subnetIpv6Cidr: "EXAMPLE-subnetIpv6Cidr-Value",
assignedPrivateIpv4: "EXAMPLE-assignedPrivateIpv4-Value",
assignedIpv6: "EXAMPLE-assignedIpv6-Value",
listeners: {
EXAMPLE_KEY_4RUvT :{
name: "EXAMPLE-name-Value",
defaultBackendSetName: "EXAMPLE-defaultBackendSetName-Value",
ipVersion: networkloadbalancer.models.IpVersion.Ipv4,
port: 815,
protocol: networkloadbalancer.models.ListenerProtocols.L3Ip,
isPpv2Enabled: true,
tcpIdleTimeout: 23,
udpIdleTimeout: 305,
l3IpIdleTimeout: 145,
}
},
backendSets: {
EXAMPLE_KEY_EwFHt :{
policy: networkloadbalancer.models.NetworkLoadBalancingPolicy.ThreeTuple,
ipVersion: networkloadbalancer.models.IpVersion.Ipv6,
isPreserveSource: false,
isFailOpen: true,
isInstantFailoverEnabled: true,
isInstantFailoverTcpResetEnabled: false,
areOperationallyActiveBackendsPreferred: true,
backends: [{
name: "EXAMPLE-name-Value",
ipAddress: "EXAMPLE-ipAddress-Value",
targetId: "ocid1.test.oc1..<unique_ID>EXAMPLE-targetId-Value",
port: 245,
weight: 126,
isDrain: true,
isBackup: true,
isOffline: false,
}
],
healthChecker: {
protocol: networkloadbalancer.models.HealthCheckProtocols.Http,
port: 274,
retries: 310,
timeoutInMillis: 80,
intervalInMillis: 707,
urlPath: "EXAMPLE-urlPath-Value",
responseBodyRegex: "EXAMPLE-responseBodyRegex-Value",
returnCode: 807,
requestData: "some Byte data",
responseData: "some Byte data",
dns: {
transportProtocol: networkloadbalancer.models.DnsHealthCheckTransportProtocols.Udp,
domainName: "EXAMPLE-domainName-Value",
queryClass: networkloadbalancer.models.DnsHealthCheckQueryClasses.In,
queryType: networkloadbalancer.models.DnsHealthCheckQueryTypes.A,
rcodes: [networkloadbalancer.models.DnsHealthCheckRCodes.Noerror,networkloadbalancer.models.DnsHealthCheckRCodes.Servfail,networkloadbalancer.models.DnsHealthCheckRCodes.Nxdomain,networkloadbalancer.models.DnsHealthCheckRCodes.Refused ],
}
,
}
,
}
},
freeformTags: {
EXAMPLE_KEY_WzX1c :"EXAMPLE_VALUE_PicXd6mCOLEINw4Amd5C"
},
definedTags: {
EXAMPLE_KEY_iWy7o :{
EXAMPLE_KEY_7tICI :"EXAMPLE--Value"
}
},
securityAttributes: {
EXAMPLE_KEY_pf1wD :{
EXAMPLE_KEY_aR7qJ :"EXAMPLE--Value"
}
},
}
const createNetworkLoadBalancerRequest: networkloadbalancer.requests.CreateNetworkLoadBalancerRequest = {
createNetworkLoadBalancerDetails: createNetworkLoadBalancerDetails,
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
opcRequestId: "P8TLGOGKST7NWMJBRUQ1<unique_ID>",
};
// Send request to the Client.
const createNetworkLoadBalancerResponse = await client.createNetworkLoadBalancer(createNetworkLoadBalancerRequest);
}
catch (error) {
console.log("createNetworkLoadBalancer Failed with error " + error);
}
})();