// 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{IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_QcWox": loadbalancer.ListenerDetails{ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(56),
BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority}},
Port: common.Int(39850),
Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
RuleSetNames: []string{"EXAMPLE--Value"},
SslConfiguration: &loadbalancer.SslConfigurationDetails{TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(578),
VerifyPeerCertificate: common.Bool(false),
CertificateIds: []string{"EXAMPLE--Value"},
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled,
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(true)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
HostnameNames: []string{"EXAMPLE--Value"},
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value")}},
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_ucIel": 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}}}}},
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_TL1fE": "EXAMPLE_VALUE_jaiq2Ms6atma40YjToCU"},
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_73uBL": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
IsRequestIdEnabled: common.Bool(true),
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(6436),
MinimumBandwidthInMbps: common.Int(6925)},
ShapeName: common.String("EXAMPLE-shapeName-Value"),
IsDeleteProtectionEnabled: common.Bool(true),
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_cMfrB": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.HttpHeaderRule{AreInvalidCharactersAllowed: common.Bool(false),
HttpLargeHeaderSizeInKB: common.Int(917)}}}},
SubnetIds: []string{"EXAMPLE--Value"},
BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_TyVJ1": loadbalancer.BackendSetDetails{BackendMaxConnections: common.Int(61589),
Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Backup: common.Bool(false),
Drain: common.Bool(false),
IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(10322),
Offline: common.Bool(true),
Port: common.Int(20084),
Weight: common.Int(933)}},
HealthChecker: &loadbalancer.HealthCheckerDetails{Retries: common.Int(620),
ReturnCode: common.Int(464),
TimeoutInMillis: common.Int(143292),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
IsForcePlainText: common.Bool(true),
Port: common.Int(54963),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value"),
IntervalInMillis: common.Int(490580),
Protocol: common.String("EXAMPLE-protocol-Value")},
LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{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(540),
Path: common.String("EXAMPLE-path-Value")},
Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
VerifyPeerCertificate: common.Bool(false),
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
HasSessionResumption: common.Bool(false),
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(956)}}},
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_kgO8d": loadbalancer.CertificateDetails{PrivateKey: common.String("EXAMPLE-privateKey-Value"),
PublicCertificate: common.String("EXAMPLE-publicCertificate-Value"),
CaCertificate: common.String("EXAMPLE-caCertificate-Value"),
CertificateName: common.String("EXAMPLE-certificateName-Value"),
Passphrase: common.String("EXAMPLE-passphrase-Value")}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
IsPrivate: common.Bool(true),
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_LDGBZ": map[string]interface{}{"EXAMPLE_KEY_AND5h": "EXAMPLE--Value"}},
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_c0oZ0": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_oKEQi": map[string]interface{}{"EXAMPLE_KEY_q869w": "EXAMPLE--Value"}}},
OpcRequestId: common.String("I4BTBUOSSD409BNQV6FY<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)
}