// 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).
import * as waas from "oci-waas";
import common = require("oci-common");
// 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.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new waas.WaasClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const updateWaasPolicyDetails = {
displayName: "EXAMPLE-displayName-Value",
additionalDomains: ["EXAMPLE--Value" ],
origins: {
EXAMPLE_KEY_tur3j :{
uri: "EXAMPLE-uri-Value",
httpPort: 8226,
httpsPort: 15367,
customHeaders: [{
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
],
}
},
originGroups: {
EXAMPLE_KEY_alPIV :{
origins: [{
origin: "EXAMPLE-origin-Value",
weight: 6081,
}
],
}
},
policyConfig: {
certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
isHttpsEnabled: true,
isHttpsForced: false,
tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV1 ],
isOriginCompressionEnabled: true,
isBehindCdn: false,
clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.XRealIp,
isCacheControlRespected: false,
isResponseBufferingEnabled: false,
cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
loadBalancingMethod: {
method: "ROUND_ROBIN",
}
,
websocketPathPrefixes: ["EXAMPLE--Value" ],
isSniEnabled: true,
healthChecks: {
isEnabled: true,
method: waas.models.HealthCheck.Method.Post,
path: "EXAMPLE-path-Value",
headers: {
EXAMPLE_KEY_Cf9PD :"EXAMPLE_VALUE_K13DANNNwevExocbyVqx"
},
expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._3Xx ],
isResponseTextCheckEnabled: true,
expectedResponseText: "EXAMPLE-expectedResponseText-Value",
intervalInSeconds: 82,
timeoutInSeconds: 30,
healthyThreshold: 4,
unhealthyThreshold: 5,
}
,
}
,
wafConfig: {
accessRules: [{
name: "EXAMPLE-name-Value",
criteria: [{
condition: waas.models.AccessRuleCriteria.Condition.CountryIsNot,
value: "EXAMPLE-value-Value",
isCaseSensitive: false,
}
],
action: waas.models.AccessRule.Action.Bypass,
blockAction: waas.models.AccessRule.BlockAction.ShowErrorPage,
blockResponseCode: 497,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
bypassChallenges: [waas.models.AccessRule.BypassChallenges.DeviceFingerprintChallenge ],
redirectUrl: "EXAMPLE-redirectUrl-Value",
redirectResponseCode: waas.models.AccessRule.RedirectResponseCode.MovedPermanently,
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
responseHeaderManipulation: [{
action: "ADD_HTTP_RESPONSE_HEADER", header: "EXAMPLE-header-Value",
value: "EXAMPLE-value-Value"
}
],
}
],
addressRateLimiting: {
isEnabled: true,
allowedRatePerAddress: 5552,
maxDelayedCountPerAddress: 3700,
blockResponseCode: 147,
}
,
captchas: [{
url: "EXAMPLE-url-Value",
sessionExpirationInSeconds: 122528,
title: "EXAMPLE-title-Value",
headerText: "EXAMPLE-headerText-Value",
footerText: "EXAMPLE-footerText-Value",
failureMessage: "EXAMPLE-failureMessage-Value",
submitLabel: "EXAMPLE-submitLabel-Value",
}
],
deviceFingerprintChallenge: {
isEnabled: true,
action: waas.models.DeviceFingerprintChallenge.Action.Block,
failureThreshold: 509449,
actionExpirationInSeconds: 243177,
failureThresholdExpirationInSeconds: 209518,
maxAddressCount: 7225,
maxAddressCountExpirationInSeconds: 224917,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
blockResponseCode: 894,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
}
,
}
,
goodBots: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
isEnabled: true,
description: "EXAMPLE-description-Value",
}
],
humanInteractionChallenge: {
isEnabled: false,
action: waas.models.HumanInteractionChallenge.Action.Block,
failureThreshold: 994781,
actionExpirationInSeconds: 345315,
failureThresholdExpirationInSeconds: 1824,
interactionThreshold: 57,
recordingPeriodInSeconds: 13335,
setHttpHeader: {
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
blockResponseCode: 469,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
}
,
isNatEnabled: true,
}
,
jsChallenge: {
isEnabled: false,
action: waas.models.JsChallenge.Action.Block,
failureThreshold: 439211,
actionExpirationInSeconds: 283764,
setHttpHeader: {
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
blockResponseCode: 438,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
}
,
areRedirectsChallenged: false,
criteria: [{
condition: waas.models.AccessRuleCriteria.Condition.UserAgentIs,
value: "EXAMPLE-value-Value",
isCaseSensitive: true,
}
],
isNatEnabled: true,
}
,
origin: "EXAMPLE-origin-Value",
cachingRules: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
action: waas.models.CachingRule.Action.BypassCache,
cachingDuration: "EXAMPLE-cachingDuration-Value",
isClientCachingEnabled: true,
clientCachingDuration: "EXAMPLE-clientCachingDuration-Value",
criteria: [{
condition: waas.models.CachingRuleCriteria.Condition.UrlIs,
value: "EXAMPLE-value-Value",
}
],
}
],
customProtectionRules: [{
id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
action: waas.models.CustomProtectionRuleSetting.Action.Detect,
exclusions: [{
target: waas.models.ProtectionRuleExclusion.Target.RequestCookies,
exclusions: ["EXAMPLE--Value" ],
}
],
}
],
originGroups: ["EXAMPLE--Value" ],
protectionRules: [{
key: "EXAMPLE-key-Value",
modSecurityRuleIds: ["EXAMPLE--Value" ],
name: "EXAMPLE-name-Value",
description: "EXAMPLE-description-Value",
action: waas.models.ProtectionRule.Action.Off,
labels: ["EXAMPLE--Value" ],
exclusions: [{
target: waas.models.ProtectionRuleExclusion.Target.Args,
exclusions: ["EXAMPLE--Value" ],
}
],
}
],
protectionSettings: {
blockAction: waas.models.ProtectionSettings.BlockAction.ShowErrorPage,
blockResponseCode: 220,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
maxArgumentCount: 6289,
maxNameLengthPerArgument: 85374,
maxTotalNameLengthOfArguments: 49070,
recommendationsPeriodInDays: 73,
isResponseInspected: true,
maxResponseSizeInKiB: 952,
allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Patch ],
mediaTypes: ["EXAMPLE--Value" ],
}
,
threatFeeds: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
action: waas.models.ThreatFeed.Action.Off,
description: "EXAMPLE-description-Value",
}
],
whitelists: [{
name: "EXAMPLE-name-Value",
addresses: ["EXAMPLE--Value" ],
addressLists: ["EXAMPLE--Value" ],
}
],
}
,
freeformTags: {
EXAMPLE_KEY_lxsuu :"EXAMPLE_VALUE_6IvQNjYlvdqIucgD8ibn"
},
definedTags: {
EXAMPLE_KEY_iD59E :{
EXAMPLE_KEY_2KlCk :"EXAMPLE--Value"
}
},
}
const updateWaasPolicyRequest: waas.requests.UpdateWaasPolicyRequest = {
waasPolicyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value",
updateWaasPolicyDetails: updateWaasPolicyDetails,
opcRequestId: "AEVXGDI3ERHF4XUROROH<unique_ID>",
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
ifMatch: "EXAMPLE-ifMatch-Value",
};
// Send request to the Client.
const updateWaasPolicyResponse = await client.updateWaasPolicy(updateWaasPolicyRequest);
}
catch (error) {
console.log("updateWaasPolicy Failed with error " + error);
}
})();