// 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(false),
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
CipherGroup: waas.PolicyConfigCipherGroupDefault,
IsBehindCdn: common.Bool(true),
IsCacheControlRespected: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(false),
IsSniEnabled: common.Bool(true),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXClientIp,
HealthChecks: &waas.HealthCheck{UnhealthyThreshold: common.Int(9),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
HealthyThreshold: common.Int(2),
IntervalInSeconds: common.Int(36),
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Headers: map[string]string{"EXAMPLE_KEY_WLlkm": "EXAMPLE_VALUE_0zOTAIb7rG6c6TGEZKZ8"},
IsEnabled: common.Bool(true),
IsResponseTextCheckEnabled: common.Bool(true),
Method: waas.HealthCheckMethodGet,
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(13)},
IsHttpsEnabled: common.Bool(false),
IsHttpsForced: common.Bool(false)},
WafConfig: &waas.WafConfigDetails{AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(3858),
BlockResponseCode: common.Int(247),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(8411)},
Captchas: []waas.Captcha{waas.Captcha{Url: common.String("EXAMPLE-url-Value"),
FailureMessage: common.String("EXAMPLE-failureMessage-Value"),
FooterText: common.String("EXAMPLE-footerText-Value"),
HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(144885),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-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")}},
Origin: common.String("EXAMPLE-origin-Value"),
Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"}}},
CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionCache,
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(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(277714),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(8164),
MaxAddressCountExpirationInSeconds: common.Int(11093),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(229369),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(756),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
FailureThreshold: common.Int(736108)},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{InteractionThreshold: common.Int(67),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
FailureThreshold: common.Int(911142),
FailureThresholdExpirationInSeconds: common.Int(225130),
IsEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(11059),
Action: waas.HumanInteractionChallengeActionDetect,
ActionExpirationInSeconds: common.Int(338164),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(915),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")}},
JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIs,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(432315),
IsEnabled: common.Bool(true),
Action: waas.JsChallengeActionBlock,
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")},
ActionExpirationInSeconds: common.Int(62501),
AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(723),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")}},
OriginGroups: []string{"EXAMPLE--Value"},
ProtectionSettings: &waas.ProtectionSettings{MaxTotalNameLengthOfArguments: common.Int(49222),
MediaTypes: []string{"EXAMPLE--Value"},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(136),
MaxArgumentCount: common.Int(9480),
RecommendationsPeriodInDays: common.Int(90),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
IsResponseInspected: common.Bool(true),
MaxNameLengthPerArgument: common.Int(141650),
MaxResponseSizeInKiB: common.Int(1511)},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Name: common.String("EXAMPLE-name-Value"),
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
BlockResponseCode: common.Int(445),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
Action: waas.AccessRuleActionShowCaptcha,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")}}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_15mRA": map[string]interface{}{"EXAMPLE_KEY_jYiiU": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_oNgD0": "EXAMPLE_VALUE_e7fug8TjwhLqYWjIOsuh"},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
Domain: common.String("EXAMPLE-domain-Value"),
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_TM4UG": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(5403)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_BFz2v": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(27757),
HttpsPort: common.Int(63456),
Uri: common.String("EXAMPLE-uri-Value")}}},
OpcRequestId: common.String("UWRY2C6U6SD7LZJAME8H<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)
}