// 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{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_5wtg2": map[string]interface{}{"EXAMPLE_KEY_zM61h": "EXAMPLE--Value"}},
IsDeleteProtectionEnabled: common.Bool(false),
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_r98fs": loadbalancer.ListenerDetails{ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{IdleTimeout: common.Int64(990),
BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
RuleSetNames: []string{"EXAMPLE--Value"},
SslConfiguration: &loadbalancer.SslConfigurationDetails{CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(true),
VerifyPeerCertificate: common.Bool(true),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled,
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(57)},
HostnameNames: []string{"EXAMPLE--Value"},
Port: common.Int(31087),
Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value")}},
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_Aea9r": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.RemoveHttpRequestHeaderRule{Header: common.String("EXAMPLE-header-Value")}}}},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_DO3Sn": map[string]interface{}{"EXAMPLE_KEY_qkPlx": "EXAMPLE--Value"}},
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_FM9xr": loadbalancer.CertificateDetails{PublicCertificate: common.String("EXAMPLE-publicCertificate-Value"),
CaCertificate: common.String("EXAMPLE-caCertificate-Value"),
CertificateName: common.String("EXAMPLE-certificateName-Value"),
Passphrase: common.String("EXAMPLE-passphrase-Value"),
PrivateKey: common.String("EXAMPLE-privateKey-Value")}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_raSAW": "EXAMPLE_VALUE_ohFZbkOwvQwTa2TNpntM"},
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
IsRequestIdEnabled: common.Bool(false),
ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(1311),
MinimumBandwidthInMbps: common.Int(2485)},
ShapeName: common.String("EXAMPLE-shapeName-Value"),
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_4KOvN": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{BackendSetName: common.String("EXAMPLE-backendSetName-Value"),
Path: common.String("EXAMPLE-path-Value"),
PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypeExactMatch}}}}},
SubnetIds: []string{"EXAMPLE--Value"},
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv4,
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_vFRmT": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
IsPrivate: common.Bool(false),
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_w8Og8": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_IPif9": loadbalancer.BackendSetDetails{Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Offline: common.Bool(false),
Port: common.Int(35337),
Weight: common.Int(826),
Backup: common.Bool(false),
Drain: common.Bool(false),
IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(65340)}},
HealthChecker: &loadbalancer.HealthCheckerDetails{Port: common.Int(4558),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value"),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
IsForcePlainText: common.Bool(true),
Protocol: common.String("EXAMPLE-protocol-Value"),
Retries: common.Int(816),
ReturnCode: common.Int(24),
TimeoutInMillis: common.Int(413433),
IntervalInMillis: common.Int(1.356782e+06)},
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(260)},
Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(true)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{Protocols: []string{"EXAMPLE--Value"},
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(92),
CertificateIds: []string{"EXAMPLE--Value"},
HasSessionResumption: common.Bool(false),
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
VerifyPeerCertificate: common.Bool(true),
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value")},
BackendMaxConnections: common.Int(26433)}}},
OpcRequestId: common.String("737AZMJJ6OZZCWWPZGCZ<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)
}