// 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).
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/example/helpers"
"github.com/oracle/oci-go-sdk/v65/loadbalancer"
)
func ExampleCreateLoadBalancer() {
// 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.
client, err := loadbalancer.NewLoadBalancerClientWithConfigurationProvider(common.DefaultConfigProvider())
helpers.FatalIfError(err)
// Create a request and dependent object(s).
req := loadbalancer.CreateLoadBalancerRequest{CreateLoadBalancerDetails: loadbalancer.CreateLoadBalancerDetails{DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_5wtg2": "EXAMPLE_VALUE_qkPlxDO3SnfAea9r737A"},
IsPrivate: common.Bool(true),
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
SubnetIds: []string{"EXAMPLE--Value"},
ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_bkOwv": loadbalancer.BackendSetDetails{Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Weight: common.Int(862),
Backup: common.Bool(false),
Drain: common.Bool(false),
IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(13261),
Offline: common.Bool(false),
Port: common.Int(48516)}},
HealthChecker: &loadbalancer.HealthCheckerDetails{ReturnCode: common.Int(417),
IntervalInMillis: common.Int(876404),
Port: common.Int(59668),
Protocol: common.String("EXAMPLE-protocol-Value"),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value"),
Retries: common.Int(578),
IsForcePlainText: common.Bool(false),
TimeoutInMillis: common.Int(78128),
UrlPath: common.String("EXAMPLE-urlPath-Value")},
LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{Path: common.String("EXAMPLE-path-Value"),
CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false),
Domain: common.String("EXAMPLE-domain-Value"),
IsHttpOnly: common.Bool(true),
IsSecure: common.Bool(true),
MaxAgeInSeconds: common.Int(622)},
Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(122),
VerifyPeerCertificate: common.Bool(false),
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(false),
Protocols: []string{"EXAMPLE--Value"}},
BackendMaxConnections: common.Int(400)}},
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_QwTa2": loadbalancer.CertificateDetails{Passphrase: common.String("EXAMPLE-passphrase-Value"),
PrivateKey: common.String("EXAMPLE-privateKey-Value"),
PublicCertificate: common.String("EXAMPLE-publicCertificate-Value"),
CaCertificate: common.String("EXAMPLE-caCertificate-Value"),
CertificateName: common.String("EXAMPLE-certificateName-Value")}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_ozZcw": map[string]interface{}{"EXAMPLE_KEY_zMjJ6": "EXAMPLE--Value"}},
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_dD0w1": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
IsDeleteProtectionEnabled: common.Bool(true),
IsRequestIdEnabled: common.Bool(true),
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_zM61h": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{BackendSetName: common.String("EXAMPLE-backendSetName-Value"),
Path: common.String("EXAMPLE-path-Value"),
PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypeForceLongestPrefixMatch}}}}},
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_0CJRa": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.ExtendHttpResponseHeaderValueRule{Header: common.String("EXAMPLE-header-Value"),
Prefix: common.String("EXAMPLE-prefix-Value"),
Suffix: common.String("EXAMPLE-suffix-Value")}}}},
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_TNpnt": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_ZBOn0": map[string]interface{}{"EXAMPLE_KEY_wpzGC": "EXAMPLE--Value"}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_qmDun": loadbalancer.ListenerDetails{Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(382)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
HostnameNames: []string{"EXAMPLE--Value"},
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
Port: common.Int(8286),
RuleSetNames: []string{"EXAMPLE--Value"},
SslConfiguration: &loadbalancer.SslConfigurationDetails{HasSessionResumption: common.Bool(false),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
VerifyPeerCertificate: common.Bool(true),
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(694)}}},
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(1274),
MinimumBandwidthInMbps: common.Int(5418)},
ShapeName: common.String("EXAMPLE-shapeName-Value")},
OpcRequestId: common.String("NHOSMFZGV0IRQVUVLNAU<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}
// Send the request using the service client
resp, err := client.CreateLoadBalancer(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}