// 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{SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_GdKEl": loadbalancer.SslCipherSuiteDetails{Name: common.String("EXAMPLE-name-Value"),
Ciphers: []string{"EXAMPLE--Value"}}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_BCz9p": map[string]interface{}{"EXAMPLE_KEY_1xS0o": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_fjFJm": "EXAMPLE_VALUE_XBEIEMEUx2wWqLulR3H9"},
IsPrivate: common.Bool(true),
IsRequestIdEnabled: common.Bool(true),
ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_SV2Gr": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.AllowRule{Conditions: []loadbalancer.RuleCondition{loadbalancer.PathMatchCondition{AttributeValue: common.String("EXAMPLE-attributeValue-Value"),
Operator: loadbalancer.PathMatchConditionOperatorExactMatch}},
Description: common.String("EXAMPLE-description-Value")}}}},
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(5637),
MinimumBandwidthInMbps: common.Int(2380)},
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_Tf1II": 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")}},
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_Qfo6n": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
IsDeleteProtectionEnabled: common.Bool(false),
ShapeName: common.String("EXAMPLE-shapeName-Value"),
SubnetIds: []string{"EXAMPLE--Value"},
BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_JUq05": loadbalancer.BackendSetDetails{SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(false),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(538),
VerifyPeerCertificate: common.Bool(true)},
BackendMaxConnections: common.Int(48142),
Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(1493),
Offline: common.Bool(true),
Port: common.Int(15051),
Weight: common.Int(662),
Backup: common.Bool(true),
Drain: common.Bool(false)}},
HealthChecker: &loadbalancer.HealthCheckerDetails{Retries: common.Int(855),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
IntervalInMillis: common.Int(1.057888e+06),
IsForcePlainText: common.Bool(true),
Protocol: common.String("EXAMPLE-protocol-Value"),
ReturnCode: common.Int(644),
TimeoutInMillis: common.Int(196421),
Port: common.Int(35369),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value")},
LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{Domain: common.String("EXAMPLE-domain-Value"),
IsHttpOnly: common.Bool(true),
IsSecure: common.Bool(false),
MaxAgeInSeconds: common.Int(152),
Path: common.String("EXAMPLE-path-Value"),
CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(true)},
Policy: common.String("EXAMPLE-policy-Value")}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_HUo88": loadbalancer.ListenerDetails{PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
Protocol: common.String("EXAMPLE-protocol-Value"),
RuleSetNames: []string{"EXAMPLE--Value"},
ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(646)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
Port: common.Int(40924),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
SslConfiguration: &loadbalancer.SslConfigurationDetails{CertificateIds: []string{"EXAMPLE--Value"},
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
HasSessionResumption: common.Bool(false),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled,
VerifyDepth: common.Int(108),
VerifyPeerCertificate: common.Bool(false)},
HostnameNames: []string{"EXAMPLE--Value"}}},
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_ozQTm": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{BackendSetName: common.String("EXAMPLE-backendSetName-Value"),
Path: common.String("EXAMPLE-path-Value"),
PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypeSuffixMatch}}}}},
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_DIOS5": map[string]interface{}{"EXAMPLE_KEY_3FUsm": "EXAMPLE--Value"}}},
OpcRequestId: common.String("HBN7XNMJLD4UN1NNDSM3<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)
}