cloudflare
Version:
The official TypeScript library for the Cloudflare API
102 lines • 3.87 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseSubscriptions = /* @__PURE__ */ (() => {
class BaseSubscriptions extends 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(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(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(path `/accounts/${account_id}/event_subscriptions/subscriptions`, (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(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(path `/accounts/${account_id}/event_subscriptions/subscriptions/${subscriptionID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSubscriptions._key = Object.freeze([
'queues',
'subscriptions',
]);
return BaseSubscriptions;
})();
export class Subscriptions extends BaseSubscriptions {
}
//# sourceMappingURL=subscriptions.mjs.map