// 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("3KEK8AQVNK1Z6OBEFOLQ<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWafConfigDetails: waas.WafConfig{AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionShowCaptcha,
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Name: common.String("EXAMPLE-name-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpIs,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(951),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesCaptcha},
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeFound,
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}}}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCountExpirationInSeconds: common.Int(364790),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(5540),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(431),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value")},
FailureThreshold: common.Int(945611),
FailureThresholdExpirationInSeconds: common.Int(90121),
IsEnabled: common.Bool(true),
MaxAddressCount: common.Int(5823)},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value"),
Action: waas.CustomProtectionRuleSettingActionDetect,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookieNames}}}},
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)}},
HumanInteractionChallenge: &waas.HumanInteractionChallenge{FailureThreshold: common.Int(612237),
IsEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(8591),
ActionExpirationInSeconds: common.Int(105664),
ChallengeSettings: &waas.BlockChallengeSettings{BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(439),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
FailureThresholdExpirationInSeconds: common.Int(144130),
InteractionThreshold: common.Int(13),
IsNatEnabled: common.Bool(true),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
Action: waas.HumanInteractionChallengeActionBlock},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Action: waas.ProtectionRuleActionBlock,
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")}},
ProtectionSettings: &waas.ProtectionSettings{RecommendationsPeriodInDays: common.Int(91),
BlockAction: waas.ProtectionSettingsBlockActionSetResponseCode,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(807),
MaxArgumentCount: common.Int(1209),
MaxNameLengthPerArgument: common.Int(102417),
MaxTotalNameLengthOfArguments: common.Int(353248),
MediaTypes: []string{"EXAMPLE--Value"},
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsHead},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
IsResponseInspected: common.Bool(true),
MaxResponseSizeInKiB: common.Int(1215)},
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")}},
Whitelists: []waas.Whitelist{waas.Whitelist{AddressLists: []string{"EXAMPLE--Value"},
Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value")}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(2635),
BlockResponseCode: common.Int(195),
IsEnabled: common.Bool(true),
MaxDelayedCountPerAddress: common.Int(7872)},
JsChallenge: &waas.JsChallenge{AreRedirectsChallenged: common.Bool(false),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUserAgentIs,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(52435),
IsNatEnabled: common.Bool(false),
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")},
ActionExpirationInSeconds: common.Int(431234),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockResponseCode: common.Int(569),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
IsEnabled: common.Bool(true),
Action: waas.JsChallengeActionBlock},
Origin: common.String("EXAMPLE-origin-Value"),
CachingRules: []waas.CachingRule{waas.CachingRule{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.CachingRuleCriteriaConditionStartsWith,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value")}},
Captchas: []waas.Captcha{waas.Captcha{FooterText: common.String("EXAMPLE-footerText-Value"),
HeaderText: common.String("EXAMPLE-headerText-Value"),
SessionExpirationInSeconds: common.Int(49921),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value"),
FailureMessage: common.String("EXAMPLE-failureMessage-Value")}},
OriginGroups: []string{"EXAMPLE--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)
}