// 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{RuleSets: map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_UAdl5": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.AddHttpRequestHeaderRule{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}}}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_CGxuP": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
Name: common.String("EXAMPLE-name-Value")}},
IpMode: loadbalancer.CreateLoadBalancerDetailsIpModeIpv4,
Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_eHP9f": loadbalancer.ListenerDetails{Port: common.Int(35004),
Protocol: common.String("EXAMPLE-protocol-Value"),
RoutingPolicyName: common.String("EXAMPLE-routingPolicyName-Value"),
RuleSetNames: []string{"EXAMPLE--Value"},
SslConfiguration: &loadbalancer.SslConfigurationDetails{ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
VerifyPeerCertificate: common.Bool(true),
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(304),
CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(false),
Protocols: []string{"EXAMPLE--Value"}},
DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
BackendTcpProxyProtocolVersion: common.Int(1),
IdleTimeout: common.Int64(349)},
HostnameNames: []string{"EXAMPLE--Value"}}},
ReservedIps: []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_WzxAs": map[string]interface{}{"EXAMPLE_KEY_fo6nI": "EXAMPLE--Value"}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_Uo88Q": map[string]interface{}{"EXAMPLE_KEY_MuqjH": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_UnIca": "EXAMPLE_VALUE_2kFwKzjhOOHBadmYwHrg"},
IsPrivate: common.Bool(false),
ShapeName: common.String("EXAMPLE-shapeName-Value"),
SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_IgD7U": loadbalancer.SslCipherSuiteDetails{Ciphers: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
SubnetIds: []string{"EXAMPLE--Value"},
Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_9tmE6": 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")}},
IsDeleteProtectionEnabled: common.Bool(false),
NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(3319),
MinimumBandwidthInMbps: common.Int(1682)},
BackendSets: map[string]loadbalancer.BackendSetDetails{"EXAMPLE_KEY_34diC": loadbalancer.BackendSetDetails{Policy: common.String("EXAMPLE-policy-Value"),
SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
DisableFallback: common.Bool(false)},
SslConfiguration: &loadbalancer.SslConfigurationDetails{CipherSuiteName: common.String("EXAMPLE-cipherSuiteName-Value"),
HasSessionResumption: common.Bool(true),
ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
VerifyDepth: common.Int(378),
VerifyPeerCertificate: common.Bool(false),
CertificateIds: []string{"EXAMPLE--Value"},
CertificateName: common.String("EXAMPLE-certificateName-Value"),
Protocols: []string{"EXAMPLE--Value"}},
BackendMaxConnections: common.Int(1172),
Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{MaxConnections: common.Int(23634),
Offline: common.Bool(false),
Port: common.Int(43693),
Weight: common.Int(157),
Backup: common.Bool(false),
Drain: common.Bool(true),
IpAddress: common.String("EXAMPLE-ipAddress-Value")}},
HealthChecker: &loadbalancer.HealthCheckerDetails{ReturnCode: common.Int(633),
TimeoutInMillis: common.Int(364783),
UrlPath: common.String("EXAMPLE-urlPath-Value"),
IsForcePlainText: common.Bool(true),
Port: common.Int(56496),
Retries: common.Int(774),
IntervalInMillis: common.Int(968237),
Protocol: common.String("EXAMPLE-protocol-Value"),
ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value")},
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(false),
IsSecure: common.Bool(false),
MaxAgeInSeconds: common.Int(756)}}},
Ipv6SubnetCidr: common.String("EXAMPLE-ipv6SubnetCidr-Value"),
IsRequestIdEnabled: common.Bool(true),
PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_zbhjK": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{Path: common.String("EXAMPLE-path-Value"),
PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypeSuffixMatch},
BackendSetName: common.String("EXAMPLE-backendSetName-Value")}}}},
RequestIdHeader: common.String("EXAMPLE-requestIdHeader-Value")},
OpcRequestId: common.String("OQA8FUMPIKNF6EYKTQOH<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)
}