// 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("T71A4CJSRWIDZJPRW3XE<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWafConfigDetails: waas.WafConfig{AddressRateLimiting: &waas.AddressRateLimiting{MaxDelayedCountPerAddress: common.Int(4407),
AllowedRatePerAddress: common.Int(6811),
BlockResponseCode: common.Int(484),
IsEnabled: common.Bool(false)},
Captchas: []waas.Captcha{waas.Captcha{HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(175222),
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")}},
Origin: common.String("EXAMPLE-origin-Value"),
OriginGroups: []string{"EXAMPLE--Value"},
ProtectionSettings: &waas.ProtectionSettings{AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsConnect},
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
IsResponseInspected: common.Bool(false),
MaxNameLengthPerArgument: common.Int(95282),
MaxResponseSizeInKiB: common.Int(1295),
MaxTotalNameLengthOfArguments: common.Int(106858),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockResponseCode: common.Int(746),
MaxArgumentCount: common.Int(3269),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(59)},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionBlock,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Target: waas.ProtectionRuleExclusionTargetRequestCookieNames,
Exclusions: []string{"EXAMPLE--Value"}}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{FailureThresholdExpirationInSeconds: common.Int(196792),
IsEnabled: common.Bool(false),
MaxAddressCount: common.Int(9785),
MaxAddressCountExpirationInSeconds: common.Int(273409),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(128065),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockResponseCode: common.Int(461),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value")},
FailureThreshold: common.Int(88269)},
GoodBots: []waas.GoodBot{waas.GoodBot{Name: common.String("EXAMPLE-name-Value"),
Description: common.String("EXAMPLE-description-Value"),
IsEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value")}},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{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"},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionBlock,
Description: common.String("EXAMPLE-description-Value")}},
ThreatFeeds: []waas.ThreatFeed{waas.ThreatFeed{Action: waas.ThreatFeedActionOff,
Description: common.String("EXAMPLE-description-Value"),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
Whitelists: []waas.Whitelist{waas.Whitelist{Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"}}},
AccessRules: []waas.AccessRule{waas.AccessRule{BlockAction: waas.AccessRuleBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
Action: waas.AccessRuleActionBlock,
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesJsChallenge},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
Name: common.String("EXAMPLE-name-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently,
BlockResponseCode: common.Int(519),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlDoesNotMatchRegex,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.RemoveHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value")}}}},
CachingRules: []waas.CachingRule{waas.CachingRule{Criteria: []waas.CachingRuleCriteria{waas.CachingRuleCriteria{Condition: waas.CachingRuleCriteriaConditionStartsWith,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value"),
Action: waas.CachingRuleActionBypassCache,
CachingDuration: common.String("EXAMPLE-cachingDuration-Value"),
ClientCachingDuration: common.String("EXAMPLE-clientCachingDuration-Value")}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{InteractionThreshold: common.Int(80),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(11085),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(220522),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(492),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
Action: waas.HumanInteractionChallengeActionDetect,
FailureThreshold: common.Int(489191),
FailureThresholdExpirationInSeconds: common.Int(212750)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
FailureThreshold: common.Int(277410),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(true),
ActionExpirationInSeconds: common.Int(24797),
AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(717),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value"),
Condition: waas.AccessRuleCriteriaConditionUrlPartDoesNotContain}},
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-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)
}