orb-billing
Version:
The official TypeScript library for the Orb API
90 lines • 4.25 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../resource.mjs";
import { isRequestOptions } from "../core.mjs";
import { Page } from "../pagination.mjs";
export class Alerts extends APIResource {
/**
* This endpoint retrieves an alert by its ID.
*/
retrieve(alertId, options) {
return this._client.get(`/alerts/${alertId}`, options);
}
/**
* This endpoint updates the thresholds of an alert.
*/
update(alertConfigurationId, body, options) {
return this._client.put(`/alerts/${alertConfigurationId}`, { body, ...options });
}
list(query = {}, options) {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/alerts', AlertsPage, { query, ...options });
}
/**
* This endpoint creates a new alert to monitor a customer's credit balance. There
* are three types of alerts that can be scoped to customers:
* `credit_balance_depleted`, `credit_balance_dropped`, and
* `credit_balance_recovered`. Customers can have a maximum of one of each type of
* alert per [credit balance currency](/product-catalog/prepurchase).
* `credit_balance_dropped` alerts require a list of thresholds to be provided
* while `credit_balance_depleted` and `credit_balance_recovered` alerts do not
* require thresholds.
*/
createForCustomer(customerId, body, options) {
return this._client.post(`/alerts/customer_id/${customerId}`, { body, ...options });
}
/**
* This endpoint creates a new alert to monitor a customer's credit balance. There
* are three types of alerts that can be scoped to customers:
* `credit_balance_depleted`, `credit_balance_dropped`, and
* `credit_balance_recovered`. Customers can have a maximum of one of each type of
* alert per [credit balance currency](/product-catalog/prepurchase).
* `credit_balance_dropped` alerts require a list of thresholds to be provided
* while `credit_balance_depleted` and `credit_balance_recovered` alerts do not
* require thresholds.
*/
createForExternalCustomer(externalCustomerId, body, options) {
return this._client.post(`/alerts/external_customer_id/${externalCustomerId}`, { body, ...options });
}
/**
* This endpoint is used to create alerts at the subscription level.
*
* Subscription level alerts can be one of two types: `usage_exceeded` or
* `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and
* is triggered when the usage of that metric exceeds predefined thresholds during
* the current billing cycle. A `cost_exceeded` alert is triggered when the total
* amount due during the current billing cycle surpasses predefined thresholds.
* `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each
* subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert
* per metric that is a part of the subscription. Alerts are triggered based on
* usage or cost conditions met during the current billing cycle.
*/
createForSubscription(subscriptionId, body, options) {
return this._client.post(`/alerts/subscription_id/${subscriptionId}`, { body, ...options });
}
disable(alertConfigurationId, params = {}, options) {
if (isRequestOptions(params)) {
return this.disable(alertConfigurationId, {}, params);
}
const { subscription_id } = params;
return this._client.post(`/alerts/${alertConfigurationId}/disable`, {
query: { subscription_id },
...options,
});
}
enable(alertConfigurationId, params = {}, options) {
if (isRequestOptions(params)) {
return this.enable(alertConfigurationId, {}, params);
}
const { subscription_id } = params;
return this._client.post(`/alerts/${alertConfigurationId}/enable`, {
query: { subscription_id },
...options,
});
}
}
export class AlertsPage extends Page {
}
Alerts.AlertsPage = AlertsPage;
//# sourceMappingURL=alerts.mjs.map