@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
141 lines • 6.54 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThrottlingPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an APIG (API) throttling policy resource within HuaweiCloud.
*
* ## Example Usage
* ### Create a basic throttling policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const instanceId = config.requireObject("instanceId");
* const policyName = config.requireObject("policyName");
* const description = config.requireObject("description");
* const test = new huaweicloud.dedicatedapig.ThrottlingPolicy("test", {
* instanceId: instanceId,
* description: description,
* type: "API-based",
* period: 10,
* periodUnit: "MINUTE",
* maxApiRequests: 70,
* maxUserRequests: 45,
* maxAppRequests: 45,
* maxIpRequests: 45,
* });
* ```
* ### Create a throttling policy with a special throttle
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const instanceId = config.requireObject("instanceId");
* const policyName = config.requireObject("policyName");
* const applicationId = config.requireObject("applicationId");
* const test = new huaweicloud.dedicatedapig.ThrottlingPolicy("test", {
* instanceId: instanceId,
* type: "API-based",
* period: 10,
* periodUnit: "MINUTE",
* maxApiRequests: 70,
* appThrottles: [{
* maxApiRequests: 40,
* throttlingObjectId: applicationId,
* }],
* });
* ```
*
* ## Import
*
* API Throttling Policies can be imported using their `name` and related dedicated instance ID, separated by a slash, e.g.
*
* ```sh
* $ pulumi import huaweicloud:DedicatedApig/throttlingPolicy:ThrottlingPolicy test <instance_id>/<name>
* ```
*/
class ThrottlingPolicy extends pulumi.CustomResource {
/**
* Get an existing ThrottlingPolicy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new ThrottlingPolicy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of ThrottlingPolicy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ThrottlingPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["appThrottles"] = state ? state.appThrottles : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["instanceId"] = state ? state.instanceId : undefined;
resourceInputs["maxApiRequests"] = state ? state.maxApiRequests : undefined;
resourceInputs["maxAppRequests"] = state ? state.maxAppRequests : undefined;
resourceInputs["maxIpRequests"] = state ? state.maxIpRequests : undefined;
resourceInputs["maxUserRequests"] = state ? state.maxUserRequests : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["period"] = state ? state.period : undefined;
resourceInputs["periodUnit"] = state ? state.periodUnit : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["type"] = state ? state.type : undefined;
resourceInputs["userThrottles"] = state ? state.userThrottles : undefined;
}
else {
const args = argsOrState;
if ((!args || args.instanceId === undefined) && !opts.urn) {
throw new Error("Missing required property 'instanceId'");
}
if ((!args || args.maxApiRequests === undefined) && !opts.urn) {
throw new Error("Missing required property 'maxApiRequests'");
}
if ((!args || args.period === undefined) && !opts.urn) {
throw new Error("Missing required property 'period'");
}
resourceInputs["appThrottles"] = args ? args.appThrottles : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["instanceId"] = args ? args.instanceId : undefined;
resourceInputs["maxApiRequests"] = args ? args.maxApiRequests : undefined;
resourceInputs["maxAppRequests"] = args ? args.maxAppRequests : undefined;
resourceInputs["maxIpRequests"] = args ? args.maxIpRequests : undefined;
resourceInputs["maxUserRequests"] = args ? args.maxUserRequests : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["period"] = args ? args.period : undefined;
resourceInputs["periodUnit"] = args ? args.periodUnit : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["type"] = args ? args.type : undefined;
resourceInputs["userThrottles"] = args ? args.userThrottles : undefined;
resourceInputs["createdAt"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ThrottlingPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.ThrottlingPolicy = ThrottlingPolicy;
/** @internal */
ThrottlingPolicy.__pulumiType = 'huaweicloud:DedicatedApig/throttlingPolicy:ThrottlingPolicy';
//# sourceMappingURL=throttlingPolicy.js.map