// 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{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		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_6Lwzh": map[string]interface{}{"EXAMPLE_KEY_nJ3Wb": "EXAMPLE--Value"}},
			DisplayName:   common.String("EXAMPLE-displayName-Value"),
			FreeformTags:  map[string]string{"EXAMPLE_KEY_oNk7G": "EXAMPLE_VALUE_vGhQ2BybDwTMTwf6geWd"},
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_sMMvk": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(1041)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_zO7Zi": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(37729),
				HttpsPort: common.Int(28561),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_L5s0N": "EXAMPLE_VALUE_VCt71a4CjSRwIDZJprw3"},
				HealthyThreshold:           common.Int(16),
				IsEnabled:                  common.Bool(false),
				IntervalInSeconds:          common.Int(3),
				IsResponseTextCheckEnabled: common.Bool(false),
				Method:                     waas.HealthCheckMethodPost,
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(63),
				UnhealthyThreshold:         common.Int(14)},
				IsHttpsEnabled:             common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(false),
				IsResponseBufferingEnabled: common.Bool(true),
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				IsBehindCdn:                common.Bool(true),
				IsCacheControlRespected:    common.Bool(true),
				IsHttpsForced:              common.Bool(false),
				IsSniEnabled:               common.Bool(true),
				LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
				CipherGroup:                waas.PolicyConfigCipherGroupDefault,
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXClientIp},
			Domain: common.String("EXAMPLE-domain-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(98650)}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgsNames}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{IsNatEnabled: common.Bool(true),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                    waas.HumanInteractionChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(368204),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(508),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						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")},
					FailureThreshold:                    common.Int(671139),
					IsEnabled:                           common.Bool(false),
					RecordingPeriodInSeconds:            common.Int(3779),
					FailureThresholdExpirationInSeconds: common.Int(258245),
					InteractionThreshold:                common.Int(67)},
				Origin:       common.String("EXAMPLE-origin-Value"),
				OriginGroups: []string{"EXAMPLE--Value"},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(370115),
					Action:                    waas.DeviceFingerprintChallengeActionBlock,
					ActionExpirationInSeconds: common.Int(71155),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockResponseCode:         common.Int(359),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
					FailureThreshold:                    common.Int(37302),
					FailureThresholdExpirationInSeconds: common.Int(282638),
					IsEnabled:                           common.Bool(true),
					MaxAddressCount:                     common.Int(5988)},
				JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIs,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
					SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
						Name: common.String("EXAMPLE-name-Value")},
					Action: waas.JsChallengeActionBlock,
					ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(661),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
					FailureThreshold:          common.Int(480718),
					IsEnabled:                 common.Bool(false),
					IsNatEnabled:              common.Bool(false),
					ActionExpirationInSeconds: common.Int(369884),
					AreRedirectsChallenged:    common.Bool(true)},
				ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:             common.Int(345),
					IsResponseInspected:           common.Bool(true),
					MediaTypes:                    []string{"EXAMPLE--Value"},
					RecommendationsPeriodInDays:   common.Int(94),
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					MaxArgumentCount:              common.Int(5399),
					MaxNameLengthPerArgument:      common.Int(43270),
					MaxResponseSizeInKiB:          common.Int(1386),
					MaxTotalNameLengthOfArguments: common.Int(84714),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
					BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value")},
				Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
					AddressLists: []string{"EXAMPLE--Value"},
					Addresses:    []string{"EXAMPLE--Value"}}},
				AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
					RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					BlockAction:                waas.AccessRuleBlockActionSetResponseCode,
					BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
						IsCaseSensitive: common.Bool(true),
						Value:           common.String("EXAMPLE-value-Value")}},
					RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
					Action:               waas.AccessRuleActionDetect,
					BlockResponseCode:    common.Int(650),
					Name:                 common.String("EXAMPLE-name-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(516),
					BlockResponseCode:         common.Int(144),
					IsEnabled:                 common.Bool(false),
					MaxDelayedCountPerAddress: common.Int(3843)},
				CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionBypassCache,
					CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
					ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
					Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
						Condition: waas.CachingRuleCriteriaConditionStartsWith}},
					IsClientCachingEnabled: common.Bool(false),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-Value")}}}},
		OpcRequestId: common.String("V10HRVUBNVWNSNGZPDFF<unique_ID>")}

	// 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)
}