// 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_QwzBc: ({
uri: "EXAMPLE-uri-Value",
httpPort: 57670,
httpsPort: 17770,
customHeaders: [
({
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value"
} as unknown) as waas.models.Header
]
} as unknown) as waas.models.Origin
},
originGroups: {
EXAMPLE_KEY_Z86VU: ({
origins: [
({
origin: "EXAMPLE-origin-Value",
weight: 3490
} as unknown) as waas.models.OriginGroupOrigins
]
} as unknown) as waas.models.OriginGroup
},
policyConfig: ({
certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
isHttpsEnabled: true,
isHttpsForced: true,
tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV13],
isOriginCompressionEnabled: false,
isBehindCdn: true,
clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.XForwardedFor,
isCacheControlRespected: true,
isResponseBufferingEnabled: true,
cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
loadBalancingMethod: ({
method: "IP_HASH"
} as unknown) as waas.models.IPHashLoadBalancingMethod,
websocketPathPrefixes: ["EXAMPLE--Value"],
isSniEnabled: false,
healthChecks: ({
isEnabled: true,
method: waas.models.HealthCheck.Method.Head,
path: "EXAMPLE-path-Value",
headers: {
EXAMPLE_KEY_f2goi: "EXAMPLE_VALUE_HavBOhg3rBGeI5uexHhy"
},
expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._5Xx],
isResponseTextCheckEnabled: false,
expectedResponseText: "EXAMPLE-expectedResponseText-Value",
intervalInSeconds: 13,
timeoutInSeconds: 78,
healthyThreshold: 1,
unhealthyThreshold: 6
} as unknown) as waas.models.HealthCheck
} as unknown) as waas.models.PolicyConfig,
wafConfig: ({
accessRules: [
({
name: "EXAMPLE-name-Value",
criteria: [
({
condition: waas.models.AccessRuleCriteria.Condition.HttpHeaderContains,
value: "EXAMPLE-value-Value",
isCaseSensitive: false
} as unknown) as waas.models.AccessRuleCriteria
],
action: waas.models.AccessRule.Action.ShowCaptcha,
blockAction: waas.models.AccessRule.BlockAction.SetResponseCode,
blockResponseCode: 280,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
bypassChallenges: [waas.models.AccessRule.BypassChallenges.JsChallenge],
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"
} as unknown) as waas.models.AddHttpResponseHeaderAction
]
} as unknown) as waas.models.AccessRule
],
addressRateLimiting: ({
isEnabled: true,
allowedRatePerAddress: 2351,
maxDelayedCountPerAddress: 7366,
blockResponseCode: 118
} as unknown) as waas.models.AddressRateLimiting,
captchas: [
({
url: "EXAMPLE-url-Value",
sessionExpirationInSeconds: 7482,
title: "EXAMPLE-title-Value",
headerText: "EXAMPLE-headerText-Value",
footerText: "EXAMPLE-footerText-Value",
failureMessage: "EXAMPLE-failureMessage-Value",
submitLabel: "EXAMPLE-submitLabel-Value"
} as unknown) as waas.models.Captcha
],
deviceFingerprintChallenge: ({
isEnabled: true,
action: waas.models.DeviceFingerprintChallenge.Action.Detect,
failureThreshold: 267764,
actionExpirationInSeconds: 352669,
failureThresholdExpirationInSeconds: 297159,
maxAddressCount: 9080,
maxAddressCountExpirationInSeconds: 238639,
challengeSettings: ({
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
blockResponseCode: 927,
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"
} as unknown) as waas.models.BlockChallengeSettings
} as unknown) as waas.models.DeviceFingerprintChallenge,
humanInteractionChallenge: ({
isEnabled: false,
action: waas.models.HumanInteractionChallenge.Action.Block,
failureThreshold: 690376,
actionExpirationInSeconds: 393236,
failureThresholdExpirationInSeconds: 320146,
interactionThreshold: 66,
recordingPeriodInSeconds: 8590,
setHttpHeader: ({
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value"
} as unknown) as waas.models.Header,
challengeSettings: ({
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
blockResponseCode: 137,
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"
} as unknown) as waas.models.BlockChallengeSettings,
isNatEnabled: true
} as unknown) as waas.models.HumanInteractionChallenge,
jsChallenge: ({
isEnabled: true,
action: waas.models.JsChallenge.Action.Block,
failureThreshold: 292795,
actionExpirationInSeconds: 320817,
setHttpHeader: ({
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value"
} as unknown) as waas.models.Header,
challengeSettings: ({
blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
blockResponseCode: 555,
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"
} as unknown) as waas.models.BlockChallengeSettings,
areRedirectsChallenged: true,
criteria: [
({
condition: waas.models.AccessRuleCriteria.Condition.UrlRegex,
value: "EXAMPLE-value-Value",
isCaseSensitive: false
} as unknown) as waas.models.AccessRuleCriteria
],
isNatEnabled: false
} as unknown) as waas.models.JsChallenge,
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"
} as unknown) as waas.models.CachingRuleCriteria
]
} as unknown) as waas.models.CachingRule
],
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"]
} as unknown) as waas.models.ProtectionRuleExclusion
]
} as unknown) as waas.models.CustomProtectionRuleSetting
],
originGroups: ["EXAMPLE--Value"],
protectionSettings: ({
blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
blockResponseCode: 813,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
maxArgumentCount: 5828,
maxNameLengthPerArgument: 55400,
maxTotalNameLengthOfArguments: 198720,
recommendationsPeriodInDays: 73,
isResponseInspected: false,
maxResponseSizeInKiB: 1378,
allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Propfind],
mediaTypes: ["EXAMPLE--Value"]
} as unknown) as waas.models.ProtectionSettings,
whitelists: [
({
name: "EXAMPLE-name-Value",
addresses: ["EXAMPLE--Value"],
addressLists: ["EXAMPLE--Value"]
} as unknown) as waas.models.Whitelist
]
} as unknown) as waas.models.WafConfigDetails,
freeformTags: {
EXAMPLE_KEY_XqzJ2: "EXAMPLE_VALUE_Py5JfnFZnyotrpwITLXV"
},
definedTags: {
EXAMPLE_KEY_3gEve: {
EXAMPLE_KEY_xk9ri: "EXAMPLE--Value"
}
}
} as unknown) as waas.models.CreateWaasPolicyDetails;
const createWaasPolicyRequest: waas.requests.CreateWaasPolicyRequest = {
createWaasPolicyDetails: createWaasPolicyDetails,
opcRequestId: "RCFQUV2SKBQ5YM2HBPEL<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);
}
})();