// 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("QR5CATRCLTJGJNGFRZX0<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
CreateWaasPolicyDetails: waas.CreateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_fCRlB": map[string]interface{}{"EXAMPLE_KEY_j3Vfy": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
Domain: common.String("EXAMPLE-domain-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_YG8o0": "EXAMPLE_VALUE_bDCmMIMAtdfYgEaLslnB"},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_xq904": waas.Origin{HttpsPort: common.Int(36121),
Uri: common.String("EXAMPLE-uri-Value"),
CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(30598)}},
WafConfig: &waas.WafConfigDetails{AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(275),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(7679),
AllowedRatePerAddress: common.Int(9888)},
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(50580),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(280951),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(6297),
MaxAddressCountExpirationInSeconds: common.Int(165917),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(186813),
ChallengeSettings: &waas.BlockChallengeSettings{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"),
BlockResponseCode: common.Int(975),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
FailureThreshold: common.Int(95832)},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"},
ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(487),
IsResponseInspected: common.Bool(false),
MaxNameLengthPerArgument: common.Int(48728),
MaxTotalNameLengthOfArguments: common.Int(121934),
RecommendationsPeriodInDays: common.Int(62),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsOptions},
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
MaxArgumentCount: common.Int(1472),
MaxResponseSizeInKiB: common.Int(353),
MediaTypes: []string{"EXAMPLE--Value"}},
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.CachingRuleCriteriaConditionPartContains,
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{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
Action: waas.CustomProtectionRuleSettingActionDetect}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{IsEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(275360),
FailureThresholdExpirationInSeconds: common.Int(208755),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(3460),
Action: waas.HumanInteractionChallengeActionDetect,
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(473),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
FailureThreshold: common.Int(797784),
InteractionThreshold: common.Int(28)},
JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIsNot,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
FailureThreshold: common.Int(152615),
IsEnabled: common.Bool(false),
Action: waas.JsChallengeActionBlock,
ActionExpirationInSeconds: common.Int(395566),
AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(737),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")}},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
AccessRules: []waas.AccessRule{waas.AccessRule{ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Action: waas.AccessRuleActionAllow,
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(462),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
Name: common.String("EXAMPLE-name-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value")}}},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_keynN": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(2457)}}}},
PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderClientIp,
IsBehindCdn: common.Bool(false),
IsCacheControlRespected: common.Bool(true),
IsHttpsEnabled: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(false),
IsSniEnabled: common.Bool(false),
HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Headers: map[string]string{"EXAMPLE_KEY_K0wlP": "EXAMPLE_VALUE_CfsQeU3pSrIbStRMiFuc"},
HealthyThreshold: common.Int(5),
IsEnabled: common.Bool(false),
IsResponseTextCheckEnabled: common.Bool(false),
Method: waas.HealthCheckMethodPost,
Path: common.String("EXAMPLE-path-Value"),
IntervalInSeconds: common.Int(78),
TimeoutInSeconds: common.Int(2),
UnhealthyThreshold: common.Int(2)},
IsHttpsForced: common.Bool(false),
IsOriginCompressionEnabled: common.Bool(false),
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV11},
WebsocketPathPrefixes: []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)
}