// 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("GVSY8P1PXVSNDV1BRMNA<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{FreeformTags: map[string]string{"EXAMPLE_KEY_sngZP": "EXAMPLE_VALUE_dfFVljc1gOVmxbKqS7r7"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_wIDZJ": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(1754)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_a4CjS": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(50069),
HttpsPort: common.Int(3106),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXForwardedFor,
HealthChecks: &waas.HealthCheck{IsResponseTextCheckEnabled: common.Bool(true),
Method: waas.HealthCheckMethodGet,
Path: common.String("EXAMPLE-path-Value"),
TimeoutInSeconds: common.Int(82),
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Headers: map[string]string{"EXAMPLE_KEY_uNsS0": "EXAMPLE_VALUE_v8VN0HvFhlz6TYXXm0bK"},
HealthyThreshold: common.Int(13),
IntervalInSeconds: common.Int(64),
IsEnabled: common.Bool(true),
UnhealthyThreshold: common.Int(5),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup5xx}},
IsCacheControlRespected: common.Bool(true),
IsHttpsEnabled: common.Bool(false),
IsHttpsForced: common.Bool(false),
IsOriginCompressionEnabled: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(true),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
IsBehindCdn: common.Bool(false)},
WafConfig: &waas.WafConfig{Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--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")}},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
ActionExpirationInSeconds: common.Int(133646),
AreRedirectsChallenged: common.Bool(true),
ChallengeSettings: &waas.BlockChallengeSettings{BlockResponseCode: common.Int(561),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
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")},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUrlStartsWith,
IsCaseSensitive: common.Bool(false)}},
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")},
FailureThreshold: common.Int(925768)},
Origin: common.String("EXAMPLE-origin-Value"),
AccessRules: []waas.AccessRule{waas.AccessRule{BlockResponseCode: common.Int(721),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUrlDoesNotStartWith,
IsCaseSensitive: common.Bool(false)}},
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.AccessRuleActionRedirect,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(1970),
BlockResponseCode: common.Int(135),
IsEnabled: common.Bool(false),
MaxDelayedCountPerAddress: common.Int(3571)},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(89783),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(299743),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(327),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")},
FailureThreshold: common.Int(492497),
FailureThresholdExpirationInSeconds: common.Int(49449),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(379)},
GoodBots: []waas.GoodBot{waas.GoodBot{Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Description: common.String("EXAMPLE-description-Value"),
IsEnabled: common.Bool(false)}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(false),
Action: waas.HumanInteractionChallengeActionBlock,
FailureThreshold: common.Int(500858),
FailureThresholdExpirationInSeconds: common.Int(43901),
InteractionThreshold: common.Int(55),
RecordingPeriodInSeconds: common.Int(9780),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(316802),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(341),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")}},
ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Name: common.String("EXAMPLE-name-Value"),
Action: waas.ThreatFeedActionOff,
Description: common.String("EXAMPLE-description-Value"),
Key: common.String("EXAMPLE-key-Value")}},
CachingRules: []waas.CachingRule{waas.CachingRule{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"),
Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionPartEndsWith,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true)}},
Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(230607),
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")}},
OriginGroups: []string{"EXAMPLE--Value"},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionBlock,
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")}},
ProtectionSettings: &waas.ProtectionSettings{BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockResponseCode: common.Int(524),
MaxArgumentCount: common.Int(7121),
MaxNameLengthPerArgument: common.Int(140040),
MaxTotalNameLengthOfArguments: common.Int(27076),
MediaTypes: []string{"EXAMPLE--Value"},
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsTrace},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
IsResponseInspected: common.Bool(false),
MaxResponseSizeInKiB: common.Int(989),
RecommendationsPeriodInDays: common.Int(30)}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_sBh7b": map[string]interface{}{"EXAMPLE_KEY_QEmng": "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)
}