// 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_XCZGF": loadbalancer.BackendSetDetails{Policy: common.String("EXAMPLE-policy-Value"),
		SessionPersistenceConfiguration: &loadbalancer.SessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
			DisableFallback: common.Bool(true)},
		SslConfiguration: &loadbalancer.SslConfigurationDetails{TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
			CertificateName:       common.String("EXAMPLE-certificateName-Value"),
			CipherSuiteName:       common.String("EXAMPLE-cipherSuiteName-Value"),
			HasSessionResumption:  common.Bool(false),
			Protocols:             []string{"EXAMPLE--Value"},
			CertificateIds:        []string{"EXAMPLE--Value"},
			ServerOrderPreference: loadbalancer.SslConfigurationDetailsServerOrderPreferenceEnabled,
			VerifyDepth:           common.Int(565),
			VerifyPeerCertificate: common.Bool(false)},
		BackendMaxConnections: common.Int(63013),
		Backends: []loadbalancer.BackendDetails{loadbalancer.BackendDetails{Port: common.Int(5058),
			Weight:         common.Int(376),
			Backup:         common.Bool(false),
			Drain:          common.Bool(true),
			IpAddress:      common.String("EXAMPLE-ipAddress-Value"),
			MaxConnections: common.Int(31495),
			Offline:        common.Bool(false)}},
		HealthChecker: &loadbalancer.HealthCheckerDetails{IntervalInMillis: common.Int(660640),
			Port:              common.Int(14964),
			Retries:           common.Int(393),
			ReturnCode:        common.Int(81),
			TimeoutInMillis:   common.Int(134282),
			IsForcePlainText:  common.Bool(false),
			Protocol:          common.String("EXAMPLE-protocol-Value"),
			ResponseBodyRegex: common.String("EXAMPLE-responseBodyRegex-Value"),
			UrlPath:           common.String("EXAMPLE-urlPath-Value")},
		LbCookieSessionPersistenceConfiguration: &loadbalancer.LbCookieSessionPersistenceConfigurationDetails{CookieName: common.String("EXAMPLE-cookieName-Value"),
			DisableFallback: common.Bool(false),
			Domain:          common.String("EXAMPLE-domain-Value"),
			IsHttpOnly:      common.Bool(true),
			IsSecure:        common.Bool(false),
			MaxAgeInSeconds: common.Int(531),
			Path:            common.String("EXAMPLE-path-Value")}}},
		DisplayName: common.String("EXAMPLE-displayName-Value"),
		IpMode:      loadbalancer.CreateLoadBalancerDetailsIpModeIpv6,
		Listeners: map[string]loadbalancer.ListenerDetails{"EXAMPLE_KEY_kWGDM": loadbalancer.ListenerDetails{ConnectionConfiguration: &loadbalancer.ConnectionConfiguration{BackendTcpProxyProtocolOptions: []loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum{loadbalancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsPp2TypeAuthority},
			BackendTcpProxyProtocolVersion: common.Int(1),
			IdleTimeout:                    common.Int64(548)},
			PathRouteSetName: common.String("EXAMPLE-pathRouteSetName-Value"),
			Port:             common.Int(34483),
			RuleSetNames:     []string{"EXAMPLE--Value"},
			SslConfiguration: &loadbalancer.SslConfigurationDetails{Protocols: []string{"EXAMPLE--Value"},
				TrustedCertificateAuthorityIds: []string{"EXAMPLE--Value"},
				VerifyDepth:                    common.Int(541),
				VerifyPeerCertificate:          common.Bool(true),
				CertificateIds:                 []string{"EXAMPLE--Value"},
				CertificateName:                common.String("EXAMPLE-certificateName-Value"),
				CipherSuiteName:                common.String("EXAMPLE-cipherSuiteName-Value"),
				HasSessionResumption:           common.Bool(false),
				ServerOrderPreference:          loadbalancer.SslConfigurationDetailsServerOrderPreferenceDisabled},
			DefaultBackendSetName: common.String("EXAMPLE-defaultBackendSetName-Value"),
			HostnameNames:         []string{"EXAMPLE--Value"},
			Protocol:              common.String("EXAMPLE-protocol-Value"),
			RoutingPolicyName:     common.String("EXAMPLE-routingPolicyName-Value")}},
		IsRequestIdEnabled: common.Bool(false),
		ShapeName:          common.String("EXAMPLE-shapeName-Value"),
		Certificates: map[string]loadbalancer.CertificateDetails{"EXAMPLE_KEY_wJXgo": 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")}},
		DefinedTags:             map[string]map[string]interface{}{"EXAMPLE_KEY_AgwTk": map[string]interface{}{"EXAMPLE_KEY_8WCcr": "EXAMPLE--Value"}},
		FreeformTags:            map[string]string{"EXAMPLE_KEY_I5Xhv": "EXAMPLE_VALUE_1nPXjPnQBiAUrQGzGm54"},
		IsPrivate:               common.Bool(true),
		NetworkSecurityGroupIds: []string{"EXAMPLE--Value"},
		PathRouteSets: map[string]loadbalancer.PathRouteSetDetails{"EXAMPLE_KEY_h6FM9": loadbalancer.PathRouteSetDetails{PathRoutes: []loadbalancer.PathRoute{loadbalancer.PathRoute{BackendSetName: common.String("EXAMPLE-backendSetName-Value"),
			Path:          common.String("EXAMPLE-path-Value"),
			PathMatchType: &loadbalancer.PathMatchType{MatchType: loadbalancer.PathMatchTypeMatchTypePrefixMatch}}}}},
		RequestIdHeader:    common.String("EXAMPLE-requestIdHeader-Value"),
		RuleSets:           map[string]loadbalancer.RuleSetDetails{"EXAMPLE_KEY_NG9Av": loadbalancer.RuleSetDetails{Items: []loadbalancer.Rule{loadbalancer.RemoveHttpRequestHeaderRule{Header: common.String("EXAMPLE-header-Value")}}}},
		SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_osYMz": map[string]interface{}{"EXAMPLE_KEY_1bKOo": "EXAMPLE--Value"}},
		SslCipherSuites: map[string]loadbalancer.SslCipherSuiteDetails{"EXAMPLE_KEY_NBg5z": loadbalancer.SslCipherSuiteDetails{Name: common.String("EXAMPLE-name-Value"),
			Ciphers: []string{"EXAMPLE--Value"}}},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		Hostnames: map[string]loadbalancer.HostnameDetails{"EXAMPLE_KEY_EtMKy": loadbalancer.HostnameDetails{Hostname: common.String("EXAMPLE-hostname-Value"),
			Name: common.String("EXAMPLE-name-Value")}},
		Ipv6SubnetCidr:            common.String("EXAMPLE-ipv6SubnetCidr-Value"),
		IsDeleteProtectionEnabled: common.Bool(true),
		ReservedIps:               []loadbalancer.ReservedIp{loadbalancer.ReservedIp{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
		ShapeDetails: &loadbalancer.ShapeDetails{MaximumBandwidthInMbps: common.Int(7192),
			MinimumBandwidthInMbps: common.Int(594)},
		SubnetIds: []string{"EXAMPLE--Value"}},
		OpcRequestId:  common.String("Q2THCPDXKHPF3NM04EDZ<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)
}