// 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/waas"
)

func ExampleCreateWaasPolicy() {
	// 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 := waas.NewWaasClientWithConfigurationProvider(common.DefaultConfigProvider())
	helpers.FatalIfError(err)

	// Create a request and dependent object(s).

	req := waas.CreateWaasPolicyRequest{CreateWaasPolicyDetails: waas.CreateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
		DisplayName: common.String("EXAMPLE-displayName-Value"),
		Domain:      common.String("EXAMPLE-domain-Value"),
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_0fhci": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
			Weight: common.Int(1738)}}}},
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_U1BJy": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
			Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(22176),
			HttpsPort: common.Int(1799),
			Uri:       common.String("EXAMPLE-uri-Value")}},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_bmmht": map[string]interface{}{"EXAMPLE_KEY_3PFCq": "EXAMPLE--Value"}},
		FreeformTags:  map[string]string{"EXAMPLE_KEY_B4lt5": "EXAMPLE_VALUE_BUSCbuDIt5iCbIYS0ccm"},
		PolicyConfig: &waas.PolicyConfig{CipherGroup: waas.PolicyConfigCipherGroupDefault,
			ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
			HealthChecks: &waas.HealthCheck{Method: waas.HealthCheckMethodHead,
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(89),
				UnhealthyThreshold:         common.Int(4),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				HealthyThreshold:           common.Int(7),
				IntervalInSeconds:          common.Int(74),
				IsEnabled:                  common.Bool(false),
				Headers:                    map[string]string{"EXAMPLE_KEY_wXa0A": "EXAMPLE_VALUE_a8sJAMRVnrtSHuTXQZ3g"},
				IsResponseTextCheckEnabled: common.Bool(true)},
			IsHttpsForced:              common.Bool(false),
			IsOriginCompressionEnabled: common.Bool(false),
			IsResponseBufferingEnabled: common.Bool(true),
			IsSniEnabled:               common.Bool(false),
			CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			IsBehindCdn:                common.Bool(true),
			IsCacheControlRespected:    common.Bool(false),
			IsHttpsEnabled:             common.Bool(true),
			LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
			TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
			WebsocketPathPrefixes:      []string{"EXAMPLE--Value"}},
		WafConfig: &waas.WafConfigDetails{Captchas: []waas.Captcha{waas.Captcha{SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
			Title:                      common.String("EXAMPLE-title-Value"),
			Url:                        common.String("EXAMPLE-url-Value"),
			FailureMessage:             common.String("EXAMPLE-failureMessage-Value"),
			FooterText:                 common.String("EXAMPLE-footerText-Value"),
			HeaderText:                 common.String("EXAMPLE-headerText-Value"),
			SessionExpirationInSeconds: common.Int(101996)}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{IsEnabled: common.Bool(true),
				MaxAddressCount:                    common.Int(6027),
				MaxAddressCountExpirationInSeconds: common.Int(410291),
				Action:                             waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:          common.Int(100659),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					BlockResponseCode:         common.Int(334),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage},
				FailureThreshold:                    common.Int(262559),
				FailureThresholdExpirationInSeconds: common.Int(347683)},
			JsChallenge: &waas.JsChallenge{IsNatEnabled: common.Bool(true),
				ActionExpirationInSeconds: common.Int(12466),
				AreRedirectsChallenged:    common.Bool(false),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action: waas.JsChallengeActionBlock,
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(284),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value")},
				FailureThreshold: common.Int(223394),
				IsEnabled:        common.Bool(true)},
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete},
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:             common.Int(519),
				MaxArgumentCount:              common.Int(639),
				MaxNameLengthPerArgument:      common.Int(29118),
				MaxTotalNameLengthOfArguments: common.Int(47802),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				IsResponseInspected:           common.Bool(true),
				MaxResponseSizeInKiB:          common.Int(760),
				RecommendationsPeriodInDays:   common.Int(31)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AccessRules: []waas.AccessRule{waas.AccessRule{BlockAction: waas.AccessRuleBlockActionSetResponseCode,
				BlockResponseCode:         common.Int(506),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeFound,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
				Name:                      common.String("EXAMPLE-name-Value"),
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				RedirectUrl:   common.String("EXAMPLE-redirectUrl-Value"),
				Action:        waas.AccessRuleActionAllow,
				CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}}}},
			AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6206),
				BlockResponseCode:         common.Int(676),
				IsEnabled:                 common.Bool(true),
				MaxDelayedCountPerAddress: common.Int(5775)},
			CachingRules: []waas.CachingRule{waas.CachingRule{IsClientCachingEnabled: common.Bool(true),
				Key:                   common.String("EXAMPLE-key-Value"),
				Name:                  common.String("EXAMPLE-name-Value"),
				Action:                waas.CachingRuleActionBypassCache,
				CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
				ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionIs,
					Value: common.String("EXAMPLE-value-Value")}}}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(379),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
				FailureThreshold:                    common.Int(514413),
				FailureThresholdExpirationInSeconds: common.Int(45115),
				InteractionThreshold:                common.Int(46),
				IsEnabled:                           common.Bool(false),
				IsNatEnabled:                        common.Bool(true),
				ActionExpirationInSeconds:           common.Int(279680),
				RecordingPeriodInSeconds:            common.Int(6674),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			Origin: common.String("EXAMPLE-origin-Value")}},
		OpcRequestId:  common.String("UR3JEALPIV8P4SDLBPKC<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value")}

	// Send the request using the service client
	resp, err := client.CreateWaasPolicy(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}