// 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{Origins: map[string]waas.Origin{"EXAMPLE_KEY_1xc9F": waas.Origin{HttpsPort: common.Int(45529),
		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(61397)}},
		PolicyConfig: &waas.PolicyConfig{IsCacheControlRespected: common.Bool(false),
			IsOriginCompressionEnabled: common.Bool(false),
			IsSniEnabled:               common.Bool(false),
			WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
			CipherGroup:                waas.PolicyConfigCipherGroupDefault,
			HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
				Headers:                    map[string]string{"EXAMPLE_KEY_CbIYS": "EXAMPLE_VALUE_0ccm3PFCqbmmhtur3jea"},
				HealthyThreshold:           common.Int(4),
				IsResponseTextCheckEnabled: common.Bool(true),
				Method:                     waas.HealthCheckMethodPost,
				TimeoutInSeconds:           common.Int(88),
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				IntervalInSeconds:          common.Int(2),
				IsEnabled:                  common.Bool(true),
				Path:                       common.String("EXAMPLE-path-Value"),
				UnhealthyThreshold:         common.Int(10)},
			IsBehindCdn:                common.Bool(false),
			IsHttpsEnabled:             common.Bool(false),
			IsHttpsForced:              common.Bool(true),
			IsResponseBufferingEnabled: common.Bool(false),
			LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
			TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
			CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderClientIp},
		WafConfig: &waas.WafConfigDetails{ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
			BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
			IsResponseInspected:           common.Bool(true),
			MaxTotalNameLengthOfArguments: common.Int(213610),
			MediaTypes:                    []string{"EXAMPLE--Value"},
			RecommendationsPeriodInDays:   common.Int(93),
			BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockResponseCode:             common.Int(319),
			MaxArgumentCount:              common.Int(6735),
			MaxNameLengthPerArgument:      common.Int(143624),
			MaxResponseSizeInKiB:          common.Int(1115),
			AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet}},
			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.AccessRuleActionDetect,
				BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockResponseCode:     common.Int(699),
				Name:                  common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:  waas.AccessRuleRedirectResponseCodeMovedPermanently,
				BlockAction:           waas.AccessRuleBlockActionShowErrorPage,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BypassChallenges:      []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
				CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
					Condition:       waas.AccessRuleCriteriaConditionUrlPartEndsWith,
					IsCaseSensitive: common.Bool(true)}},
				RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")}},
			AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(7314),
				AllowedRatePerAddress:     common.Int(6487),
				BlockResponseCode:         common.Int(467)},
			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")}},
			Origin: common.String("EXAMPLE-origin-Value"),
			CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionCache,
				CachingDuration:       common.String("EXAMPLE-cachingDuration-Value"),
				ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionIs,
					Value: common.String("EXAMPLE-value-Value")}},
				IsClientCachingEnabled: common.Bool(true),
				Key:                    common.String("EXAMPLE-key-Value"),
				Name:                   common.String("EXAMPLE-name-Value")}},
			Captchas: []waas.Captcha{waas.Captcha{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(228489),
				SubmitLabel:                common.String("EXAMPLE-submitLabel-Value")}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(290437),
				FailureThresholdExpirationInSeconds: common.Int(301116),
				IsEnabled:                           common.Bool(true),
				MaxAddressCount:                     common.Int(9694),
				MaxAddressCountExpirationInSeconds:  common.Int(274757),
				Action:                              waas.DeviceFingerprintChallengeActionDetect,
				ActionExpirationInSeconds:           common.Int(423082),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(215),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
				ActionExpirationInSeconds: common.Int(201294),
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:         common.Int(905),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value")},
				FailureThresholdExpirationInSeconds: common.Int(158048),
				InteractionThreshold:                common.Int(75),
				FailureThreshold:                    common.Int(592388),
				IsEnabled:                           common.Bool(false),
				IsNatEnabled:                        common.Bool(false),
				RecordingPeriodInSeconds:            common.Int(9884),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")}},
			JsChallenge: &waas.JsChallenge{SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")},
				Action: waas.JsChallengeActionDetect,
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(915),
					CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value")},
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartContains,
					IsCaseSensitive: common.Bool(true),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold:          common.Int(439566),
				ActionExpirationInSeconds: common.Int(245427),
				AreRedirectsChallenged:    common.Bool(true),
				IsEnabled:                 common.Bool(true),
				IsNatEnabled:              common.Bool(false)},
			OriginGroups: []string{"EXAMPLE--Value"}},
		AdditionalDomains: []string{"EXAMPLE--Value"},
		CompartmentId:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DisplayName:       common.String("EXAMPLE-displayName-Value"),
		DefinedTags:       map[string]map[string]interface{}{"EXAMPLE_KEY_4fIlJ": map[string]interface{}{"EXAMPLE_KEY_cELCY": "EXAMPLE--Value"}},
		Domain:            common.String("EXAMPLE-domain-Value"),
		FreeformTags:      map[string]string{"EXAMPLE_KEY_f4PPu": "EXAMPLE_VALUE_f4t7fbJF0W34W6C8MUKG"},
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_jq6x2": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
			Weight: common.Int(3748)}}}}},
		OpcRequestId:  common.String("C7SHO5MR3G6BQJWAIA2A<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)
}