pulumi-stripe
Version:
A Pulumi package for creating and managing Stripe resources.
112 lines • 4.6 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Meter = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* With this resource, you can create a billing meter - [Stripe API billing meter documentation](https://docs.stripe.com/api/billing/meter).
*
* A billing meter is a resource that allows you to track usage of a particular event. For example, you might create a billing meter to track the number of API calls made by a particular user. You can then attach the billing meter to a price and attach the price to a subscription to charge the user for the number of API calls they make.
*
* Related guide: [Usage based billing](https://docs.stripe.com/billing/subscriptions/usage-based)
*
* > Removal of the Billing Meter isn't supported through the Stripe API.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as stripe from "pulumi-stripe";
*
* // meter
* const sampleMeter = new stripe.Meter("sampleMeter", {
* customerMapping: {
* eventPayloadKey: "stripe_customer_id",
* type: "by_id",
* },
* defaultAggregation: {
* formula: "sum",
* },
* displayName: "A Sample meter",
* eventName: "sample_meter",
* valueSettings: {
* eventPayloadKey: "value",
* },
* });
* ```
*
* ## Note on updating meters
*
* Once created, you can update the `displayName`.
*
* Other attribute edits will trigger a destroy action (archival) and creation of a new meter entry.
*
* ## Import
*
* ```sh
* $ pulumi import stripe:index/meter:Meter meter <meter_id>
* ```
*/
class Meter extends pulumi.CustomResource {
/**
* Get an existing Meter 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 Meter(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Meter. 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'] === Meter.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["customerMapping"] = state?.customerMapping;
resourceInputs["defaultAggregation"] = state?.defaultAggregation;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["eventName"] = state?.eventName;
resourceInputs["eventTimeWindow"] = state?.eventTimeWindow;
resourceInputs["valueSettings"] = state?.valueSettings;
}
else {
const args = argsOrState;
if (args?.defaultAggregation === undefined && !opts.urn) {
throw new Error("Missing required property 'defaultAggregation'");
}
if (args?.displayName === undefined && !opts.urn) {
throw new Error("Missing required property 'displayName'");
}
if (args?.eventName === undefined && !opts.urn) {
throw new Error("Missing required property 'eventName'");
}
resourceInputs["customerMapping"] = args?.customerMapping;
resourceInputs["defaultAggregation"] = args?.defaultAggregation;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["eventName"] = args?.eventName;
resourceInputs["eventTimeWindow"] = args?.eventTimeWindow;
resourceInputs["valueSettings"] = args?.valueSettings;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Meter.__pulumiType, name, resourceInputs, opts);
}
}
exports.Meter = Meter;
/** @internal */
Meter.__pulumiType = 'stripe:index/meter:Meter';
//# sourceMappingURL=meter.js.map