// 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 createWaasPolicyDetails = {
compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
displayName: "EXAMPLE-displayName-Value",
domain: "EXAMPLE-domain-Value",
additionalDomains: ["EXAMPLE--Value" ],
origins: {
EXAMPLE_KEY_b6Gj1 :{
uri: "EXAMPLE-uri-Value",
httpPort: 55119,
httpsPort: 42485,
customHeaders: [{
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
],
}
},
originGroups: {
EXAMPLE_KEY_tfAtd :{
origins: [{
origin: "EXAMPLE-origin-Value",
weight: 4211,
}
],
}
},
policyConfig: {
certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
isHttpsEnabled: false,
isHttpsForced: true,
tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV13 ],
isOriginCompressionEnabled: false,
isBehindCdn: false,
clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.XForwardedFor,
isCacheControlRespected: true,
isResponseBufferingEnabled: false,
cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
loadBalancingMethod: {
method: "STICKY_COOKIE", name: "EXAMPLE-name-Value",
domain: "EXAMPLE-domain-Value",
expirationTimeInSeconds: 12899217
}
,
websocketPathPrefixes: ["EXAMPLE--Value" ],
isSniEnabled: true,
healthChecks: {
isEnabled: false,
method: waas.models.HealthCheck.Method.Get,
path: "EXAMPLE-path-Value",
headers: {
EXAMPLE_KEY_Z2aaC :"EXAMPLE_VALUE_Yx9GhmON98Vj2b0GYa60"
},
expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._2Xx ],
isResponseTextCheckEnabled: false,
expectedResponseText: "EXAMPLE-expectedResponseText-Value",
intervalInSeconds: 53,
timeoutInSeconds: 103,
healthyThreshold: 7,
unhealthyThreshold: 12,
}
,
}
,
wafConfig: {
accessRules: [{
name: "EXAMPLE-name-Value",
criteria: [{
condition: waas.models.AccessRuleCriteria.Condition.UrlPartContains,
value: "EXAMPLE-value-Value",
isCaseSensitive: false,
}
],
action: waas.models.AccessRule.Action.Detect,
blockAction: waas.models.AccessRule.BlockAction.SetResponseCode,
blockResponseCode: 697,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
bypassChallenges: [waas.models.AccessRule.BypassChallenges.HumanInteractionChallenge ],
redirectUrl: "EXAMPLE-redirectUrl-Value",
redirectResponseCode: waas.models.AccessRule.RedirectResponseCode.Found,
captchaTitle: "EXAMPLE-captchaTitle-Value",
captchaHeader: "EXAMPLE-captchaHeader-Value",
captchaFooter: "EXAMPLE-captchaFooter-Value",
captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
responseHeaderManipulation: [{
action: "REMOVE_HTTP_RESPONSE_HEADER", header: "EXAMPLE-header-Value"
}
],
}
],
addressRateLimiting: {
isEnabled: false,
allowedRatePerAddress: 8099,
maxDelayedCountPerAddress: 8923,
blockResponseCode: 996,
}
,
captchas: [{
url: "EXAMPLE-url-Value",
sessionExpirationInSeconds: 193740,
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: 439756,
actionExpirationInSeconds: 311748,
failureThresholdExpirationInSeconds: 11556,
maxAddressCount: 8324,
maxAddressCountExpirationInSeconds: 426393,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
blockResponseCode: 362,
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",
}
,
}
,
humanInteractionChallenge: {
isEnabled: true,
action: waas.models.HumanInteractionChallenge.Action.Detect,
failureThreshold: 768648,
actionExpirationInSeconds: 15820,
failureThresholdExpirationInSeconds: 196628,
interactionThreshold: 51,
recordingPeriodInSeconds: 8730,
setHttpHeader: {
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
blockResponseCode: 863,
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: false,
}
,
jsChallenge: {
isEnabled: false,
action: waas.models.JsChallenge.Action.Block,
failureThreshold: 940117,
actionExpirationInSeconds: 295544,
setHttpHeader: {
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value",
}
,
challengeSettings: {
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
blockResponseCode: 552,
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.UrlIsNot,
value: "EXAMPLE-value-Value",
isCaseSensitive: true,
}
],
isNatEnabled: false,
}
,
origin: "EXAMPLE-origin-Value",
cachingRules: [{
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
action: waas.models.CachingRule.Action.BypassCache,
cachingDuration: "EXAMPLE-cachingDuration-Value",
isClientCachingEnabled: false,
clientCachingDuration: "EXAMPLE-clientCachingDuration-Value",
criteria: [{
condition: waas.models.CachingRuleCriteria.Condition.UrlPartContains,
value: "EXAMPLE-value-Value",
}
],
}
],
customProtectionRules: [{
id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
action: waas.models.CustomProtectionRuleSetting.Action.Block,
exclusions: [{
target: waas.models.ProtectionRuleExclusion.Target.ArgsNames,
exclusions: ["EXAMPLE--Value" ],
}
],
}
],
originGroups: ["EXAMPLE--Value" ],
protectionSettings: {
blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
blockResponseCode: 339,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
maxArgumentCount: 3163,
maxNameLengthPerArgument: 136076,
maxTotalNameLengthOfArguments: 256549,
recommendationsPeriodInDays: 52,
isResponseInspected: true,
maxResponseSizeInKiB: 75,
allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Head ],
mediaTypes: ["EXAMPLE--Value" ],
}
,
whitelists: [{
name: "EXAMPLE-name-Value",
addresses: ["EXAMPLE--Value" ],
addressLists: ["EXAMPLE--Value" ],
}
],
}
,
freeformTags: {
EXAMPLE_KEY_mO7up :"EXAMPLE_VALUE_VMFjH2PNQfq72AZ1Up1r"
},
definedTags: {
EXAMPLE_KEY_RXkSO :{
EXAMPLE_KEY_3JzsY :"EXAMPLE--Value"
}
},
}
const createWaasPolicyRequest: waas.requests.CreateWaasPolicyRequest = {
createWaasPolicyDetails: createWaasPolicyDetails,
opcRequestId: "SDZDFIACXUVB9TBDT7F8<unique_ID>",
opcRetryToken: "EXAMPLE-opcRetryToken-Value",
};
// Send request to the Client.
const createWaasPolicyResponse = await client.createWaasPolicy(createWaasPolicyRequest);
}
catch (error) {
console.log("createWaasPolicy Failed with error " + error);
}
})();