// 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"},
		DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_A5MEr": map[string]interface{}{"EXAMPLE_KEY_Fzk8k": "EXAMPLE--Value"}},
		DisplayName: common.String("EXAMPLE-displayName-Value"),
		Domain:      common.String("EXAMPLE-domain-Value"),
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_va85Q": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
			Weight: common.Int(1396)}}}},
		PolicyConfig: &waas.PolicyConfig{TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV11},
			WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
			CertificateId:         common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			HealthChecks: &waas.HealthCheck{Path: common.String("EXAMPLE-path-Value"),
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_Grecx": "EXAMPLE_VALUE_mgX96J8PakN95BD8TdWC"},
				IntervalInSeconds:          common.Int(90),
				IsEnabled:                  common.Bool(false),
				Method:                     waas.HealthCheckMethodGet,
				TimeoutInSeconds:           common.Int(91),
				UnhealthyThreshold:         common.Int(14),
				ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
				HealthyThreshold:           common.Int(4),
				IsResponseTextCheckEnabled: common.Bool(false)},
			IsBehindCdn:                common.Bool(false),
			IsHttpsEnabled:             common.Bool(false),
			IsHttpsForced:              common.Bool(false),
			LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
			CipherGroup:                waas.PolicyConfigCipherGroupDefault,
			ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXClientIp,
			IsCacheControlRespected:    common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(false),
			IsResponseBufferingEnabled: common.Bool(false),
			IsSniEnabled:               common.Bool(false)},
		WafConfig: &waas.WafConfigDetails{AccessRules: []waas.AccessRule{waas.AccessRule{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotEndWith,
			IsCaseSensitive: common.Bool(true),
			Value:           common.String("EXAMPLE-value-Value")}},
			RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeMovedPermanently,
			Action:                     waas.AccessRuleActionDetect,
			Name:                       common.String("EXAMPLE-name-Value"),
			CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
			RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
			ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
			BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockResponseCode:          common.Int(728),
			BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
			CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
			CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
			BlockAction:                waas.AccessRuleBlockActionShowErrorPage,
			BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockErrorPageMessage:      common.String("EXAMPLE-blockErrorPageMessage-Value"),
			CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value")}},
			CachingRules: []waas.CachingRule{waas.CachingRule{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"),
				Action:                 waas.CachingRuleActionCache,
				CachingDuration:        common.String("EXAMPLE-cachingDuration-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(62402),
				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")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
				Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgs,
					Exclusions: []string{"EXAMPLE--Value"}}},
				Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
			JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(true),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(472),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-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"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value")},
				FailureThreshold: common.Int(503378),
				IsEnabled:        common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action:                    waas.JsChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(395266),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(true),
					Value:     common.String("EXAMPLE-value-Value"),
					Condition: waas.AccessRuleCriteriaConditionUserAgentIsNot}},
				IsNatEnabled: common.Bool(true)},
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{MaxArgumentCount: common.Int(8185),
				MaxNameLengthPerArgument:      common.Int(132762),
				MaxResponseSizeInKiB:          common.Int(452),
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				MaxTotalNameLengthOfArguments: common.Int(280459),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				RecommendationsPeriodInDays:   common.Int(63),
				BlockAction:                   waas.ProtectionSettingsBlockActionShowErrorPage,
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:             common.Int(865),
				IsResponseInspected:           common.Bool(true)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(774),
				IsEnabled:                 common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(8106),
				AllowedRatePerAddress:     common.Int(5996)},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(246314),
				FailureThresholdExpirationInSeconds: common.Int(196200),
				IsEnabled:                           common.Bool(false),
				MaxAddressCount:                     common.Int(566),
				MaxAddressCountExpirationInSeconds:  common.Int(407800),
				Action:                              waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:           common.Int(207706),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:         common.Int(455),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
				ActionExpirationInSeconds: common.Int(296179),
				FailureThreshold:          common.Int(877568),
				IsEnabled:                 common.Bool(false),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(126),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
				FailureThresholdExpirationInSeconds: common.Int(135763),
				InteractionThreshold:                common.Int(11),
				IsNatEnabled:                        common.Bool(false),
				RecordingPeriodInSeconds:            common.Int(176),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			Origin: common.String("EXAMPLE-origin-Value")},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		FreeformTags:  map[string]string{"EXAMPLE_KEY_BaE9F": "EXAMPLE_VALUE_fOVXbrUCeKD7HqIeKRhz"},
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_CQA9H": 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(16847),
			HttpsPort: common.Int(26814)}}},
		OpcRequestId:  common.String("KCQPBOZNAKRP5VDQNYUQ<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)
}