// 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{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
CreateLoadBalancerDetails: loadbalancer.CreateLoadBalancerDetails{ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_wTfJR": map[string]interface{}{"EXAMPLE_KEY_FaUHd": "EXAMPLE--Value"}},
ShapeName: common.String("EXAMPLE-shapeName-Value"),
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_8Sn2s": map[string]interface{}{"EXAMPLE_KEY_CZ671": "EXAMPLE--Value"}},
IsDeleteProtectionEnabled: common.Bool(true),
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_iXLzh": loadbalancer.ListenerDetails{HostnameNames: []string{"EXAMPLE--Value"},
Port: common.Int(21941),
Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
RuleSetNames: []string{"EXAMPLE--Value"},
ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(409)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
SslConfiguration: &loadbalancer.SslConfigurationDetails{CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(true),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(937),
VerifyPeerCertificate: common.Bool(true)}}},
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_WlcMu": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_RjsDs": loadbalancer.BackendSetDetails{BackendMaxConnections: common.Int(50430),
Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Offline: common.Bool(true),
Port: common.Int(6534),
Weight: common.Int(220),
Backup: common.Bool(false),
Drain: common.Bool(true),
IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(9500)}},
HealthChecker: &loadbalancer.HealthCheckerDetails{Retries: common.Int(858),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
IntervalInMillis: common.Int(1.782348e+06),
ReturnCode: common.Int(20),
TimeoutInMillis: common.Int(534602),
IsForcePlainText: common.Bool(true),
Port: common.Int(42715),
Protocol: common.String("EXAMPLE-protocol-Value"),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value")},
LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{Domain: common.String("EXAMPLE-domain-Value"),
IsHttpOnly: common.Bool(false),
IsSecure: common.Bool(false),
MaxAgeInSeconds: common.Int(709),
Path: common.String("EXAMPLE-path-Value"),
CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false)},
Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(true)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{VerifyDepth: common.Int(268),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyPeerCertificate: common.Bool(true),
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
HasSessionResumption: common.Bool(true),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled}}},
FreeformTags: map[string]string{"EXAMPLE_KEY_cJJTx": "EXAMPLE_VALUE_iGXA6zWbodVL3qLvA2qn"},
IsRequestIdEnabled: common.Bool(true),
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_rNZLE": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypePrefixMatch},
BackendSetName: common.String("EXAMPLE-backendSetName-Value"),
Path: common.String("EXAMPLE-path-Value")}}}},
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_Ja5ws": 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")}}}},
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_1z5Vk": loadbalancer.CertificateDetails{CaCertificate: common.String("EXAMPLE-caCertificate-Value"),
CertificateName: common.String("EXAMPLE-certificateName-Value"),
Passphrase: common.String("EXAMPLE-passphrase-Value"),
PrivateKey: common.String("EXAMPLE-privateKey-Value"),
PublicCertificate: common.String("EXAMPLE-publicCertificate-Value")}},
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
IsPrivate: common.Bool(false),
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(6985),
MinimumBandwidthInMbps: common.Int(6519)},
SubnetIds: []string{"EXAMPLE--Value"},
DisplayName: common.String("EXAMPLE-displayName-Value"),
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_xujlI": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"}},
OpcRequestId: common.String("BBIWXJEHP9FCGXUPXT4H<unique_ID>")}
// 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)
}