// 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"},
			DefinedTags:  map[string]map[string]interface{}{"EXAMPLE_KEY_B3NbQ": map[string]interface{}{"EXAMPLE_KEY_UDjHK": "EXAMPLE--Value"}},
			Domain:       common.String("EXAMPLE-domain-Value"),
			FreeformTags: map[string]string{"EXAMPLE_KEY_pUTjg": "EXAMPLE_VALUE_kIHbcxGxoYjvMJLScehh"},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_WGZqi": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(38563),
				HttpsPort: common.Int(9631),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			PolicyConfig: &waas.PolicyConfig{IsBehindCdn: common.Bool(false),
				IsCacheControlRespected:    common.Bool(false),
				IsHttpsForced:              common.Bool(false),
				IsSniEnabled:               common.Bool(true),
				TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
				CipherGroup:                waas.PolicyConfigCipherGroupDefault,
				IsHttpsEnabled:             common.Bool(true),
				IsOriginCompressionEnabled: common.Bool(false),
				IsResponseBufferingEnabled: common.Bool(false),
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXClientIp,
				HealthChecks: &waas.HealthCheck{UnhealthyThreshold: common.Int(18),
					Headers:                    map[string]string{"EXAMPLE_KEY_ybDwT": "EXAMPLE_VALUE_MTwf6geWdnJ3Wb6Lwzhv"},
					Method:                     waas.HealthCheckMethodHead,
					HealthyThreshold:           common.Int(7),
					IntervalInSeconds:          common.Int(24),
					IsEnabled:                  common.Bool(false),
					IsResponseTextCheckEnabled: common.Bool(false),
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(93),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value")},
				LoadBalancingMethod: waas.IpHashLoadBalancingMethod{}},
			WafConfig: &waas.WafConfigDetails{JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(44975),
				FailureThreshold: common.Int(748300),
				IsEnabled:        common.Bool(false),
				IsNatEnabled:     common.Bool(false),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                 waas.JsChallengeActionDetect,
				AreRedirectsChallenged: common.Bool(false),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:     common.Int(873),
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value")},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}}},
				ProtectionSettings: &waas.ProtectionSettings{RecommendationsPeriodInDays: common.Int(7),
					AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet},
					BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode,
					MaxArgumentCount:              common.Int(4998),
					BlockResponseCode:             common.Int(441),
					IsResponseInspected:           common.Bool(true),
					MaxNameLengthPerArgument:      common.Int(85178),
					MaxResponseSizeInKiB:          common.Int(182),
					MaxTotalNameLengthOfArguments: common.Int(299554),
					BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
					MediaTypes:                    []string{"EXAMPLE--Value"}},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(266),
					BlockResponseCode:         common.Int(545),
					IsEnabled:                 common.Bool(true),
					MaxDelayedCountPerAddress: common.Int(2388)},
				CachingRules: []waas.CachingRule{waas.CachingRule{IsClientCachingEnabled: common.Bool(false),
					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"),
					Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionStartsWith,
						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.ProtectionRuleExclusionTargetArgsNames}},
					Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(302),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
					FailureThreshold:                    common.Int(96389),
					FailureThresholdExpirationInSeconds: common.Int(161569),
					IsEnabled:                           common.Bool(false),
					MaxAddressCount:                     common.Int(3878),
					MaxAddressCountExpirationInSeconds:  common.Int(396131),
					Action:                              waas.DeviceFingerprintChallengeActionDetect,
					ActionExpirationInSeconds:           common.Int(307797)},
				OriginGroups: []string{"EXAMPLE--Value"},
				AccessRules: []waas.AccessRule{waas.AccessRule{Name: common.String("EXAMPLE-name-Value"),
					RedirectUrl:           common.String("EXAMPLE-redirectUrl-Value"),
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(true),
						Value:     common.String("EXAMPLE-value-Value"),
						Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotContain}},
					BlockAction:                waas.AccessRuleBlockActionSetResponseCode,
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeMovedPermanently,
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					BlockResponseCode:          common.Int(609),
					Action:                     waas.AccessRuleActionBypass,
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value")}},
				Captchas: []waas.Captcha{waas.Captcha{HeaderText: common.String("EXAMPLE-headerText-Value"),
					SessionExpirationInSeconds: common.Int(140773),
					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")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{IsNatEnabled: common.Bool(false),
					RecordingPeriodInSeconds:  common.Int(12792),
					InteractionThreshold:      common.Int(47),
					ActionExpirationInSeconds: common.Int(171866),
					ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:     common.Int(180),
						CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
						BlockAction:           waas.BlockChallengeSettingsBlockActionShowErrorPage,
						CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value")},
					FailureThreshold:                    common.Int(651060),
					FailureThresholdExpirationInSeconds: common.Int(23583),
					IsEnabled:                           common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action: waas.HumanInteractionChallengeActionDetect},
				Origin: common.String("EXAMPLE-origin-Value")},
			CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
			DisplayName:   common.String("EXAMPLE-displayName-Value"),
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_UhUJy": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(715)}}}}},
		OpcRequestId: common.String("NA1IEIHPUE73BON3UOKR<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)
}