// 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("RO9NPPYNPUTJGKIHBCXG<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWafConfigDetails: waas.WafConfig{JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIsNot,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(451775),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.JsChallengeActionBlock,
ActionExpirationInSeconds: common.Int(23583),
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.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(671),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
AreRedirectsChallenged: common.Bool(true)},
Origin: common.String("EXAMPLE-origin-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(175706),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}},
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")}},
ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsDelete},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
IsResponseInspected: common.Bool(true),
MaxResponseSizeInKiB: common.Int(1504),
MaxTotalNameLengthOfArguments: common.Int(67044),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(65),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(676),
MaxArgumentCount: common.Int(4398),
MaxNameLengthPerArgument: common.Int(99549)},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
OriginGroups: []string{"EXAMPLE--Value"},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(7695),
BlockResponseCode: common.Int(888),
IsEnabled: common.Bool(false),
MaxDelayedCountPerAddress: common.Int(1294)},
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{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")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{ActionExpirationInSeconds: common.Int(16350),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(131)},
FailureThreshold: common.Int(423784),
FailureThresholdExpirationInSeconds: common.Int(253984),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(5346),
MaxAddressCountExpirationInSeconds: common.Int(191175),
Action: waas.DeviceFingerprintChallengeActionDetect},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{ActionExpirationInSeconds: common.Int(376978),
FailureThreshold: common.Int(905269),
InteractionThreshold: common.Int(49),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(false),
Action: waas.HumanInteractionChallengeActionDetect,
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(477),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")},
FailureThresholdExpirationInSeconds: common.Int(307797),
RecordingPeriodInSeconds: common.Int(11728),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Description: common.String("EXAMPLE-description-Value"),
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionBlock}},
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{Action: waas.AccessRuleActionDetect,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Value: common.String("EXAMPLE-value-Value"),
Header: common.String("EXAMPLE-header-Value")}},
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(865),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIs,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
Name: common.String("EXAMPLE-name-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value")}},
GoodBots: []waas.GoodBot{waas.GoodBot{IsEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Description: common.String("EXAMPLE-description-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)
}