// 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{FreeformTags: map[string]string{"EXAMPLE_KEY_HKa8E": "EXAMPLE_VALUE_sdSAyY7NsdgnUCcbBP2y"},
PolicyConfig: &waas.PolicyConfig{HealthChecks: &waas.HealthCheck{IntervalInSeconds: common.Int(97),
IsEnabled: common.Bool(true),
IsResponseTextCheckEnabled: common.Bool(false),
Method: waas.HealthCheckMethodHead,
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(37),
UnhealthyThreshold: common.Int(17),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
Headers: map[string]string{"EXAMPLE_KEY_IdB4t": "EXAMPLE_VALUE_f19v8CzERw0lZ8HgA31V"},
HealthyThreshold: common.Int(9)},
IsBehindCdn: common.Bool(false),
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderTrueClientIp,
IsCacheControlRespected: common.Bool(true),
IsHttpsEnabled: common.Bool(false),
IsHttpsForced: common.Bool(false),
IsOriginCompressionEnabled: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(false),
IsSniEnabled: common.Bool(true),
CipherGroup: waas.PolicyConfigCipherGroupDefault},
WafConfig: &waas.WafConfigDetails{DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(921),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")},
FailureThreshold: common.Int(687593),
FailureThresholdExpirationInSeconds: common.Int(418730),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(8426),
MaxAddressCountExpirationInSeconds: common.Int(207283),
Action: waas.DeviceFingerprintChallengeActionDetect,
ActionExpirationInSeconds: common.Int(127358)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
AreRedirectsChallenged: common.Bool(false),
FailureThreshold: common.Int(258865),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(221379),
ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(448),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpMethodIsNot,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(false)},
OriginGroups: []string{"EXAMPLE--Value"},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockResponseCode: common.Int(192),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Name: common.String("EXAMPLE-name-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Action: waas.AccessRuleActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUserAgentIs,
IsCaseSensitive: common.Bool(true)}},
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6231),
BlockResponseCode: common.Int(183),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(7107)},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
InteractionThreshold: common.Int(77),
IsNatEnabled: common.Bool(false),
RecordingPeriodInSeconds: common.Int(7167),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(361737),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(481),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
FailureThreshold: common.Int(634553),
FailureThresholdExpirationInSeconds: common.Int(113141),
IsEnabled: common.Bool(false)},
Origin: common.String("EXAMPLE-origin-Value"),
ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(239),
IsResponseInspected: common.Bool(false),
MaxNameLengthPerArgument: common.Int(121515),
MaxResponseSizeInKiB: common.Int(85),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
MaxArgumentCount: common.Int(6133),
MaxTotalNameLengthOfArguments: common.Int(47917),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(37),
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
CachingRules: []waas.CachingRule{waas.CachingRule{CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.CachingRuleCriteriaConditionPartEndsWith}},
IsClientCachingEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.CachingRuleActionCache}},
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(335793),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_LN0rr": map[string]interface{}{"EXAMPLE_KEY_mGzBx": "EXAMPLE--Value"}},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_ZfdJJ": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(9646)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_S8CV6": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(62446),
HttpsPort: common.Int(10382),
Uri: common.String("EXAMPLE-uri-Value")}},
AdditionalDomains: []string{"EXAMPLE--Value"},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
Domain: common.String("EXAMPLE-domain-Value")},
OpcRequestId: common.String("XMFPK5L4KDE1BFZ2VYTM<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)
}