// 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{BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_0l7jK": loadbalancer.BackendSetDetails{BackendMaxConnections: common.Int(43730),
Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Port: common.Int(54428),
Weight: common.Int(614),
Backup: common.Bool(false),
Drain: common.Bool(false),
IpAddress: common.String("EXAMPLE-ipAddress-Value"),
MaxConnections: common.Int(36393),
Offline: common.Bool(true)}},
HealthChecker: &loadbalancer.HealthCheckerDetails{Retries: common.Int(706),
ReturnCode: common.Int(300),
TimeoutInMillis: common.Int(251591),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
DefaultWeight: common.Int(77),
IntervalInMillis: common.Int(1.097299e+06),
IsDynamicBackendWeightEnabled: common.Bool(false),
Protocol: common.String("EXAMPLE-protocol-Value"),
IsForcePlainText: common.Bool(true),
Port: common.Int(4327),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value")},
LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(true),
Domain: common.String("EXAMPLE-domain-Value"),
IsHttpOnly: common.Bool(false),
IsSecure: common.Bool(false),
MaxAgeInSeconds: common.Int(149),
Path: common.String("EXAMPLE-path-Value")},
Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(true)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
Protocols: []string{"EXAMPLE--Value"},
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(613),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(true),
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled,
VerifyPeerCertificate: common.Bool(true)}}},
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_Zygi9": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
IsDeleteProtectionEnabled: common.Bool(true),
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_TfrpS": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypeForceLongestPrefixMatch},
BackendSetName: common.String("EXAMPLE-backendSetName-Value"),
Path: common.String("EXAMPLE-path-Value")}}}},
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(5719),
MinimumBandwidthInMbps: common.Int(2278)},
SubnetIds: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_uvtda": map[string]interface{}{"EXAMPLE_KEY_Fk02I": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_34RIj": "EXAMPLE_VALUE_bgbAt9y0r0ti6OoDA9ZM"},
IsPrivate: common.Bool(false),
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_r2rS4": loadbalancer.ListenerDetails{Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
SslConfiguration: &loadbalancer.SslConfigurationDetails{CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
Protocols: []string{"EXAMPLE--Value"},
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled,
CertificateIds: []string{"EXAMPLE--Value"},
HasSessionResumption: common.Bool(false),
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(897),
VerifyPeerCertificate: common.Bool(true),
CertificateName: common.String("EXAMPLE-certificateName-Value")},
HostnameNames: []string{"EXAMPLE--Value"},
Port: common.Int(22031),
RuleSetNames: []string{"EXAMPLE--Value"},
ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(523)},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value")}},
RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_PhGNz": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.IpBasedMaxConnectionsRule{DefaultMaxConnections: common.Int(11139),
IpMaxConnections: []loadbalancer.IpMaxConnections{loadbalancer.IpMaxConnections{IpAddresses: []string{"EXAMPLE--Value"},
MaxConnections: common.Int(44960)}}}}}},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_3TcYP": map[string]interface{}{"EXAMPLE_KEY_ha4oH": "EXAMPLE--Value"}},
ShapeName: common.String("EXAMPLE-shapeName-Value"),
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_jCk2W": loadbalancer.CertificateDetails{CertificateName: common.String("EXAMPLE-certificateName-Value"),
Passphrase: common.String("EXAMPLE-passphrase-Value"),
PrivateKey: common.String("EXAMPLE-privateKey-Value"),
PublicCertificate: common.String("EXAMPLE-publicCertificate-Value"),
CaCertificate: common.String("EXAMPLE-caCertificate-Value")}},
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
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"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
IsRequestIdEnabled: common.Bool(true),
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value"),
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_1rMdh": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}}},
OpcRequestId: common.String("3TB7DD0OPABKNKYAP1CR<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)
}