// 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{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_buDIt": map[string]interface{}{"EXAMPLE_KEY_5BUSC": "EXAMPLE--Value"}},
Domain: common.String("EXAMPLE-domain-Value"),
Origins: map[string]waas.Origin{"EXAMPLE_KEY_6Obef": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(60519),
HttpsPort: common.Int(58956),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderTrueClientIp,
IsBehindCdn: common.Bool(false),
IsCacheControlRespected: common.Bool(true),
IsHttpsEnabled: common.Bool(true),
IsHttpsForced: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(true),
IsSniEnabled: common.Bool(true),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
HealthChecks: &waas.HealthCheck{HealthyThreshold: common.Int(16),
IntervalInSeconds: common.Int(86),
Method: waas.HealthCheckMethodHead,
Path: common.String("EXAMPLE-path-Value"),
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Headers: map[string]string{"EXAMPLE_KEY_H2p5a": "EXAMPLE_VALUE_Yys1O4Ru54640Vy0wXa0"},
IsEnabled: common.Bool(true),
IsResponseTextCheckEnabled: common.Bool(true),
TimeoutInSeconds: common.Int(119),
UnhealthyThreshold: common.Int(2),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx}},
IsOriginCompressionEnabled: common.Bool(true),
LoadBalancingMethod: waas.RoundRobinLoadBalancingMethod{},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_zPDMs": "EXAMPLE_VALUE_1xc9Ffjq6x2j9b8vB4lt"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_Lqsee": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(5573)}}}},
WafConfig: &waas.WafConfigDetails{DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(5980),
MaxAddressCountExpirationInSeconds: common.Int(368800),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(211966),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(706),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")},
FailureThreshold: common.Int(565232),
FailureThresholdExpirationInSeconds: common.Int(186573)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
ActionExpirationInSeconds: common.Int(347683),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
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(802),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
FailureThreshold: common.Int(356637),
AreRedirectsChallenged: common.Bool(true),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpNotInList,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"},
ProtectionSettings: &waas.ProtectionSettings{IsResponseInspected: common.Bool(false),
MaxArgumentCount: common.Int(7408),
MaxResponseSizeInKiB: common.Int(226),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(30),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(378),
MaxNameLengthPerArgument: common.Int(30266),
MaxTotalNameLengthOfArguments: common.Int(184224),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockResponseCode: common.Int(702),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.AccessRuleActionDetect,
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpMethodIs,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}}}},
AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(230),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(5006),
AllowedRatePerAddress: common.Int(8270)},
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.CachingRuleCriteriaConditionIs,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
Captchas: []waas.Captcha{waas.Captcha{HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(57619),
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")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetArgs,
Exclusions: []string{"EXAMPLE--Value"}}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(676),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
FailureThreshold: common.Int(969006),
InteractionThreshold: common.Int(63),
RecordingPeriodInSeconds: common.Int(3298),
ActionExpirationInSeconds: common.Int(38747),
FailureThresholdExpirationInSeconds: common.Int(372434),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Whitelists: []waas.Whitelist{waas.Whitelist{Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"}}}}},
OpcRequestId: common.String("5ICBIYS0CCM3PFCQBMMH<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)
}