// 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("YMOYURRBDC8JLZCZFWL9<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_tSHuT": "EXAMPLE_VALUE_XQZ3glhF2NEmDabW6dfh"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_scVvR": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(7744)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_kqdWd": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(18014),
HttpsPort: common.Int(45152),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{HealthChecks: &waas.HealthCheck{Method: waas.HealthCheckMethodPost,
Path: common.String("EXAMPLE-path-Value"),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup3xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
IntervalInSeconds: common.Int(102),
IsEnabled: common.Bool(true),
IsResponseTextCheckEnabled: common.Bool(true),
TimeoutInSeconds: common.Int(80),
UnhealthyThreshold: common.Int(15),
Headers: map[string]string{"EXAMPLE_KEY_k4LPf": "EXAMPLE_VALUE_JXjgDoR6l48Sql0jPUS3"},
HealthyThreshold: common.Int(9)},
IsBehindCdn: common.Bool(false),
IsCacheControlRespected: common.Bool(false),
IsHttpsForced: common.Bool(true),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
IsHttpsEnabled: common.Bool(true),
IsOriginCompressionEnabled: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(true),
IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Name: common.String("EXAMPLE-name-Value"),
Domain: common.String("EXAMPLE-domain-Value"),
ExpirationTimeInSeconds: common.Int(3.550872e+06)}},
WafConfig: &waas.WafConfig{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")}},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionOff,
Description: common.String("EXAMPLE-description-Value"),
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgsNames}}}},
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.ProtectionRuleExclusionTargetArgs}}}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThresholdExpirationInSeconds: common.Int(72390),
InteractionThreshold: common.Int(46),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(9214),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(400503),
IsEnabled: common.Bool(true),
Action: waas.HumanInteractionChallengeActionDetect,
ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(288),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")},
FailureThreshold: common.Int(987842)},
ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPropfind},
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(968),
MaxArgumentCount: common.Int(8938),
MaxNameLengthPerArgument: common.Int(102647),
MaxResponseSizeInKiB: common.Int(1715),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
IsResponseInspected: common.Bool(true),
MaxTotalNameLengthOfArguments: common.Int(42401),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(20)},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(227),
BlockResponseCode: common.Int(135),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(7347)},
Origin: common.String("EXAMPLE-origin-Value"),
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")}},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Name: common.String("EXAMPLE-name-Value"),
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(202),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIsNot,
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")}},
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
Action: waas.AccessRuleActionBypass}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCount: common.Int(4490),
MaxAddressCountExpirationInSeconds: common.Int(157979),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(395793),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(439),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
FailureThreshold: common.Int(832355),
FailureThresholdExpirationInSeconds: common.Int(152324),
IsEnabled: common.Bool(true)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionBlock,
AreRedirectsChallenged: common.Bool(false),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotEndWith,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(154901),
IsEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")},
ActionExpirationInSeconds: common.Int(219947),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(264),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
IsNatEnabled: common.Bool(true)},
OriginGroups: []string{"EXAMPLE--Value"},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
CachingRules: []waas.CachingRule{waas.CachingRule{CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
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.CachingRuleActionCache}},
Captchas: []waas.Captcha{waas.Captcha{FooterText: common.String("EXAMPLE-footerText-Value"),
HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(173541),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value"),
FailureMessage: common.String("EXAMPLE-failureMessage-Value")}}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_shwyM": map[string]interface{}{"EXAMPLE_KEY_DeEbK": "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)
}