// *** 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! *** import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; import * as utilities from "./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 SDK. The best practice, which this provider follows, * is to deactivate the Billing Meter by marking it as inactive on destroy, which indicates that resource is no longer * available. * * ## 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 * ``` */ export 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. */ public static get(name: string, id: pulumi.Input, state?: MeterState, opts?: pulumi.CustomResourceOptions): Meter { return new Meter(name, state, { ...opts, id: id }); } /** @internal */ public static readonly __pulumiType = 'stripe:index/meter:Meter'; /** * 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. */ public static isInstance(obj: any): obj is Meter { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Meter.__pulumiType; } /** * Lst(Resource). Fields that specify how to map a meter event to a customer. */ public readonly customerMapping!: pulumi.Output; /** * List(Resource). The default settings to aggregate a meter’s events with. */ public readonly defaultAggregation!: pulumi.Output; /** * String. The display name of the meter. */ public readonly displayName!: pulumi.Output; /** * String. The name of the meter event to record usage for. Corresponds with the `eventName` field on meter events. */ public readonly eventName!: pulumi.Output; /** * String. The time window to pre-aggregate meter events for, if any. Possible values are: */ public readonly eventTimeWindow!: pulumi.Output; /** * List(Resource). Fields that specify how to calculate a meter event’s value. */ public readonly valueSettings!: pulumi.Output; /** * Create a Meter resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: MeterArgs, opts?: pulumi.CustomResourceOptions) constructor(name: string, argsOrState?: MeterArgs | MeterState, opts?: pulumi.CustomResourceOptions) { let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState as MeterState | undefined; resourceInputs["customerMapping"] = state ? state.customerMapping : undefined; resourceInputs["defaultAggregation"] = state ? state.defaultAggregation : undefined; resourceInputs["displayName"] = state ? state.displayName : undefined; resourceInputs["eventName"] = state ? state.eventName : undefined; resourceInputs["eventTimeWindow"] = state ? state.eventTimeWindow : undefined; resourceInputs["valueSettings"] = state ? state.valueSettings : undefined; } else { const args = argsOrState as MeterArgs | undefined; if ((!args || args.defaultAggregation === undefined) && !opts.urn) { throw new Error("Missing required property 'defaultAggregation'"); } if ((!args || args.displayName === undefined) && !opts.urn) { throw new Error("Missing required property 'displayName'"); } if ((!args || args.eventName === undefined) && !opts.urn) { throw new Error("Missing required property 'eventName'"); } resourceInputs["customerMapping"] = args ? args.customerMapping : undefined; resourceInputs["defaultAggregation"] = args ? args.defaultAggregation : undefined; resourceInputs["displayName"] = args ? args.displayName : undefined; resourceInputs["eventName"] = args ? args.eventName : undefined; resourceInputs["eventTimeWindow"] = args ? args.eventTimeWindow : undefined; resourceInputs["valueSettings"] = args ? args.valueSettings : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Meter.__pulumiType, name, resourceInputs, opts); } } /** * Input properties used for looking up and filtering Meter resources. */ export interface MeterState { /** * Lst(Resource). Fields that specify how to map a meter event to a customer. */ customerMapping?: pulumi.Input; /** * List(Resource). The default settings to aggregate a meter’s events with. */ defaultAggregation?: pulumi.Input; /** * String. The display name of the meter. */ displayName?: pulumi.Input; /** * String. The name of the meter event to record usage for. Corresponds with the `eventName` field on meter events. */ eventName?: pulumi.Input; /** * String. The time window to pre-aggregate meter events for, if any. Possible values are: */ eventTimeWindow?: pulumi.Input; /** * List(Resource). Fields that specify how to calculate a meter event’s value. */ valueSettings?: pulumi.Input; } /** * The set of arguments for constructing a Meter resource. */ export interface MeterArgs { /** * Lst(Resource). Fields that specify how to map a meter event to a customer. */ customerMapping?: pulumi.Input; /** * List(Resource). The default settings to aggregate a meter’s events with. */ defaultAggregation: pulumi.Input; /** * String. The display name of the meter. */ displayName: pulumi.Input; /** * String. The name of the meter event to record usage for. Corresponds with the `eventName` field on meter events. */ eventName: pulumi.Input; /** * String. The time window to pre-aggregate meter events for, if any. Possible values are: */ eventTimeWindow?: pulumi.Input; /** * List(Resource). Fields that specify how to calculate a meter event’s value. */ valueSettings?: pulumi.Input; }