UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

93 lines 4.56 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.BackfillListResponsesPage = exports.Backfills = void 0; const resource_1 = require("../../resource.js"); const core_1 = require("../../core.js"); const pagination_1 = require("../../pagination.js"); class Backfills extends resource_1.APIResource { /** * Creating the backfill enables adding or replacing past events, even those that * are older than the ingestion grace period. Performing a backfill in Orb involves * 3 steps: * * 1. Create the backfill, specifying its parameters. * 2. [Ingest](ingest) usage events, referencing the backfill (query parameter * `backfill_id`). * 3. [Close](close-backfill) the backfill, propagating the update in past usage * throughout Orb. * * Changes from a backfill are not reflected until the backfill is closed, so you * won’t need to worry about your customers seeing partially updated usage data. * Backfills are also reversible, so you’ll be able to revert a backfill if you’ve * made a mistake. * * This endpoint will return a backfill object, which contains an `id`. That `id` * can then be used as the `backfill_id` query parameter to the event ingestion * endpoint to associate ingested events with this backfill. The effects (e.g. * updated usage graphs) of this backfill will not take place until the backfill is * closed. * * If the `replace_existing_events` is `true`, existing events in the backfill's * timeframe will be replaced with the newly ingested events associated with the * backfill. If `false`, newly ingested events will be added to the existing * events. * * If a `customer_id` or `external_customer_id` is specified, the backfill will * only affect events for that customer. If neither is specified, the backfill will * affect all customers. * * When `replace_existing_events` is `true`, this indicates that existing events in * the timeframe should no longer be counted towards invoiced usage. In this * scenario, the parameter `deprecation_filter` can be optionally added which * enables filtering using * [computed properties](/extensibility/advanced-metrics#computed-properties). The * expressiveness of computed properties allows you to deprecate existing events * based on both a period of time and specific property values. * * You may not have multiple backfills in a pending or pending_revert state with * overlapping timeframes. */ create(body, options) { return this._client.post('/events/backfills', { body, ...options }); } list(query = {}, options) { if ((0, core_1.isRequestOptions)(query)) { return this.list({}, query); } return this._client.getAPIList('/events/backfills', BackfillListResponsesPage, { query, ...options }); } /** * Closing a backfill makes the updated usage visible in Orb. Upon closing a * backfill, Orb will asynchronously reflect the updated usage in invoice amounts * and usage graphs. Once all of the updates are complete, the backfill's status * will transition to `reflected`. */ close(backfillId, options) { return this._client.post(`/events/backfills/${backfillId}/close`, options); } /** * This endpoint is used to fetch a backfill given an identifier. */ fetch(backfillId, options) { return this._client.get(`/events/backfills/${backfillId}`, options); } /** * Reverting a backfill undoes all the effects of closing the backfill. If the * backfill is reflected, the status will transition to `pending_revert` while the * effects of the backfill are undone. Once all effects are undone, the backfill * will transition to `reverted`. * * If a backfill is reverted before its closed, no usage will be updated as a * result of the backfill and it will immediately transition to `reverted`. */ revert(backfillId, options) { return this._client.post(`/events/backfills/${backfillId}/revert`, options); } } exports.Backfills = Backfills; class BackfillListResponsesPage extends pagination_1.Page { } exports.BackfillListResponsesPage = BackfillListResponsesPage; Backfills.BackfillListResponsesPage = BackfillListResponsesPage; //# sourceMappingURL=backfills.js.map