// 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{IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("7FBJF0W34W6C8MUKGCEL<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_Puf4t": map[string]interface{}{"EXAMPLE_KEY_HZf4P": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_Vqxjk": "EXAMPLE_VALUE_pKKd6Bmv5U4uYcgqxnqj"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_rbdC8": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(6392)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_YmoYu": waas.Origin{HttpPort: common.Int(50067),
HttpsPort: common.Int(30343),
Uri: common.String("EXAMPLE-uri-Value"),
CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}}}},
PolicyConfig: &waas.PolicyConfig{IsHttpsEnabled: common.Bool(true),
IsHttpsForced: common.Bool(false),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV11},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderClientIp,
IsBehindCdn: common.Bool(false),
IsCacheControlRespected: common.Bool(false),
IsOriginCompressionEnabled: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(false),
IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Domain: common.String("EXAMPLE-domain-Value"),
ExpirationTimeInSeconds: common.Int(2.1836621e+07),
Name: common.String("EXAMPLE-name-Value")},
CipherGroup: waas.PolicyConfigCipherGroupDefault,
HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
HealthyThreshold: common.Int(6),
IntervalInSeconds: common.Int(21),
IsEnabled: common.Bool(true),
Method: waas.HealthCheckMethodHead,
UnhealthyThreshold: common.Int(1),
Headers: map[string]string{"EXAMPLE_KEY_1xc9F": "EXAMPLE_VALUE_fjq6x2j9b8vB4lt5BUSC"},
IsResponseTextCheckEnabled: common.Bool(true),
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(69)}},
WafConfig: &waas.WafConfig{JsChallenge: &waas.JsChallenge{SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(72019),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(467)},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlRegex,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(true),
Action: waas.JsChallengeActionBlock,
AreRedirectsChallenged: common.Bool(false),
FailureThreshold: common.Int(983309)},
ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
MaxArgumentCount: common.Int(6393),
MaxNameLengthPerArgument: common.Int(14768),
MaxTotalNameLengthOfArguments: common.Int(273078),
RecommendationsPeriodInDays: common.Int(8),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(635),
IsResponseInspected: common.Bool(false),
MaxResponseSizeInKiB: common.Int(708),
MediaTypes: []string{"EXAMPLE--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(319332),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value")}},
OriginGroups: []string{"EXAMPLE--Value"},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionDetect,
Description: common.String("EXAMPLE-description-Value"),
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"}}},
ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionBlock,
Description: common.String("EXAMPLE-description-Value"),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(5131),
AllowedRatePerAddress: common.Int(7634),
BlockResponseCode: common.Int(178)},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
FailureThreshold: common.Int(218938),
InteractionThreshold: common.Int(64),
IsEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(143277),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(730),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
FailureThresholdExpirationInSeconds: common.Int(164343),
IsNatEnabled: common.Bool(false),
RecordingPeriodInSeconds: common.Int(1016)},
Origin: common.String("EXAMPLE-origin-Value"),
AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIsNot,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.AccessRuleActionBlock,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(152),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThreshold: common.Int(485294),
FailureThresholdExpirationInSeconds: common.Int(139353),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(8814),
MaxAddressCountExpirationInSeconds: common.Int(367066),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(304704),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(658),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")}},
GoodBots: []waas.GoodBot{waas.GoodBot{Description: common.String("EXAMPLE-description-Value"),
IsEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
CachingRules: []waas.CachingRule{waas.CachingRule{Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionStartsWith,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.CachingRuleActionBypassCache,
CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}}},
AdditionalDomains: []string{"EXAMPLE--Value"}},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value")}
// 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)
}