// 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{OpcRequestId: common.String("JDOSRSHSTWVRZ1UKU5HU<unique_ID>"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		CreateWaasPolicyDetails: waas.CreateWaasPolicyDetails{Domain: common.String("EXAMPLE-domain-Value"),
			OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_Yx9Gh": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
				Weight: common.Int(6125)}}}},
			Origins: map[string]waas.Origin{"EXAMPLE_KEY_ZZ2aa": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
				Value: common.String("EXAMPLE-value-Value")}},
				HttpPort:  common.Int(51660),
				HttpsPort: common.Int(39572),
				Uri:       common.String("EXAMPLE-uri-Value")}},
			WafConfig: &waas.WafConfigDetails{Origin: common.String("EXAMPLE-origin-Value"),
				OriginGroups: []string{"EXAMPLE--Value"},
				AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BypassChallenges:           []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
					CaptchaFooter:              common.String("EXAMPLE-captchaFooter-Value"),
					CaptchaHeader:              common.String("EXAMPLE-captchaHeader-Value"),
					CaptchaSubmitLabel:         common.String("EXAMPLE-captchaSubmitLabel-Value"),
					RedirectResponseCode:       waas.AccessRuleRedirectResponseCodeMovedPermanently,
					ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
					Name:                       common.String("EXAMPLE-name-Value"),
					Action:                     waas.AccessRuleActionBlock,
					BlockAction:                waas.AccessRuleBlockActionShowErrorPage,
					BlockErrorPageCode:         common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageDescription:  common.String("EXAMPLE-blockErrorPageDescription-Value"),
					BlockResponseCode:          common.Int(417),
					RedirectUrl:                common.String("EXAMPLE-redirectUrl-Value"),
					CaptchaTitle:               common.String("EXAMPLE-captchaTitle-Value"),
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(false),
						Value:     common.String("EXAMPLE-value-Value"),
						Condition: waas.AccessRuleCriteriaConditionUrlIsNot}}}},
				Captchas: []waas.Captcha{waas.Captcha{FailureMessage: common.String("EXAMPLE-failureMessage-Value"),
					FooterText:                 common.String("EXAMPLE-footerText-Value"),
					HeaderText:                 common.String("EXAMPLE-headerText-Value"),
					SessionExpirationInSeconds: common.Int(20919),
					SubmitLabel:                common.String("EXAMPLE-submitLabel-Value"),
					Title:                      common.String("EXAMPLE-title-Value"),
					Url:                        common.String("EXAMPLE-url-Value")}},
				HumanInteractionChallenge: &waas.HumanInteractionChallenge{IsEnabled: common.Bool(true),
					IsNatEnabled:              common.Bool(true),
					ActionExpirationInSeconds: common.Int(183255),
					ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(119),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value")},
					FailureThreshold:                    common.Int(934502),
					InteractionThreshold:                common.Int(17),
					Action:                              waas.HumanInteractionChallengeActionBlock,
					FailureThresholdExpirationInSeconds: common.Int(328126),
					RecordingPeriodInSeconds:            common.Int(612),
					SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
						Name: common.String("EXAMPLE-name-Value")}},
				DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(160178),
					Action:                    waas.DeviceFingerprintChallengeActionBlock,
					ActionExpirationInSeconds: common.Int(108536),
					ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value"),
						BlockResponseCode:         common.Int(734),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaSubmitLabel:        common.String("EXAMPLE-captchaSubmitLabel-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value")},
					FailureThreshold:                    common.Int(731474),
					FailureThresholdExpirationInSeconds: common.Int(51788),
					IsEnabled:                           common.Bool(true),
					MaxAddressCount:                     common.Int(8400)},
				JsChallenge: &waas.JsChallenge{IsNatEnabled: common.Bool(false),
					SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
						Value: common.String("EXAMPLE-value-Value")},
					Action:                    waas.JsChallengeActionDetect,
					ActionExpirationInSeconds: common.Int(145700),
					AreRedirectsChallenged:    common.Bool(false),
					FailureThreshold:          common.Int(467248),
					ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
						BlockAction:               waas.BlockChallengeSettingsBlockActionSetResponseCode,
						BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
						BlockResponseCode:         common.Int(813),
						CaptchaFooter:             common.String("EXAMPLE-captchaFooter-Value"),
						CaptchaHeader:             common.String("EXAMPLE-captchaHeader-Value"),
						CaptchaTitle:              common.String("EXAMPLE-captchaTitle-Value"),
						BlockErrorPageCode:        common.String("EXAMPLE-blockErrorPageCode-Value"),
						BlockErrorPageMessage:     common.String("EXAMPLE-blockErrorPageMessage-Value")},
					Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIsNot,
						IsCaseSensitive: common.Bool(false),
						Value:           common.String("EXAMPLE-value-Value")}},
					IsEnabled: common.Bool(false)},
				ProtectionSettings: &waas.ProtectionSettings{MaxTotalNameLengthOfArguments: common.Int(308245),
					MediaTypes:                  []string{"EXAMPLE--Value"},
					BlockErrorPageCode:          common.String("EXAMPLE-blockErrorPageCode-Value"),
					BlockErrorPageMessage:       common.String("EXAMPLE-blockErrorPageMessage-Value"),
					BlockResponseCode:           common.Int(983),
					IsResponseInspected:         common.Bool(true),
					MaxNameLengthPerArgument:    common.Int(31603),
					RecommendationsPeriodInDays: common.Int(76),
					AllowedHttpMethods:          []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
					BlockAction:                 waas.ProtectionSettingsBlockActionSetResponseCode,
					BlockErrorPageDescription:   common.String("EXAMPLE-blockErrorPageDescription-Value"),
					MaxArgumentCount:            common.Int(7374),
					MaxResponseSizeInKiB:        common.Int(1382)},
				Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
					Addresses: []string{"EXAMPLE--Value"},
					Name:      common.String("EXAMPLE-name-Value")}},
				AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
					MaxDelayedCountPerAddress: common.Int(7975),
					AllowedRatePerAddress:     common.Int(2248),
					BlockResponseCode:         common.Int(575)},
				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.CachingRuleCriteriaConditionIs,
						Value: common.String("EXAMPLE-value-Value")}},
					IsClientCachingEnabled: common.Bool(false),
					Key:                    common.String("EXAMPLE-key-Value"),
					Name:                   common.String("EXAMPLE-name-Value")}},
				CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
					Action: waas.CustomProtectionRuleSettingActionDetect,
					Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
						Target: waas.ProtectionRuleExclusionTargetArgs}}}}},
			CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
			DefinedTags:   map[string]map[string]interface{}{"EXAMPLE_KEY_pTKqU": map[string]interface{}{"EXAMPLE_KEY_K59QQ": "EXAMPLE--Value"}},
			DisplayName:   common.String("EXAMPLE-displayName-Value"),
			FreeformTags:  map[string]string{"EXAMPLE_KEY_XkSOS": "EXAMPLE_VALUE_dzdFiaCxUvb9tBdT7F8h"},
			PolicyConfig: &waas.PolicyConfig{TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
				WebsocketPathPrefixes:      []string{"EXAMPLE--Value"},
				CertificateId:              common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
				IsBehindCdn:                common.Bool(true),
				IsHttpsForced:              common.Bool(false),
				IsOriginCompressionEnabled: common.Bool(true),
				IsSniEnabled:               common.Bool(false),
				ClientAddressHeader:        waas.PolicyConfigClientAddressHeaderXRealIp,
				IsCacheControlRespected:    common.Bool(false),
				IsHttpsEnabled:             common.Bool(true),
				LoadBalancingMethod:        waas.IpHashLoadBalancingMethod{},
				CipherGroup:                waas.PolicyConfigCipherGroupDefault,
				HealthChecks: &waas.HealthCheck{IntervalInSeconds: common.Int(70),
					ExpectedResponseCodeGroup:  []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
					Headers:                    map[string]string{"EXAMPLE_KEY_mR431": "EXAMPLE_VALUE_FNSZlPDICCDn3NZyI7Wh"},
					HealthyThreshold:           common.Int(1),
					Method:                     waas.HealthCheckMethodPost,
					Path:                       common.String("EXAMPLE-path-Value"),
					TimeoutInSeconds:           common.Int(95),
					UnhealthyThreshold:         common.Int(1),
					ExpectedResponseText:       common.String("EXAMPLE-expectedResponseText-Value"),
					IsEnabled:                  common.Bool(true),
					IsResponseTextCheckEnabled: common.Bool(true)},
				IsResponseBufferingEnabled: common.Bool(false)},
			AdditionalDomains: []string{"EXAMPLE--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)
}