// 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{OpcRequestId: common.String("B9TBDT7F8HK59QQPTKQU<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{FreeformTags: map[string]string{"EXAMPLE_KEY_PNQfq": "EXAMPLE_VALUE_72AZ1Up1r3JzsYRXkSOS"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_BzRoN": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(1833)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_fAtdm": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(42765),
HttpsPort: common.Int(7750),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXClientIp,
IsCacheControlRespected: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(false),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CipherGroup: waas.PolicyConfigCipherGroupDefault,
HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
Headers: map[string]string{"EXAMPLE_KEY_x9Ghm": "EXAMPLE_VALUE_ON98Vj2b0GYa60Tlphzk"},
HealthyThreshold: common.Int(12),
IntervalInSeconds: common.Int(21),
IsEnabled: common.Bool(true),
Method: waas.HealthCheckMethodHead,
TimeoutInSeconds: common.Int(65),
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
IsResponseTextCheckEnabled: common.Bool(false),
Path: common.String("EXAMPLE-path-Value"),
UnhealthyThreshold: common.Int(1)},
IsBehindCdn: common.Bool(false),
IsHttpsEnabled: common.Bool(false),
IsHttpsForced: common.Bool(false),
IsOriginCompressionEnabled: common.Bool(false),
IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.RoundRobinLoadBalancingMethod{}},
WafConfig: &waas.WafConfig{ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{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"},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionDetect,
Description: common.String("EXAMPLE-description-Value")}},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
Name: common.String("EXAMPLE-name-Value"),
Action: waas.AccessRuleActionBypass,
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionCountryIs,
IsCaseSensitive: common.Bool(false)}},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(847),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(206796),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
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"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(568)},
FailureThreshold: common.Int(243210),
FailureThresholdExpirationInSeconds: common.Int(146158),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(8326),
MaxAddressCountExpirationInSeconds: common.Int(57267),
Action: waas.DeviceFingerprintChallengeActionBlock},
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")}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(7856),
BlockResponseCode: common.Int(558),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(6104)},
ProtectionSettings: &waas.ProtectionSettings{MaxResponseSizeInKiB: common.Int(1279),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
IsResponseInspected: common.Bool(false),
MaxNameLengthPerArgument: common.Int(99872),
MaxTotalNameLengthOfArguments: common.Int(348219),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(43),
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(667),
MaxArgumentCount: common.Int(1356)},
ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ThreatFeedActionOff,
Description: common.String("EXAMPLE-description-Value")}},
CachingRules: []waas.CachingRule{waas.CachingRule{Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartEndsWith,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true),
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")}},
Captchas: []waas.Captcha{waas.Captcha{FailureMessage: common.String("EXAMPLE-failureMessage-Value"),
FooterText: common.String("EXAMPLE-footerText-Value"),
HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(11556),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgsNames}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(451),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
FailureThreshold: common.Int(758316),
IsNatEnabled: common.Bool(true),
Action: waas.JsChallengeActionBlock,
ActionExpirationInSeconds: common.Int(259607),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpInList,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
IsEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionBlock,
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(718),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")},
FailureThreshold: common.Int(584234),
InteractionThreshold: common.Int(71),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(7460),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(246719),
FailureThresholdExpirationInSeconds: common.Int(39985)},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_aCxUv": map[string]interface{}{"EXAMPLE_KEY_dzdFi": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value")},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
IfMatch: common.String("EXAMPLE-ifMatch-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)
}