// 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{WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("C89TYMO7UPVMFJH2PNQF<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_C1L6R": map[string]interface{}{"EXAMPLE_KEY_TmpTT": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_3HCdi": "EXAMPLE_VALUE_GiYPhQaCk0DskA4237VP"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_8ibn2": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Origin: common.String("EXAMPLE-origin-Value"),
Weight: common.Int(2606)}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_qIucg": waas.Origin{CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(18066),
HttpsPort: common.Int(47784),
Uri: common.String("EXAMPLE-uri-Value")}},
PolicyConfig: &waas.PolicyConfig{IsCacheControlRespected: common.Bool(true),
IsOriginCompressionEnabled: common.Bool(false),
IsResponseBufferingEnabled: common.Bool(false),
IsSniEnabled: common.Bool(true),
LoadBalancingMethod: waas.RoundRobinLoadBalancingMethod{},
CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderXClientIp,
IsHttpsEnabled: common.Bool(false),
IsHttpsForced: common.Bool(true),
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV1},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
CipherGroup: waas.PolicyConfigCipherGroupDefault,
HealthChecks: &waas.HealthCheck{ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup4xx},
Headers: map[string]string{"EXAMPLE_KEY_4xuRO": "EXAMPLE_VALUE_roHkn92b6Gj1otfAtdmi"},
HealthyThreshold: common.Int(3),
IntervalInSeconds: common.Int(119),
IsResponseTextCheckEnabled: common.Bool(true),
Path: common.String("EXAMPLE-path-Value"),
UnhealthyThreshold: common.Int(14),
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
IsEnabled: common.Bool(true),
Method: waas.HealthCheckMethodHead,
TimeoutInSeconds: common.Int(111)},
IsBehindCdn: common.Bool(false)},
WafConfig: &waas.WafConfig{CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
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)}},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Name: common.String("EXAMPLE-name-Value"),
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"}}},
ProtectionSettings: &waas.ProtectionSettings{IsResponseInspected: common.Bool(true),
MaxArgumentCount: common.Int(6725),
MaxResponseSizeInKiB: common.Int(1433),
MaxTotalNameLengthOfArguments: common.Int(228548),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPropfind},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
MaxNameLengthPerArgument: common.Int(56628),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(11),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(201)},
Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(197018),
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")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(46556),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(760),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
FailureThreshold: common.Int(911327),
FailureThresholdExpirationInSeconds: common.Int(121593),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(2409),
MaxAddressCountExpirationInSeconds: common.Int(49676)},
JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionIpIs,
IsCaseSensitive: common.Bool(true)}},
FailureThreshold: common.Int(223784),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.JsChallengeActionDetect,
AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(391),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value")},
IsEnabled: common.Bool(false),
ActionExpirationInSeconds: common.Int(394542)},
ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Description: common.String("EXAMPLE-description-Value"),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ThreatFeedActionDetect}},
AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionBlock,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUrlDoesNotStartWith,
IsCaseSensitive: common.Bool(true)}},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(906),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Name: common.String("EXAMPLE-name-Value")}},
CachingRules: []waas.CachingRule{waas.CachingRule{Name: common.String("EXAMPLE-name-Value"),
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(false),
Key: common.String("EXAMPLE-key-Value")}},
OriginGroups: []string{"EXAMPLE--Value"},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(7576),
BlockResponseCode: common.Int(554),
IsEnabled: common.Bool(false),
MaxDelayedCountPerAddress: common.Int(7178)},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThresholdExpirationInSeconds: common.Int(241763),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(false),
RecordingPeriodInSeconds: common.Int(3608),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(167636),
InteractionThreshold: common.Int(89),
Action: waas.HumanInteractionChallengeActionBlock,
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(654)},
FailureThreshold: common.Int(702453)},
Origin: common.String("EXAMPLE-origin-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)
}