// 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"},
		DisplayName: common.String("EXAMPLE-displayName-Value"),
		Domain:      common.String("EXAMPLE-domain-Value"),
		Origins: map[string]waas.Origin{"EXAMPLE_KEY_oYjvM": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
			Value: common.String("EXAMPLE-value-Value")}},
			HttpPort:  common.Int(30085),
			HttpsPort: common.Int(10628),
			Uri:       common.String("EXAMPLE-uri-Value")}},
		PolicyConfig: &waas.PolicyConfig{ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
			IsBehindCdn:                common.Bool(false),
			IsCacheControlRespected:    common.Bool(true),
			IsHttpsForced:              common.Bool(false),
			IsOriginCompressionEnabled: common.Bool(true),
			LoadBalancingMethod:        waas.RoundRobinLoadBalancingMethod{},
			CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
			CipherGroup:                waas.PolicyConfigCipherGroupDefault,
			HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
				Headers:                    map[string]string{"EXAMPLE_KEY_73Bon": "EXAMPLE_VALUE_3UOkr59ivsvb3krWzVdo"},
				IsResponseTextCheckEnabled: common.Bool(true),
				Path:                       common.String("EXAMPLE-path-Value"),
				TimeoutInSeconds:           common.Int(3),
				UnhealthyThreshold:         common.Int(7),
				ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
				HealthyThreshold:           common.Int(17),
				IntervalInSeconds:          common.Int(28),
				IsEnabled:                  common.Bool(false),
				Method:                     waas.HealthCheckMethodGet},
			IsHttpsEnabled:             common.Bool(false),
			IsResponseBufferingEnabled: common.Bool(true),
			IsSniEnabled:               common.Bool(false),
			TlsProtocols:               []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
			WebsocketPathPrefixes:      []string{"EXAMPLE--Value"}},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_ETyiT": map[string]interface{}{"EXAMPLE_KEY_RYfCo": "EXAMPLE--Value"}},
		FreeformTags:  map[string]string{"EXAMPLE_KEY_PYpzV": "EXAMPLE_VALUE_cJtzII3zcdiKfNeJsfa2"},
		OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_LSceh": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Weight: common.Int(8154),
			Origin: common.String("EXAMPLE-origin-Value")}}}},
		WafConfig: &waas.WafConfigDetails{ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
			MaxArgumentCount:              common.Int(9199),
			MaxNameLengthPerArgument:      common.Int(66172),
			MaxTotalNameLengthOfArguments: common.Int(106114),
			MediaTypes:                    []string{"EXAMPLE--Value"},
			AllowedHttpMethods:            []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
			BlockErrorPageCode:            common.String("EXAMPLE-blockErrorPageCode-Value"),
			BlockErrorPageDescription:     common.String("EXAMPLE-blockErrorPageDescription-Value"),
			BlockErrorPageMessage:         common.String("EXAMPLE-blockErrorPageMessage-Value"),
			BlockResponseCode:             common.Int(860),
			IsResponseInspected:           common.Bool(true),
			MaxResponseSizeInKiB:          common.Int(1904),
			RecommendationsPeriodInDays:   common.Int(74)},
			AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(7015),
				BlockResponseCode:         common.Int(205),
				IsEnabled:                 common.Bool(false),
				MaxDelayedCountPerAddress: common.Int(2840)},
			CachingRules: []waas.CachingRule{waas.CachingRule{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
				Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartEndsWith,
					Value: common.String("EXAMPLE-value-Value")}},
				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")}},
			CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
				Target: waas.ProtectionRuleExclusionTargetArgsNames}},
				Id:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
				Action: waas.CustomProtectionRuleSettingActionDetect}},
			HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThresholdExpirationInSeconds: common.Int(236941),
				InteractionThreshold:      common.Int(58),
				IsEnabled:                 common.Bool(true),
				IsNatEnabled:              common.Bool(false),
				RecordingPeriodInSeconds:  common.Int(8953),
				ActionExpirationInSeconds: common.Int(24291),
				FailureThreshold:          common.Int(790768),
				SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
					Value: common.String("EXAMPLE-value-Value")},
				Action: waas.HumanInteractionChallengeActionDetect,
				ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:               waas.BlockChallengeSettingsBlockActionShowCaptcha,
					BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:         common.Int(189)}},
			Origin: common.String("EXAMPLE-origin-Value"),
			Whitelists: []waas.Whitelist{waas.Whitelist{Addresses: []string{"EXAMPLE--Value"},
				Name:         common.String("EXAMPLE-name-Value"),
				AddressLists: []string{"EXAMPLE--Value"}}},
			AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
				BlockResponseCode:         common.Int(612),
				RedirectUrl:               common.String("EXAMPLE-redirectUrl-Value"),
				BypassChallenges:          []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
				Name:                      common.String("EXAMPLE-name-Value"),
				RedirectResponseCode:      waas.AccessRuleRedirectResponseCodeFound,
				CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIs,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				Action:                waas.AccessRuleActionDetect,
				BlockAction:           waas.AccessRuleBlockActionSetResponseCode,
				BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
				CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
				ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
					Value: common.String("EXAMPLE-value-Value")}}}},
			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(172447)}},
			DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(62415),
				ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:     common.Int(878),
					CaptchaFooter:         common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaSubmitLabel:    common.String("EXAMPLE-captchaSubmitLabel-Value"),
					CaptchaTitle:          common.String("EXAMPLE-captchaTitle-Value"),
					BlockAction:           waas.BlockChallengeSettingsBlockActionShowCaptcha,
					CaptchaHeader:         common.String("EXAMPLE-captchaHeader-Value"),
					BlockErrorPageCode:    common.String("EXAMPLE-blockErrorPageCode-Value")},
				FailureThreshold:                    common.Int(28161),
				FailureThresholdExpirationInSeconds: common.Int(239964),
				IsEnabled:                           common.Bool(true),
				MaxAddressCount:                     common.Int(6350),
				MaxAddressCountExpirationInSeconds:  common.Int(61491),
				Action:                              waas.DeviceFingerprintChallengeActionBlock},
			JsChallenge: &waas.JsChallenge{ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
				CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
				BlockAction:               waas.BlockChallengeSettingsBlockActionShowErrorPage,
				BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
				BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
				BlockResponseCode:         common.Int(957),
				CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
				CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
				BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
				IsNatEnabled:              common.Bool(true),
				ActionExpirationInSeconds: common.Int(368790),
				Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotContain,
					IsCaseSensitive: common.Bool(false),
					Value:           common.String("EXAMPLE-value-Value")}},
				FailureThreshold: common.Int(966080),
				IsEnabled:        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)},
			OriginGroups: []string{"EXAMPLE--Value"}}},
		OpcRequestId:  common.String("V2IRMYI0SEPX11V9HO7B<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)
}