// 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{UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{PolicyConfig: &waas.PolicyConfig{IsHttpsForced: common.Bool(false),
IsOriginCompressionEnabled: common.Bool(false),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV13},
IsBehindCdn: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(false),
HealthChecks: &waas.HealthCheck{Headers: map[string]string{"EXAMPLE_KEY_qzJ2P": "EXAMPLE_VALUE_y5JfnFZnyotrpwITLXVx"},
HealthyThreshold: common.Int(15),
IsResponseTextCheckEnabled: common.Bool(true),
Method: waas.HealthCheckMethodGet,
TimeoutInSeconds: common.Int(101),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
Path: common.String("EXAMPLE-path-Value"),
UnhealthyThreshold: common.Int(1),
IntervalInSeconds: common.Int(7),
IsEnabled: common.Bool(true)},
IsHttpsEnabled: common.Bool(false),
IsSniEnabled: common.Bool(false),
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
IsCacheControlRespected: common.Bool(true),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXRealIp,
LoadBalancingMethod: waas.IpHashLoadBalancingMethod{},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value")},
WafConfig: &waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Name: common.String("EXAMPLE-name-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BlockResponseCode: common.Int(612),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Action: waas.AccessRuleActionBlock,
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIsNot,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-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{FailureMessage: common.String("EXAMPLE-failureMessage-Value"),
FooterText: common.String("EXAMPLE-footerText-Value"),
HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(183468),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{Action: waas.HumanInteractionChallengeActionDetect,
InteractionThreshold: common.Int(28),
IsNatEnabled: common.Bool(false),
ActionExpirationInSeconds: common.Int(382577),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(140),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")},
FailureThreshold: common.Int(46050),
FailureThresholdExpirationInSeconds: common.Int(126674),
IsEnabled: common.Bool(false),
RecordingPeriodInSeconds: common.Int(11369),
SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")}},
ProtectionSettings: &waas.ProtectionSettings{BlockResponseCode: common.Int(959),
MaxNameLengthPerArgument: common.Int(56305),
MaxResponseSizeInKiB: common.Int(1220),
MediaTypes: []string{"EXAMPLE--Value"},
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
IsResponseInspected: common.Bool(true),
MaxArgumentCount: common.Int(1081),
MaxTotalNameLengthOfArguments: common.Int(14438),
RecommendationsPeriodInDays: common.Int(42),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPost},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")},
CachingRules: []waas.CachingRule{waas.CachingRule{Action: waas.CachingRuleActionCache,
CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.CachingRuleCriteriaConditionPartContains}},
IsClientCachingEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(9116),
MaxAddressCountExpirationInSeconds: common.Int(175613),
Action: waas.DeviceFingerprintChallengeActionDetect,
ActionExpirationInSeconds: common.Int(128817),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(823),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
FailureThreshold: common.Int(912916),
FailureThresholdExpirationInSeconds: common.Int(420750)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
AreRedirectsChallenged: common.Bool(false),
FailureThreshold: common.Int(887975),
IsNatEnabled: common.Bool(false),
ActionExpirationInSeconds: common.Int(339971),
ChallengeSettings: &waas.BlockChallengeSettings{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(737),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlDoesNotMatchRegex,
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")}},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{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"),
Action: waas.ProtectionRuleActionDetect,
Description: common.String("EXAMPLE-description-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(6182),
BlockResponseCode: common.Int(188),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(6841)},
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")}},
GoodBots: []waas.GoodBot{waas.GoodBot{Name: common.String("EXAMPLE-name-Value"),
Description: common.String("EXAMPLE-description-Value"),
IsEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value")}},
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")}}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_k8aqv": map[string]interface{}{"EXAMPLE_KEY_US3KE": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_ekQk4": "EXAMPLE_VALUE_LPfJXjgDoR6l48Sql0jP"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_20V8z": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(3926)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_V5mNE": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(39461),
HttpsPort: common.Int(36922),
Uri: common.String("EXAMPLE-uri-Value")}}},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("NK1Z6OBEFOLQSEES5FET<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-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)
}