// 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("RW75SQK8LIZEGANNOKRL<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWafConfigDetails: waas.WafConfig{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.ThreatFeedActionBlock}},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgs}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
OriginGroups: []string{"EXAMPLE--Value"},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(145060),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(9481),
MaxAddressCountExpirationInSeconds: common.Int(49346),
Action: waas.DeviceFingerprintChallengeActionDetect,
ActionExpirationInSeconds: common.Int(224166),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(917),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
FailureThreshold: common.Int(714445)},
JsChallenge: &waas.JsChallenge{ActionExpirationInSeconds: common.Int(349379),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(151)},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionCountryIs,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(448539),
Action: waas.JsChallengeActionBlock,
AreRedirectsChallenged: common.Bool(false),
IsEnabled: common.Bool(true),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
Origin: common.String("EXAMPLE-origin-Value"),
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{ModSecurityRuleIds: []string{"EXAMPLE--Value"},
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.ProtectionRuleExclusionTargetArgs}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"}}},
ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(869),
MediaTypes: []string{"EXAMPLE--Value"},
MaxResponseSizeInKiB: common.Int(1372),
MaxTotalNameLengthOfArguments: common.Int(354276),
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
IsResponseInspected: common.Bool(false),
MaxArgumentCount: common.Int(8055),
MaxNameLengthPerArgument: common.Int(80120),
RecommendationsPeriodInDays: common.Int(92)},
AccessRules: []waas.AccessRule{waas.AccessRule{CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}},
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(553),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
Action: waas.AccessRuleActionBypass,
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionIpInList,
IsCaseSensitive: common.Bool(false)}},
Name: common.String("EXAMPLE-name-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{BlockResponseCode: common.Int(432),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(351),
AllowedRatePerAddress: common.Int(2332)},
CachingRules: []waas.CachingRule{waas.CachingRule{ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value"),
Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionIs,
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")}},
Captchas: []waas.Captcha{waas.Captcha{SessionExpirationInSeconds: common.Int(39032),
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")}},
GoodBots: []waas.GoodBot{waas.GoodBot{Description: common.String("EXAMPLE-description-Value"),
IsEnabled: common.Bool(false),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{ChallengeSettings: &waas.BlockChallengeSettings{CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockResponseCode: common.Int(721),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowCaptcha,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
FailureThreshold: common.Int(532936),
FailureThresholdExpirationInSeconds: common.Int(30160),
InteractionThreshold: common.Int(90),
RecordingPeriodInSeconds: common.Int(5825),
Action: waas.HumanInteractionChallengeActionBlock,
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(225623)}},
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)
}