// 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 loadbalancer from "oci-loadbalancer";
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 loadbalancer.LoadBalancerClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const createLoadBalancerDetails = {
compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
displayName: "EXAMPLE-displayName-Value",
shapeName: "EXAMPLE-shapeName-Value",
shapeDetails: {
minimumBandwidthInMbps: 7474,
maximumBandwidthInMbps: 1011
},
isPrivate: false,
isDeleteProtectionEnabled: true,
ipMode: loadbalancer.models.CreateLoadBalancerDetails.IpMode.Ipv6,
reservedIps: [
{
id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"
}
],
listeners: {
EXAMPLE_KEY_kZcxg: {
defaultBackendSetName: "EXAMPLE-defaultBackendSetName-Value",
port: 50422,
protocol: "EXAMPLE-protocol-Value",
hostnameNames: ["EXAMPLE--Value"],
pathRouteSetName: "EXAMPLE-pathRouteSetName-Value",
sslConfiguration: {
verifyDepth: 41,
verifyPeerCertificate: false,
hasSessionResumption: true,
trustedCertificateAuthorityIds: ["EXAMPLE--Value"],
certificateIds: ["EXAMPLE--Value"],
certificateName: "EXAMPLE-certificateName-Value",
protocols: ["EXAMPLE--Value"],
cipherSuiteName: "EXAMPLE-cipherSuiteName-Value",
serverOrderPreference:
loadbalancer.models.SSLConfigurationDetails.ServerOrderPreference.Enabled
},
connectionConfiguration: {
idleTimeout: 477,
backendTcpProxyProtocolVersion: 1
},
routingPolicyName: "EXAMPLE-routingPolicyName-Value",
ruleSetNames: ["EXAMPLE--Value"]
}
},
hostnames: {
EXAMPLE_KEY_VmTQs: {
name: "EXAMPLE-name-Value",
hostname: "EXAMPLE-hostname-Value"
}
},
backendSets: {
EXAMPLE_KEY_j7I2F: {
policy: "EXAMPLE-policy-Value",
backends: [
{
ipAddress: "EXAMPLE-ipAddress-Value",
port: 17478,
weight: 97,
maxConnections: 13667,
backup: true,
drain: true,
offline: true
}
],
backendMaxConnections: 49543,
healthChecker: {
protocol: "EXAMPLE-protocol-Value",
urlPath: "EXAMPLE-urlPath-Value",
port: 5982,
returnCode: 528,
retries: 985,
timeoutInMillis: 85845,
intervalInMillis: 1093858,
responseBodyRegex: "EXAMPLE-responseBodyRegex-Value",
isForcePlainText: false
},
sslConfiguration: {
verifyDepth: 928,
verifyPeerCertificate: false,
hasSessionResumption: true,
trustedCertificateAuthorityIds: ["EXAMPLE--Value"],
certificateIds: ["EXAMPLE--Value"],
certificateName: "EXAMPLE-certificateName-Value",
protocols: ["EXAMPLE--Value"],
cipherSuiteName: "EXAMPLE-cipherSuiteName-Value",
serverOrderPreference:
loadbalancer.models.SSLConfigurationDetails.ServerOrderPreference.Enabled
},
sessionPersistenceConfiguration: {
cookieName: "EXAMPLE-cookieName-Value",
disableFallback: false
},
lbCookieSessionPersistenceConfiguration: {
cookieName: "EXAMPLE-cookieName-Value",
disableFallback: true,
domain: "EXAMPLE-domain-Value",
path: "EXAMPLE-path-Value",
maxAgeInSeconds: 115,
isSecure: false,
isHttpOnly: true
}
}
},
networkSecurityGroupIds: ["EXAMPLE--Value"],
subnetIds: ["EXAMPLE--Value"],
certificates: {
EXAMPLE_KEY_RkZY7: {
passphrase: "EXAMPLE-passphrase-Value",
privateKey: "EXAMPLE-privateKey-Value",
publicCertificate: "EXAMPLE-publicCertificate-Value",
caCertificate: "EXAMPLE-caCertificate-Value",
certificateName: "EXAMPLE-certificateName-Value"
}
},
sslCipherSuites: {
EXAMPLE_KEY_C698e: {
name: "EXAMPLE-name-Value",
ciphers: ["EXAMPLE--Value"]
}
},
pathRouteSets: {
EXAMPLE_KEY_xhPtC: {
pathRoutes: [
{
path: "EXAMPLE-path-Value",
pathMatchType: {
matchType: loadbalancer.models.PathMatchType.MatchType.PrefixMatch
},
backendSetName: "EXAMPLE-backendSetName-Value"
}
]
}
},
freeformTags: {
EXAMPLE_KEY_c6ryD: "EXAMPLE_VALUE_MNyKQlS9mBVdOPe4HFSn"
},
definedTags: {
EXAMPLE_KEY_2KUCI: {
EXAMPLE_KEY_3r0BH: "EXAMPLE--Value"
}
},
ruleSets: {
EXAMPLE_KEY_IyBX4: {
items: [
{
action: "ADD_HTTP_RESPONSE_HEADER",
header: "EXAMPLE-header-Value",
value: "EXAMPLE-value-Value"
}
]
}
}
};
const createLoadBalancerRequest: loadbalancer.requests.CreateLoadBalancerRequest = {
createLoadBalancerDetails: createLoadBalancerDetails,
opcRequestId: "KVHFFIIWNEMDRDRFRVNK<unique_ID>",
opcRetryToken: "EXAMPLE-opcRetryToken-Value"
};
// Send request to the Client.
const createLoadBalancerResponse = await client.createLoadBalancer(createLoadBalancerRequest);
} catch (error) {
console.log("createLoadBalancer Failed with error " + error);
}
})();