// 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"},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_6J8Pa": map[string]interface{}{"EXAMPLE_KEY_xmgX9": "EXAMPLE--Value"}},
		DisplayName:   common.String("EXAMPLE-displayName-Value"),
		Domain:        common.String("EXAMPLE-domain-Value"),
		FreeformTags:  map[string]string{"EXAMPLE_KEY_DUIOC": "EXAMPLE_VALUE_DKVyR9pyNYuflFUzGrec"},
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_FgYdB": waas.Origin{Uri: common.String("EXAMPLE-uri-Value"),
			CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(59281),
			HttpsPort: common.Int(35758)}},
		PolicyConfig: &waas.PolicyConfig{IsCacheControlRespected: common.Bool(false),
			IsHttpsEnabled:             common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(true),
			IsResponseBufferingEnabled: common.Bool(true),
			IsSniEnabled:               common.Bool(false),
			LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Domain: common.String("EXAMPLE-domain-Value"),
				ExpirationTimeInSeconds: common.Int(2.8733227e+07),
				Name:                    common.String("EXAMPLE-name-Value")},
			CertificateId:       common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXForwardedFor,
			HealthChecks: &waas.HealthCheck{IsEnabled: common.Bool(false),
				IsResponseTextCheckEnabled: common.Bool(false),
				Method:                     waas.HealthCheckMethodGet,
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(37),
				UnhealthyThreshold:         common.Int(19),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_0e7fu": "EXAMPLE_VALUE_g8TjwhLqYWjIOsuhjYii"},
				HealthyThreshold:           common.Int(6),
				IntervalInSeconds:          common.Int(93)},
			IsHttpsForced:         common.Bool(false),
			TlsProtocols:          []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
			WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
			CipherGroup:           waas.PolicyConfigCipherGroupDefault,
			IsBehindCdn:           common.Bool(true)},
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_rAmVt": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Weight: common.Int(9569),
			Origin: common.String("EXAMPLE-origin-Value")}}}},
		WafConfig: &waas.WafConfigDetails{AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
			MaxDelayedCountPerAddress: common.Int(3314),
			AllowedRatePerAddress:     common.Int(2402),
			BlockResponseCode:         common.Int(977)},
			CachingRules: []waas.CachingRule{waas.CachingRule{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartContains,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(false),
				Key:                    common.String("EXAMPLE-key-Value"),
				Name:                   common.String("EXAMPLE-name-Value"),
				Action:                 waas.CachingRuleActionBypassCache,
				CachingDuration:        common.String("EXAMPLE-cachingDuration-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(418876),
				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")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(668182),
				FailureThresholdExpirationInSeconds: common.Int(371669),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(9107),
				MaxAddressCountExpirationInSeconds:  common.Int(299640),
				Action:                              waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:           common.Int(144373),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:     common.Int(982),
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionSetResponseCode,
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{RecordingPeriodInSeconds: common.Int(10387),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(832),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
				FailureThreshold:                    common.Int(939093),
				FailureThresholdExpirationInSeconds: common.Int(186826),
				InteractionThreshold:                common.Int(95),
				IsEnabled:                           common.Bool(false),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.HumanInteractionChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(7298),
				IsNatEnabled:              common.Bool(true)},
			JsChallenge: &waas.JsChallenge{IsNatEnabled: common.Bool(true),
				Action:                 waas.JsChallengeActionDetect,
				AreRedirectsChallenged: common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds: common.Int(229623),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					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(935)},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartContains,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold: common.Int(165286),
				IsEnabled:        common.Bool(false)},
			Origin: common.String("EXAMPLE-origin-Value"),
			AccessRules: []waas.AccessRule{waas.AccessRule{RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartContains,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				Action:                    waas.AccessRuleActionAllow,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeMovedPermanently,
				BlockAction:               waas.AccessRuleBlockActionShowErrorPage,
				BlockResponseCode:         common.Int(654),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				Name:                      common.String("EXAMPLE-name-Value")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
					Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxNameLengthPerArgument:      common.Int(40769),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				RecommendationsPeriodInDays:   common.Int(45),
				BlockResponseCode:             common.Int(343),
				IsResponseInspected:           common.Bool(true),
				MaxArgumentCount:              common.Int(7020),
				MaxResponseSizeInKiB:          common.Int(101),
				MaxTotalNameLengthOfArguments: common.Int(285451),
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsHead},
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value")},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}}}},
		OpcRequestId:  common.String("KN95BD8TDWCWFLCRC8WL<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)
}