// 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{OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWafConfigDetails: waas.WafConfig{ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionBlock,
Description: common.String("EXAMPLE-description-Value"),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(7482),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockResponseCode: common.Int(486),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")},
FailureThreshold: common.Int(487866),
FailureThresholdExpirationInSeconds: common.Int(345372),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(2400),
MaxAddressCountExpirationInSeconds: common.Int(348876)},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(4649),
BlockResponseCode: common.Int(747),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(1078)},
Captchas: []waas.Captcha{waas.Captcha{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(231194),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value")}},
JsChallenge: &waas.JsChallenge{Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(987160),
Action: waas.JsChallengeActionBlock,
AreRedirectsChallenged: common.Bool(true),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(626),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(410841)},
OriginGroups: []string{"EXAMPLE--Value"},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockAction: waas.AccessRuleBlockActionSetResponseCode,
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
Action: waas.AccessRuleActionDetect,
Name: common.String("EXAMPLE-name-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(613),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesDeviceFingerprintChallenge},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlIs,
IsCaseSensitive: common.Bool(true),
Value: common.String("EXAMPLE-value-Value")}}}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
Action: waas.CustomProtectionRuleSettingActionDetect}},
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.ProtectionRuleActionDetect,
Description: common.String("EXAMPLE-description-Value"),
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgs}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"}}},
ProtectionSettings: &waas.ProtectionSettings{MaxResponseSizeInKiB: common.Int(1578),
MaxTotalNameLengthOfArguments: common.Int(142122),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(6),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
IsResponseInspected: common.Bool(true),
MaxNameLengthPerArgument: common.Int(48256),
MaxArgumentCount: common.Int(7972),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsPatch},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(743)},
Whitelists: []waas.Whitelist{waas.Whitelist{Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"}}},
CachingRules: []waas.CachingRule{waas.CachingRule{Key: common.String("EXAMPLE-key-Value"),
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{Condition: waas.CachingRuleCriteriaConditionIs,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true)}},
Origin: common.String("EXAMPLE-origin-Value"),
HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThreshold: common.Int(864939),
FailureThresholdExpirationInSeconds: common.Int(291036),
IsEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.HumanInteractionChallengeActionDetect,
ActionExpirationInSeconds: common.Int(422964),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(834),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
InteractionThreshold: common.Int(68),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(9029)}},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value"),
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("XQZJ2PY5JFNFZNYOTRPW<unique_ID>")}
// 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)
}