// 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_IxP1c: ({
uri: "EXAMPLE-uri-Value",
httpPort: 57554,
httpsPort: 22756,
customHeaders: [
({
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value"
} as unknown) as waas.models.Header
]
} as unknown) as waas.models.Origin
},
originGroups: {
EXAMPLE_KEY_NBW0n: ({
origins: [
({
origin: "EXAMPLE-origin-Value",
weight: 298
} 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.TlsV11],
isOriginCompressionEnabled: false,
isBehindCdn: true,
clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.XRealIp,
isCacheControlRespected: false,
isResponseBufferingEnabled: true,
cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
loadBalancingMethod: ({
method: "STICKY_COOKIE",
name: "EXAMPLE-name-Value",
domain: "EXAMPLE-domain-Value",
expirationTimeInSeconds: 7782073
} as unknown) as waas.models.StickyCookieLoadBalancingMethod,
websocketPathPrefixes: ["EXAMPLE--Value"],
isSniEnabled: true,
healthChecks: ({
isEnabled: false,
method: waas.models.HealthCheck.Method.Post,
path: "EXAMPLE-path-Value",
headers: {
EXAMPLE_KEY_wIDZJ: "EXAMPLE_VALUE_prw3xE4sJf3YPKbX2tfA"
},
expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._5Xx],
isResponseTextCheckEnabled: false,
expectedResponseText: "EXAMPLE-expectedResponseText-Value",
intervalInSeconds: 116,
timeoutInSeconds: 8,
healthyThreshold: 18,
unhealthyThreshold: 3
} as unknown) as waas.models.HealthCheck
} as unknown) as waas.models.PolicyConfig,
wafConfig: ({
accessRules: [
({
name: "EXAMPLE-name-Value",
criteria: [
({
condition: waas.models.AccessRuleCriteria.Condition.UserAgentIsNot,
value: "EXAMPLE-value-Value",
isCaseSensitive: true
} as unknown) as waas.models.AccessRuleCriteria
],
action: waas.models.AccessRule.Action.Block,
blockAction: waas.models.AccessRule.BlockAction.SetResponseCode,
blockResponseCode: 245,
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: "REMOVE_HTTP_RESPONSE_HEADER",
header: "EXAMPLE-header-Value"
} as unknown) as waas.models.RemoveHttpResponseHeaderAction
]
} as unknown) as waas.models.AccessRule
],
addressRateLimiting: ({
isEnabled: false,
allowedRatePerAddress: 9250,
maxDelayedCountPerAddress: 9897,
blockResponseCode: 955
} as unknown) as waas.models.AddressRateLimiting,
captchas: [
({
url: "EXAMPLE-url-Value",
sessionExpirationInSeconds: 258245,
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.Block,
failureThreshold: 808269,
actionExpirationInSeconds: 176918,
failureThresholdExpirationInSeconds: 417215,
maxAddressCount: 7810,
maxAddressCountExpirationInSeconds: 302865,
challengeSettings: ({
blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
blockResponseCode: 937,
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: 283822,
actionExpirationInSeconds: 131885,
failureThresholdExpirationInSeconds: 116807,
interactionThreshold: 43,
recordingPeriodInSeconds: 11418,
setHttpHeader: ({
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value"
} as unknown) as waas.models.Header,
challengeSettings: ({
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
blockResponseCode: 480,
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: false
} as unknown) as waas.models.HumanInteractionChallenge,
jsChallenge: ({
isEnabled: false,
action: waas.models.JsChallenge.Action.Block,
failureThreshold: 389943,
actionExpirationInSeconds: 272015,
setHttpHeader: ({
name: "EXAMPLE-name-Value",
value: "EXAMPLE-value-Value"
} as unknown) as waas.models.Header,
challengeSettings: ({
blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
blockResponseCode: 631,
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.HttpMethodIs,
value: "EXAMPLE-value-Value",
isCaseSensitive: true
} as unknown) as waas.models.AccessRuleCriteria
],
isNatEnabled: true
} as unknown) as waas.models.JsChallenge,
origin: "EXAMPLE-origin-Value",
cachingRules: [
({
key: "EXAMPLE-key-Value",
name: "EXAMPLE-name-Value",
action: waas.models.CachingRule.Action.Cache,
cachingDuration: "EXAMPLE-cachingDuration-Value",
isClientCachingEnabled: false,
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.RequestCookieNames,
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: 634,
blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
maxArgumentCount: 6126,
maxNameLengthPerArgument: 39585,
maxTotalNameLengthOfArguments: 1932,
recommendationsPeriodInDays: 20,
isResponseInspected: false,
maxResponseSizeInKiB: 640,
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_MTwf6: "EXAMPLE_VALUE_geWdnJ3Wb6Lwzhv10HRV"
},
definedTags: {
EXAMPLE_KEY_NsngZ: {
EXAMPLE_KEY_ubnvw: "EXAMPLE--Value"
}
}
} as unknown) as waas.models.CreateWaasPolicyDetails;
const createWaasPolicyRequest: waas.requests.CreateWaasPolicyRequest = {
createWaasPolicyDetails: createWaasPolicyDetails,
opcRequestId: "PDFFVLJC1GOVMXBKQS7R<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);
}
})();