// 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{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		FreeformTags: map[string]string{"EXAMPLE_KEY_Ui7sM": "EXAMPLE_VALUE_GsMISwgm7OKCsVhTu3uZ"},
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_nBj3V": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
			Weight: common.Int(9416)}}}},
		PolicyConfig: &waas.PolicyConfig{LoadBalancingMethod: waas.RoundRobinLoadBalancingMethod{},
			TlsProtocols:        []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
			CertificateId:       common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			ClientAddressHeader: waas.PolicyConfigClientAddressHeaderTrueClientIp,
			HealthChecks: &waas.HealthCheck{IntervalInSeconds: common.Int(112),
				Path:                       common.String("EXAMPLE-path-Value"),
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_gFRZX": "EXAMPLE_VALUE_0ECDEBAqHWynLVvy7o5M"},
				IsEnabled:                  common.Bool(true),
				IsResponseTextCheckEnabled: common.Bool(true),
				Method:                     waas.HealthCheckMethodPost,
				TimeoutInSeconds:           common.Int(94),
				UnhealthyThreshold:         common.Int(17),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
				HealthyThreshold:           common.Int(9)},
			IsCacheControlRespected:    common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(true),
			WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
			CipherGroup:                waas.PolicyConfigCipherGroupDefault,
			IsBehindCdn:                common.Bool(true),
			IsHttpsEnabled:             common.Bool(true),
			IsHttpsForced:              common.Bool(true),
			IsResponseBufferingEnabled: common.Bool(true),
			IsSniEnabled:               common.Bool(false)},
		WafConfig: &waas.WafConfigDetails{OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{IsResponseInspected: common.Bool(true),
				MaxArgumentCount:              common.Int(8137),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				RecommendationsPeriodInDays:   common.Int(53),
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsOptions},
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:             common.Int(147),
				MaxNameLengthPerArgument:      common.Int(110317),
				MaxResponseSizeInKiB:          common.Int(165),
				MaxTotalNameLengthOfArguments: common.Int(91611),
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value")},
			AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(5913),
				BlockResponseCode:         common.Int(254),
				IsEnabled:                 common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(2770)},
			Captchas: []waas.Captcha{waas.Captcha{HeaderText: common.String("EXAMPLE-headerText-Value"),
				SessionExpirationInSeconds: common.Int(389957),
				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")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
				Action: waas.CustomProtectionRuleSettingActionDetect,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}}}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(500045),
				FailureThresholdExpirationInSeconds: common.Int(340179),
				IsEnabled:                           common.Bool(true),
				MaxAddressCount:                     common.Int(845),
				MaxAddressCountExpirationInSeconds:  common.Int(240612),
				Action:                              waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:           common.Int(420785),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(907),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage}},
			JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
				AreRedirectsChallenged: common.Bool(true),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(616),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlRegex,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold:          common.Int(631771),
				IsNatEnabled:              common.Bool(true),
				ActionExpirationInSeconds: common.Int(319911),
				IsEnabled:                 common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AccessRules: []waas.AccessRule{waas.AccessRule{ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockResponseCode:         common.Int(513),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				BlockAction:               waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpMethodIs,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				Action:                waas.AccessRuleActionBlock,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				Name:                  common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeMovedPermanently}},
			CachingRules: []waas.CachingRule{waas.CachingRule{Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartEndsWith,
				Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(true),
				Key:                    common.String("EXAMPLE-key-Value"),
				Name:                   common.String("EXAMPLE-name-Value"),
				Action:                 waas.CachingRuleActionCache,
				CachingDuration:        common.String("EXAMPLE-cachingDuration-Value"),
				ClientCachingDuration:  common.String("EXAMPLE-clientCachingDuration-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(300),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
				FailureThreshold:         common.Int(980211),
				IsEnabled:                common.Bool(false),
				RecordingPeriodInSeconds: common.Int(3581),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds:           common.Int(207306),
				FailureThresholdExpirationInSeconds: common.Int(430642),
				InteractionThreshold:                common.Int(85),
				IsNatEnabled:                        common.Bool(false)},
			Origin: common.String("EXAMPLE-origin-Value")},
		AdditionalDomains: []string{"EXAMPLE--Value"},
		DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_GQwzB": map[string]interface{}{"EXAMPLE_KEY_BqGvB": "EXAMPLE--Value"}},
		DisplayName:       common.String("EXAMPLE-displayName-Value"),
		Domain:            common.String("EXAMPLE-domain-Value"),
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_gEaLs": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
			Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(16469),
			HttpsPort: common.Int(17968),
			Uri:       common.String("EXAMPLE-uri-Value")}}},
		OpcRequestId:  common.String("CLZ86VUI97JKFSODQEVR<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)
}