cloudflare
Version:
The official TypeScript library for the Cloudflare API
107 lines • 4.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subscriptions = exports.BaseSubscriptions = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
var BaseSubscriptions = /* @__PURE__ */ (() => {
class BaseSubscriptions extends resource_1.APIResource {
/**
* Creates an event subscription for a Queue.
*
* @example
* ```ts
* const subscription =
* await client.queues.subscriptions.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/event_subscriptions/subscriptions`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing Queue event subscription.
*
* @example
* ```ts
* const subscription =
* await client.queues.subscriptions.update(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(subscriptionID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/event_subscriptions/subscriptions/${subscriptionID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a paginated list of Queue event subscriptions with optional sorting and
* filtering.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const subscriptionListResponse of client.queues.subscriptions.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/event_subscriptions/subscriptions`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Deletes an existing Queue event subscription.
*
* @example
* ```ts
* const subscription =
* await client.queues.subscriptions.delete(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(subscriptionID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/event_subscriptions/subscriptions/${subscriptionID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Returns an existing Queue event subscription.
*
* @example
* ```ts
* const subscription = await client.queues.subscriptions.get(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(subscriptionID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/event_subscriptions/subscriptions/${subscriptionID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSubscriptions._key = Object.freeze([
'queues',
'subscriptions',
]);
return BaseSubscriptions;
})();
exports.BaseSubscriptions = BaseSubscriptions;
class Subscriptions extends BaseSubscriptions {
}
exports.Subscriptions = Subscriptions;
//# sourceMappingURL=subscriptions.js.map