// 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 ExampleUpdateWafConfig() {
// 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.UpdateWafConfigRequest{IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("6QQZBTHXBUQLTC0F071O<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWafConfigDetails: waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Name: common.String("EXAMPLE-name-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.ExtendHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
Action: waas.AccessRuleActionRedirect,
BlockResponseCode: common.Int(310),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}}}},
AddressRateLimiting: &waas.AddressRateLimiting{IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(5450),
AllowedRatePerAddress: common.Int(6892),
BlockResponseCode: common.Int(755)},
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}}}},
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")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(237166),
FailureThreshold: common.Int(107873),
FailureThresholdExpirationInSeconds: common.Int(178070),
InteractionThreshold: common.Int(95),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")},
Action: waas.HumanInteractionChallengeActionBlock,
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(555),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
RecordingPeriodInSeconds: common.Int(2512)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(200),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionHttpHeaderContains,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(796010),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(185930),
AreRedirectsChallenged: common.Bool(false)},
OriginGroups: []string{"EXAMPLE--Value"},
Captchas: []waas.Captcha{waas.Captcha{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"),
SessionExpirationInSeconds: common.Int(196406),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionDetect,
ActionExpirationInSeconds: common.Int(203480),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(130),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
FailureThreshold: common.Int(134967),
FailureThresholdExpirationInSeconds: common.Int(201192),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(5862),
MaxAddressCountExpirationInSeconds: common.Int(133046)},
Origin: common.String("EXAMPLE-origin-Value"),
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Description: common.String("EXAMPLE-description-Value"),
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetRequestCookies,
Exclusions: []string{"EXAMPLE--Value"}}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionBlock}},
ProtectionSettings: &waas.ProtectionSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
MaxArgumentCount: common.Int(97),
MaxResponseSizeInKiB: common.Int(620),
BlockResponseCode: common.Int(376),
IsResponseInspected: common.Bool(true),
MaxNameLengthPerArgument: common.Int(39631),
MaxTotalNameLengthOfArguments: common.Int(246881),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(89),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPatch},
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-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{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionStartsWith,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.CachingRuleActionBypassCache,
CachingDuration: common.String("EXAMPLE-cachingDuration-Value")}},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}}},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value")}
// Send the request using the service client
resp, err := client.UpdateWafConfig(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}