// 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{AdditionalDomains: []string{"EXAMPLE--Value"},
DisplayName: common.String("EXAMPLE-displayName-Value"),
Domain: common.String("EXAMPLE-domain-Value"),
Origins: map[string]waas.Origin{"EXAMPLE_KEY_QwzBc": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(57670),
HttpsPort: common.Int(17770),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{CipherGroup: waas.PolicyConfigCipherGroupDefault,
IsBehindCdn: common.Bool(true),
IsCacheControlRespected: common.Bool(true),
IsHttpsEnabled: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(true),
IsSniEnabled: common.Bool(false),
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXForwardedFor,
HealthChecks: &waas.HealthCheck{Method: waas.HealthCheckMethodHead,
UnhealthyThreshold: common.Int(6),
Headers: map[string]string{"EXAMPLE_KEY_f2goi": "EXAMPLE_VALUE_HavBOhg3rBGeI5uexHhy"},
HealthyThreshold: common.Int(1),
IntervalInSeconds: common.Int(13),
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(78),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
IsEnabled: common.Bool(true),
IsResponseTextCheckEnabled: common.Bool(false)},
IsHttpsForced: common.Bool(true),
IsOriginCompressionEnabled: common.Bool(false),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value")},
WafConfig: &waas.WafConfigDetails{AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(280),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.AccessRuleActionShowCaptcha,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains}},
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BlockAction: waas.AccessRuleBlockActionSetResponseCode}},
CachingRules: []waas.CachingRule{waas.CachingRule{Name: common.String("EXAMPLE-name-Value"),
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(true),
Key: common.String("EXAMPLE-key-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
Action: waas.CustomProtectionRuleSettingActionBlock,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgsNames}}}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(267764),
FailureThresholdExpirationInSeconds: common.Int(297159),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(9080),
MaxAddressCountExpirationInSeconds: common.Int(238639),
Action: waas.DeviceFingerprintChallengeActionDetect,
ActionExpirationInSeconds: common.Int(352669),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(927),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(393236),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(137),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")},
FailureThreshold: common.Int(690376),
FailureThresholdExpirationInSeconds: common.Int(320146),
InteractionThreshold: common.Int(66),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(8590),
Action: waas.HumanInteractionChallengeActionBlock,
IsEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
AreRedirectsChallenged: common.Bool(true),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(555),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")},
FailureThreshold: common.Int(292795),
IsEnabled: common.Bool(true),
ActionExpirationInSeconds: common.Int(320817),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUrlRegex}},
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"),
ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(813),
MaxResponseSizeInKiB: common.Int(1378),
MaxTotalNameLengthOfArguments: common.Int(198720),
IsResponseInspected: common.Bool(false),
MaxArgumentCount: common.Int(5828),
MaxNameLengthPerArgument: common.Int(55400),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(73),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPropfind}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(2351),
BlockResponseCode: common.Int(118),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(7366)},
Captchas: []waas.Captcha{waas.Captcha{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"),
HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(7482)}},
OriginGroups: []string{"EXAMPLE--Value"},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}}},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_3gEve": map[string]interface{}{"EXAMPLE_KEY_xk9ri": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_XqzJ2": "EXAMPLE_VALUE_Py5JfnFZnyotrpwITLXV"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_Z86VU": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Weight: common.Int(3490),
Origin: common.String("EXAMPLE-origin-Value")}}}}},
OpcRequestId: common.String("RCFQUV2SKBQ5YM2HBPEL<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)
}