// 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 ExampleUpdateWaasPolicy() {
// 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.UpdateWaasPolicyRequest{IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("PYNYUFLFUZGRECXMGX96<unique_ID>"),
OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
UpdateWaasPolicyDetails: waas.UpdateWaasPolicyDetails{DisplayName: common.String("EXAMPLE-displayName-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_8GH3K": "EXAMPLE_VALUE_JxIvDxd9CQA9HVva85QD"},
OriginGroups: map[string]waas.OriginGroup{"EXAMPLE_KEY_wHiRW": waas.OriginGroup{Origins: []waas.OriginGroupOrigins{waas.OriginGroupOrigins{Weight: common.Int(323),
Origin: common.String("EXAMPLE-origin-Value")}}}},
Origins: map[string]waas.Origin{"EXAMPLE_KEY_wMl22": waas.Origin{Uri: common.String("EXAMPLE-uri-Value"),
CustomHeaders: []waas.Header{waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
HttpPort: common.Int(4987),
HttpsPort: common.Int(28510)}},
PolicyConfig: &waas.PolicyConfig{CertificateId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value"),
CipherGroup: waas.PolicyConfigCipherGroupDefault,
HealthChecks: &waas.HealthCheck{Headers: map[string]string{"EXAMPLE_KEY_BIrAm": "EXAMPLE_VALUE_VtnLaodqvfhff8YYp1Zm"},
HealthyThreshold: common.Int(7),
IntervalInSeconds: common.Int(114),
IsEnabled: common.Bool(false),
Path: common.String("EXAMPLE-path-Value"),
ExpectedResponseCodeGroup: []waas.HealthCheckExpectedResponseCodeGroupEnum{waas.HealthCheckExpectedResponseCodeGroup2xx},
ExpectedResponseText: common.String("EXAMPLE-expectedResponseText-Value"),
IsResponseTextCheckEnabled: common.Bool(false),
Method: waas.HealthCheckMethodHead,
TimeoutInSeconds: common.Int(66),
UnhealthyThreshold: common.Int(18)},
IsBehindCdn: common.Bool(false),
IsHttpsForced: common.Bool(false),
LoadBalancingMethod: waas.StickyCookieLoadBalancingMethod{Name: common.String("EXAMPLE-name-Value"),
Domain: common.String("EXAMPLE-domain-Value"),
ExpirationTimeInSeconds: common.Int(8.283082e+06)},
TlsProtocols: []waas.PolicyConfigTlsProtocolsEnum{waas.PolicyConfigTlsProtocolsV12},
WebsocketPathPrefixes: []string{"EXAMPLE--Value"},
ClientAddressHeader: waas.PolicyConfigClientAddressHeaderClientIp,
IsCacheControlRespected: common.Bool(true),
IsHttpsEnabled: common.Bool(true),
IsOriginCompressionEnabled: common.Bool(true),
IsResponseBufferingEnabled: common.Bool(true),
IsSniEnabled: common.Bool(true)},
WafConfig: &waas.WafConfig{HumanInteractionChallenge: &waas.HumanInteractionChallenge{SetHttpHeader: &waas.Header{Value: common.String("EXAMPLE-value-Value"),
Name: common.String("EXAMPLE-name-Value")},
Action: waas.HumanInteractionChallengeActionBlock,
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionSetResponseCode,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockResponseCode: common.Int(127)},
InteractionThreshold: common.Int(21),
IsEnabled: common.Bool(true),
RecordingPeriodInSeconds: common.Int(10661),
ActionExpirationInSeconds: common.Int(3567),
FailureThreshold: common.Int(907476),
FailureThresholdExpirationInSeconds: common.Int(169283),
IsNatEnabled: common.Bool(true)},
ProtectionRules: []waas.ProtectionRule{waas.ProtectionRule{Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetArgsNames}},
Key: common.String("EXAMPLE-key-Value"),
Labels: []string{"EXAMPLE--Value"},
ModSecurityRuleIds: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
Action: waas.ProtectionRuleActionOff,
Description: common.String("EXAMPLE-description-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")}},
Origin: common.String("EXAMPLE-origin-Value"),
ProtectionSettings: &waas.ProtectionSettings{IsResponseInspected: common.Bool(false),
MaxArgumentCount: common.Int(8193),
MaxTotalNameLengthOfArguments: common.Int(86330),
MediaTypes: []string{"EXAMPLE--Value"},
RecommendationsPeriodInDays: common.Int(16),
AllowedHttpMethods: []waas.ProtectionSettingsAllowedHttpMethodsEnum{waas.ProtectionSettingsAllowedHttpMethodsGet},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
MaxNameLengthPerArgument: common.Int(63947),
MaxResponseSizeInKiB: common.Int(1915),
BlockAction: waas.ProtectionSettingsBlockActionShowErrorPage,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(987)},
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")}},
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(431479),
SubmitLabel: common.String("EXAMPLE-submitLabel-Value"),
Title: common.String("EXAMPLE-title-Value"),
Url: common.String("EXAMPLE-url-Value")}},
DeviceFingerprintChallenge: &waas.DeviceFingerprintChallenge{MaxAddressCount: common.Int(9733),
MaxAddressCountExpirationInSeconds: common.Int(203508),
Action: waas.DeviceFingerprintChallengeActionBlock,
ActionExpirationInSeconds: common.Int(116669),
ChallengeSettings: &waas.BlockChallengeSettings{BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(529),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value")},
FailureThreshold: common.Int(660186),
FailureThresholdExpirationInSeconds: common.Int(290906),
IsEnabled: common.Bool(false)},
JsChallenge: &waas.JsChallenge{Action: waas.JsChallengeActionDetect,
ActionExpirationInSeconds: common.Int(418876),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionIpInList,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
FailureThreshold: common.Int(408094),
IsEnabled: common.Bool(false),
IsNatEnabled: common.Bool(true),
AreRedirectsChallenged: common.Bool(false),
ChallengeSettings: &waas.BlockChallengeSettings{CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(595),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
BlockAction: waas.BlockChallengeSettingsBlockActionShowErrorPage,
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value")},
SetHttpHeader: &waas.Header{Name: common.String("EXAMPLE-name-Value"),
Value: common.String("EXAMPLE-value-Value")}},
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.CachingRuleCriteriaConditionPartContains,
Value: common.String("EXAMPLE-value-Value")}},
IsClientCachingEnabled: common.Bool(true),
Key: common.String("EXAMPLE-key-Value"),
Name: common.String("EXAMPLE-name-Value")}},
OriginGroups: []string{"EXAMPLE--Value"},
Whitelists: []waas.Whitelist{waas.Whitelist{Addresses: []string{"EXAMPLE--Value"},
Name: common.String("EXAMPLE-name-Value"),
AddressLists: []string{"EXAMPLE--Value"}}},
AccessRules: []waas.AccessRule{waas.AccessRule{Action: waas.AccessRuleActionRedirect,
RedirectUrl: common.String("EXAMPLE-redirectUrl-Value"),
BlockAction: waas.AccessRuleBlockActionShowErrorPage,
BlockErrorPageMessage: common.String("EXAMPLE-blockErrorPageMessage-Value"),
BlockResponseCode: common.Int(822),
BypassChallenges: []waas.AccessRuleBypassChallengesEnum{waas.AccessRuleBypassChallengesHumanInteractionChallenge},
CaptchaFooter: common.String("EXAMPLE-captchaFooter-Value"),
CaptchaTitle: common.String("EXAMPLE-captchaTitle-Value"),
Criteria: []waas.AccessRuleCriteria{waas.AccessRuleCriteria{Condition: waas.AccessRuleCriteriaConditionUrlPartEndsWith,
IsCaseSensitive: common.Bool(false),
Value: common.String("EXAMPLE-value-Value")}},
ResponseHeaderManipulation: []waas.HeaderManipulationAction{waas.AddHttpResponseHeaderAction{Header: common.String("EXAMPLE-header-Value"),
Value: common.String("EXAMPLE-value-Value")}},
BlockErrorPageCode: common.String("EXAMPLE-blockErrorPageCode-Value"),
BlockErrorPageDescription: common.String("EXAMPLE-blockErrorPageDescription-Value"),
CaptchaHeader: common.String("EXAMPLE-captchaHeader-Value"),
CaptchaSubmitLabel: common.String("EXAMPLE-captchaSubmitLabel-Value"),
Name: common.String("EXAMPLE-name-Value"),
RedirectResponseCode: waas.AccessRuleRedirectResponseCodeMovedPermanently}},
AddressRateLimiting: &waas.AddressRateLimiting{AllowedRatePerAddress: common.Int(9201),
BlockResponseCode: common.Int(940),
IsEnabled: common.Bool(false),
MaxDelayedCountPerAddress: common.Int(9038)},
CustomProtectionRules: []waas.CustomProtectionRuleSetting{waas.CustomProtectionRuleSetting{Action: waas.CustomProtectionRuleSettingActionDetect,
Exclusions: []waas.ProtectionRuleExclusion{waas.ProtectionRuleExclusion{Exclusions: []string{"EXAMPLE--Value"},
Target: waas.ProtectionRuleExclusionTargetRequestCookies}},
Id: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value")}}},
AdditionalDomains: []string{"EXAMPLE--Value"},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_KVyR9": map[string]interface{}{"EXAMPLE_KEY_UIOCD": "EXAMPLE--Value"}}},
WaasPolicyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value")}
// Send the request using the service client
resp, err := client.UpdateWaasPolicy(context.Background(), req)
helpers.FatalIfError(err)
// Retrieve value from the response.
fmt.Println(resp)
}