// 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{PolicyConfig: &waas.PolicyConfig{IsOriginCompressionEnabled: common.Bool(true),
IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Domain: common.String("EXAMPLE-domain-Value"),
ExpirationTimeInSeconds: common.Int(2.3154126e+07),
Name: common.String("EXAMPLE-name-Value")},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
CipherGroup: waas.PolicyConfigCipherGroupDefault,
HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
IsResponseTextCheckEnabled: common.Bool(true),
Method: waas.HealthCheckMethodPost,
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(19),
Headers: map[string]string{"EXAMPLE_KEY_YWjIO": "EXAMPLE_VALUE_suhjYiiU15mRAUwRy2c6"},
HealthyThreshold: common.Int(13),
IntervalInSeconds: common.Int(27),
IsEnabled: common.Bool(true),
UnhealthyThreshold: common.Int(16)},
IsBehindCdn: common.Bool(true),
IsHttpsEnabled: common.Bool(false),
IsHttpsForced: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(true),
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderTrueClientIp,
IsCacheControlRespected: common.Bool(true)},
AdditionalDomains: []string{"EXAMPLE--Value"},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Domain: common.String("EXAMPLE-domain-Value"),
Origins: map[string]waas.Origin{"EXAMPLE_KEY_aodqv": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")}},
HttpPort: common.Int(48220),
HttpsPort: common.Int(17955),
Uri: common.String("EXAMPLE-uri-Value")}},
WafConfig: &waas.WafConfigDetails{AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Value: common.String("EXAMPLE-value-Value"),
Header: common.String("EXAMPLE-header-Value")}},
Action: waas.AccessRuleActionRedirect,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(851),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUrlDoesNotMatchRegex,
IsCaseSensitive: common.Bool(false)}},
Name: common.String("EXAMPLE-name-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(5924),
BlockResponseCode: common.Int(217),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(9748)},
Captchas: []waas.Captcha{waas.Captcha{HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(331856),
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")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(304488),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockResponseCode: common.Int(471),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
FailureThreshold: common.Int(227793),
FailureThresholdExpirationInSeconds: common.Int(206184),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(6136),
MaxAddressCountExpirationInSeconds: common.Int(326492),
Action: waas.DeviceFingerprintChallengeActionBlock},
ProtectionSettings: &waas.ProtectionSettings{MaxResponseSizeInKiB: common.Int(1447),
MaxTotalNameLengthOfArguments: common.Int(291590),
MediaTypes: []string{"EXAMPLE--Value"},
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsHead},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
MaxNameLengthPerArgument: common.Int(76865),
RecommendationsPeriodInDays: common.Int(93),
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(810),
IsResponseInspected: common.Bool(true),
MaxArgumentCount: common.Int(1222)},
Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"}}},
CachingRules: []waas.CachingRule{waas.CachingRule{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"),
Action: waas.CachingRuleActionBypassCache,
CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetRequestCookies,
Exclusions: []string{"EXAMPLE--Value"}}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
Action: waas.CustomProtectionRuleSettingActionDetect}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(508),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
FailureThresholdExpirationInSeconds: common.Int(24551),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(10044),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.HumanInteractionChallengeActionBlock,
ActionExpirationInSeconds: common.Int(392476),
FailureThreshold: common.Int(901136),
InteractionThreshold: common.Int(29),
IsEnabled: common.Bool(false)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
ActionExpirationInSeconds: common.Int(250611),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(221),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
AreRedirectsChallenged: common.Bool(false),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUserAgentIsNot}},
FailureThreshold: common.Int(363468),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(false)},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_dWCwf": map[string]interface{}{"EXAMPLE_KEY_5BD8T": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_NYufl": "EXAMPLE_VALUE_FUzGrecxmgX96J8PakN9"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_hff8Y": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(7990)}}}}},
OpcRequestId: common.String("LCRC8WLMJWI22WYZ3T2C<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)
}