// 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 ExampleUpdateWaasPolicy() {
// 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.UpdateWaasPolicyRequest{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_NEr20": map[string]interface{}{"EXAMPLE_KEY_g5V5m": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_lrsJX": "EXAMPLE_VALUE_MipzVTv3eN0MzNf4CvR5"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_0R0ZN": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(6194)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_T4R25": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(53798),
HttpsPort: common.Int(2498),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{HealthChecks: &waas.HealthCheck{HealthyThreshold: common.Int(11),
IsEnabled: common.Bool(true),
IsResponseTextCheckEnabled: common.Bool(true),
Method: waas.HealthCheckMethodGet,
UnhealthyThreshold: common.Int(6),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Headers: map[string]string{"EXAMPLE_KEY_Ui7sM": "EXAMPLE_VALUE_GsMISwgm7OKCsVhTu3uZ"},
IntervalInSeconds: common.Int(95),
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(31)},
IsCacheControlRespected: common.Bool(false),
IsSniEnabled: common.Bool(false),
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CipherGroup: waas.PolicyConfigCipherGroupDefault,
IsBehindCdn: common.Bool(false),
IsHttpsEnabled: common.Bool(true),
IsHttpsForced: common.Bool(true),
IsOriginCompressionEnabled: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(true),
LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Domain: common.String("EXAMPLE-domain-Value"),
ExpirationTimeInSeconds: common.Int(2.4088071e+07),
Name: common.String("EXAMPLE-name-Value")},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXForwardedFor},
WafConfig: &waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Action: waas.AccessRuleActionRedirect,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(461),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
Name: common.String("EXAMPLE-name-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotContain,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.HumanInteractionChallengeActionBlock,
ActionExpirationInSeconds: common.Int(163674),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(257),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
InteractionThreshold: common.Int(23),
RecordingPeriodInSeconds: common.Int(5287),
FailureThreshold: common.Int(293925),
FailureThresholdExpirationInSeconds: common.Int(116744),
IsEnabled: common.Bool(false)},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionDetect,
Description: common.String("EXAMPLE-description-Value"),
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgsNames}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(4382),
AllowedRatePerAddress: common.Int(424),
BlockResponseCode: common.Int(817)},
CachingRules: []waas.CachingRule{waas.CachingRule{Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.CachingRuleActionCache,
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(true)}},
ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
MaxNameLengthPerArgument: common.Int(126946),
MaxTotalNameLengthOfArguments: common.Int(340489),
RecommendationsPeriodInDays: common.Int(44),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(746),
IsResponseInspected: common.Bool(true),
MaxArgumentCount: common.Int(3819),
MaxResponseSizeInKiB: common.Int(1738),
MediaTypes: []string{"EXAMPLE--Value"},
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete}},
ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionDetect,
Description: common.String("EXAMPLE-description-Value"),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(232397),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-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(520),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")},
FailureThreshold: common.Int(669232),
FailureThresholdExpirationInSeconds: common.Int(320678),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(5628),
MaxAddressCountExpirationInSeconds: common.Int(136028),
Action: waas.DeviceFingerprintChallengeActionBlock},
GoodBots: []waas.GoodBot{waas.GoodBot{Description: common.String("EXAMPLE-description-Value"),
IsEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
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(378528),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value")}},
JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(747),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-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"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode},
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.JsChallengeActionBlock,
ActionExpirationInSeconds: common.Int(418914),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIsNot,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(84513),
IsEnabled: common.Bool(true)}}},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("V8Z04TK9BPLGF2FVUYQU<unique_ID>")}
// Send the request using the service client
resp, err := client.UpdateWaasPolicy(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}