// 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{BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_Pxt4h": loadbalancer.BackendSetDetails{HealthChecker: &loadbalancer.HealthCheckerDetails{ReturnCode: common.Int(799),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
IntervalInMillis: common.Int(665779),
Protocol: common.String("EXAMPLE-protocol-Value"),
Retries: common.Int(924),
TimeoutInMillis: common.Int(71554),
IsForcePlainText: common.Bool(false),
Port: common.Int(62055),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value")},
LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{IsHttpOnly: common.Bool(true),
IsSecure: common.Bool(true),
MaxAgeInSeconds: common.Int(913),
Path: common.String("EXAMPLE-path-Value"),
CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false),
Domain: common.String("EXAMPLE-domain-Value")},
Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(true),
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled,
Protocols: []string{"EXAMPLE--Value"},
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(943),
VerifyPeerCertificate: common.Bool(false),
CertificateIds: []string{"EXAMPLE--Value"}},
BackendMaxConnections: common.Int(32805),
Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Backup: common.Bool(true),
Drain: common.Bool(false),
IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(36735),
Offline: common.Bool(true),
Port: common.Int(23296),
Weight: common.Int(405)}}}},
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_nCZ67": loadbalancer.ListenerDetails{ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(780)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
HostnameNames: []string{"EXAMPLE--Value"},
Port: common.Int(32875),
RuleSetNames: []string{"EXAMPLE--Value"},
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
SslConfiguration: &loadbalancer.SslConfigurationDetails{HasSessionResumption: common.Bool(false),
Protocols: []string{"EXAMPLE--Value"},
VerifyPeerCertificate: common.Bool(true),
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(417)}}},
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_9NUV4": 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}}}}},
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(356),
MinimumBandwidthInMbps: common.Int(1499)},
ShapeName: common.String("EXAMPLE-shapeName-Value"),
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_zAWSH": 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")}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_vCFug": "EXAMPLE_VALUE_BaofiRO34diC9tmE6IgD"},
IsDeleteProtectionEnabled: common.Bool(false),
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_OOHBa": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.RemoveHttpResponseHeaderRule{Header: common.String("EXAMPLE-header-Value")}}}},
SubnetIds: []string{"EXAMPLE--Value"},
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_18Sn2": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_FwKzj": map[string]interface{}{"EXAMPLE_KEY_Ica2k": "EXAMPLE--Value"}},
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_7jX94": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
IsPrivate: common.Bool(false),
IsRequestIdEnabled: common.Bool(false),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_hjKUn": map[string]interface{}{"EXAMPLE_KEY_7UIzb": "EXAMPLE--Value"}},
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}}},
OpcRequestId: common.String("DMYWHRGMUQJHUO88QFO6<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)
}