// 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"),
		DisplayName:  common.String("EXAMPLE-displayName-Value"),
		Domain:       common.String("EXAMPLE-domain-Value"),
		FreeformTags: map[string]string{"EXAMPLE_KEY_cGJeL": "EXAMPLE_VALUE_niGb5WejYHS0uTYOwie6"},
		PolicyConfig: &waas.PolicyConfig{ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
			IsBehindCdn:             common.Bool(false),
			IsCacheControlRespected: common.Bool(false),
			IsHttpsEnabled:          common.Bool(true),
			IsSniEnabled:            common.Bool(false),
			CipherGroup:             waas.PolicyConfigCipherGroupDefault,
			HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				Headers:                    map[string]string{"EXAMPLE_KEY_sWxq9": "EXAMPLE_VALUE_04QkeynNoKbTSPHjc5h3"},
				IsResponseTextCheckEnabled: common.Bool(false),
				HealthyThreshold:           common.Int(12),
				IntervalInSeconds:          common.Int(1),
				IsEnabled:                  common.Bool(true),
				Method:                     waas.HealthCheckMethodPost,
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(78),
				UnhealthyThreshold:         common.Int(16)},
			IsHttpsForced:              common.Bool(true),
			IsOriginCompressionEnabled: common.Bool(false),
			IsResponseBufferingEnabled: common.Bool(true),
			LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Name: common.String("EXAMPLE-name-Value"),
				Domain:                  common.String("EXAMPLE-domain-Value"),
				ExpirationTimeInSeconds: common.Int(8.772809e+06)},
			TlsProtocols:          []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
			WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
			CertificateId:         common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value")},
		WafConfig: &waas.WafConfigDetails{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{Condition: waas.CachingRuleCriteriaConditionStartsWith,
				Value: common.String("EXAMPLE-value-Value")}},
			IsClientCachingEnabled: common.Bool(false),
			Key:                    common.String("EXAMPLE-key-Value"),
			Name:                   common.String("EXAMPLE-name-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{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(315605),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
				Title:                      common.String("EXAMPLE-title-Value")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
				Id:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
				Action: waas.CustomProtectionRuleSettingActionDetect}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{RecordingPeriodInSeconds: common.Int(2693),
				Action:                              waas.HumanInteractionChallengeActionBlock,
				FailureThresholdExpirationInSeconds: common.Int(82296),
				InteractionThreshold:                common.Int(13),
				IsEnabled:                           common.Bool(true),
				IsNatEnabled:                        common.Bool(true),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ActionExpirationInSeconds: common.Int(367367),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockResponseCode:         common.Int(226),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
				FailureThreshold: common.Int(135808)},
			Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
				Addresses: []string{"EXAMPLE--Value"},
				Name:      common.String("EXAMPLE-name-Value")}},
			AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionAllow,
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				Name:                      common.String("EXAMPLE-name-Value"),
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeMovedPermanently,
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				BlockAction:               waas.AccessRuleBlockActionSetResponseCode,
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(235),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}}}},
			AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(3185),
				BlockResponseCode:         common.Int(434),
				IsEnabled:                 common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(1097)},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(189156),
				IsEnabled:                          common.Bool(true),
				MaxAddressCount:                    common.Int(6452),
				MaxAddressCountExpirationInSeconds: common.Int(194219),
				Action:                             waas.DeviceFingerprintChallengeActionBlock,
				ActionExpirationInSeconds:          common.Int(310299),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(720),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value")},
				FailureThreshold: common.Int(902226)},
			JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(324534),
				AreRedirectsChallenged: common.Bool(true),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIs,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold: common.Int(172531),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockResponseCode:         common.Int(656)},
				IsEnabled:    common.Bool(false),
				IsNatEnabled: common.Bool(false),
				Action:       waas.JsChallengeActionBlock},
			Origin:       common.String("EXAMPLE-origin-Value"),
			OriginGroups: []string{"EXAMPLE--Value"},
			ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:             common.Int(975),
				MaxNameLengthPerArgument:      common.Int(20613),
				MediaTypes:                    []string{"EXAMPLE--Value"},
				RecommendationsPeriodInDays:   common.Int(75),
				BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
				IsResponseInspected:           common.Bool(false),
				MaxArgumentCount:              common.Int(8550),
				MaxResponseSizeInKiB:          common.Int(773),
				MaxTotalNameLengthOfArguments: common.Int(31636),
				AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
				BlockAction:                   waas.ProtectionSettingsBlockActionSetResponseCode}},
		AdditionalDomains: []string{"EXAMPLE--Value"},
		DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_v5dYY": map[string]interface{}{"EXAMPLE_KEY_phnOM": "EXAMPLE--Value"}},
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_9CO4t": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
			Weight: common.Int(9766)}}}},
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_26rO3": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
			Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(13723),
			HttpsPort: common.Int(7656),
			Uri:       common.String("EXAMPLE-uri-Value")}}},
		OpcRequestId:  common.String("G8O0BDCMMIMATDFYGEAL<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)
}