// 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{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_sodQe": map[string]interface{}{"EXAMPLE_KEY_97JkF": "EXAMPLE--Value"}},
Domain: common.String("EXAMPLE-domain-Value"),
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_RCLtJ": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(9736)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_Qr5Ca": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(23819),
HttpsPort: common.Int(45543),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{HealthChecks: &waas.HealthCheck{UnhealthyThreshold: common.Int(6),
Headers: map[string]string{"EXAMPLE_KEY_Vvy7o": "EXAMPLE_VALUE_5MkUU6gKpdPTgYPPf4Ne"},
IsEnabled: common.Bool(false),
IsResponseTextCheckEnabled: common.Bool(true),
Path: common.String("EXAMPLE-path-Value"),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
HealthyThreshold: common.Int(2),
IntervalInSeconds: common.Int(46),
Method: waas.HealthCheckMethodHead,
TimeoutInSeconds: common.Int(87)},
IsBehindCdn: common.Bool(true),
IsCacheControlRespected: common.Bool(true),
IsHttpsForced: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(true),
IsHttpsEnabled: common.Bool(true),
IsOriginCompressionEnabled: common.Bool(false),
IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXForwardedFor},
WafConfig: &waas.WafConfigDetails{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")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThreshold: common.Int(888538),
FailureThresholdExpirationInSeconds: common.Int(49263),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(9229),
InteractionThreshold: common.Int(30),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.HumanInteractionChallengeActionBlock,
ActionExpirationInSeconds: common.Int(120234),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(614),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")}},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
ActionExpirationInSeconds: common.Int(304566),
AreRedirectsChallenged: common.Bool(false),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(772103),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(820),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")}},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(4830),
BlockResponseCode: common.Int(444),
IsEnabled: common.Bool(false),
MaxDelayedCountPerAddress: common.Int(2432)},
CachingRules: []waas.CachingRule{waas.CachingRule{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartContains,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.CachingRuleActionBypassCache,
CachingDuration: common.String("EXAMPLE-cachingDuration-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionDetect,
ActionExpirationInSeconds: common.Int(123368),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(493),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
FailureThreshold: common.Int(622152),
FailureThresholdExpirationInSeconds: common.Int(341171),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(6194),
MaxAddressCountExpirationInSeconds: common.Int(431819)},
ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(299),
IsResponseInspected: common.Bool(true),
MaxArgumentCount: common.Int(4691),
MaxResponseSizeInKiB: common.Int(842),
MaxTotalNameLengthOfArguments: common.Int(224806),
MediaTypes: []string{"EXAMPLE--Value"},
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
MaxNameLengthPerArgument: common.Int(65348),
RecommendationsPeriodInDays: common.Int(34)},
Whitelists: []waas.Whitelist{waas.Whitelist{Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"}}},
AccessRules: []waas.AccessRule{waas.AccessRule{Name: common.String("EXAMPLE-name-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
Action: waas.AccessRuleActionAllow,
BlockResponseCode: common.Int(515),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIsNot,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")}},
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(241694),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_VhTu3": "EXAMPLE_VALUE_uZBqGvBGQwzBclZ86VUi"},
AdditionalDomains: []string{"EXAMPLE--Value"},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value")},
OpcRequestId: common.String("VRCRA0YYPSF2GOIHAVBO<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)
}