// 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: 3712,
maximumBandwidthInMbps: 4281
},
isPrivate: false,
isDeleteProtectionEnabled: true,
ipMode: loadbalancer.models.CreateLoadBalancerDetails.IpMode.Ipv4,
reservedIps: [
{
id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"
}
],
listeners: {
EXAMPLE_KEY_Fnr7p: {
defaultBackendSetName: "EXAMPLE-defaultBackendSetName-Value",
port: 28297,
protocol: "EXAMPLE-protocol-Value",
hostnameNames: ["EXAMPLE--Value"],
pathRouteSetName: "EXAMPLE-pathRouteSetName-Value",
sslConfiguration: {
verifyDepth: 633,
verifyPeerCertificate: false,
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: 812,
backendTcpProxyProtocolVersion: 1
},
routingPolicyName: "EXAMPLE-routingPolicyName-Value",
ruleSetNames: ["EXAMPLE--Value"]
}
},
hostnames: {
EXAMPLE_KEY_HSbVi: {
name: "EXAMPLE-name-Value",
hostname: "EXAMPLE-hostname-Value"
}
},
backendSets: {
EXAMPLE_KEY_8KUw5: {
policy: "EXAMPLE-policy-Value",
backends: [
{
ipAddress: "EXAMPLE-ipAddress-Value",
port: 49109,
weight: 783,
maxConnections: 33486,
backup: true,
drain: true,
offline: false
}
],
backendMaxConnections: 22132,
healthChecker: {
protocol: "EXAMPLE-protocol-Value",
urlPath: "EXAMPLE-urlPath-Value",
port: 60775,
returnCode: 345,
retries: 777,
timeoutInMillis: 275853,
intervalInMillis: 651219,
responseBodyRegex: "EXAMPLE-responseBodyRegex-Value",
isForcePlainText: true
},
sslConfiguration: {
verifyDepth: 488,
verifyPeerCertificate: 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: false,
domain: "EXAMPLE-domain-Value",
path: "EXAMPLE-path-Value",
maxAgeInSeconds: 514,
isSecure: true,
isHttpOnly: true
}
}
},
networkSecurityGroupIds: ["EXAMPLE--Value"],
subnetIds: ["EXAMPLE--Value"],
certificates: {
EXAMPLE_KEY_RlLKF: {
passphrase: "EXAMPLE-passphrase-Value",
privateKey: "EXAMPLE-privateKey-Value",
publicCertificate: "EXAMPLE-publicCertificate-Value",
caCertificate: "EXAMPLE-caCertificate-Value",
certificateName: "EXAMPLE-certificateName-Value"
}
},
sslCipherSuites: {
EXAMPLE_KEY_3pcdx: {
name: "EXAMPLE-name-Value",
ciphers: ["EXAMPLE--Value"]
}
},
pathRouteSets: {
EXAMPLE_KEY_TMqOj: {
pathRoutes: [
{
path: "EXAMPLE-path-Value",
pathMatchType: {
matchType: loadbalancer.models.PathMatchType.MatchType.ExactMatch
},
backendSetName: "EXAMPLE-backendSetName-Value"
}
]
}
},
freeformTags: {
EXAMPLE_KEY_o4Q7u: "EXAMPLE_VALUE_inhEkiE8zi1f76fQNm6n"
},
definedTags: {
EXAMPLE_KEY_fEcxY: {
EXAMPLE_KEY_aELc6: "EXAMPLE--Value"
}
},
ruleSets: {
EXAMPLE_KEY_6NWMR: {
items: [
{
action: "IP_BASED_MAX_CONNECTIONS",
defaultMaxConnections: 58884,
ipMaxConnections: [
{
ipAddresses: ["EXAMPLE--Value"],
maxConnections: 8930
}
]
}
]
}
}
};
const createLoadBalancerRequest: loadbalancer.requests.CreateLoadBalancerRequest = {
createLoadBalancerDetails: createLoadBalancerDetails,
opcRequestId: "CV5VLYEDCCTPI3H2BA0T<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);
}
})();