UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

134 lines • 5 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseMessages = /* @__PURE__ */ (() => { class BaseMessages extends APIResource { /** * Acknowledges successfully processed Queue messages and retries messages that * were not processed successfully. * * @example * ```ts * const response = await client.queues.messages.ack( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ ack(queueID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/queues/${queueID}/messages/ack`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Pushes a batch of messages to a Queue. * * @example * ```ts * const response = await client.queues.messages.bulkPush( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ bulkPush(queueID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/queues/${queueID}/messages/batch`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Peek messages from a Queue without leasing them. Each message includes a ref * that can be passed to the purge endpoint, and remains available for subsequent * peek or pull operations until it is purged. * * @example * ```ts * const response = await client.queues.messages.peek( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ peek(queueID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/queues/${queueID}/messages/peek`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Pulls a batch of messages from a Queue for an HTTP pull consumer. * * @example * ```ts * const response = await client.queues.messages.pull( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ pull(queueID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/queues/${queueID}/messages/pull`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Delete messages from a Queue by using refs returned by the peek endpoint. * Purging messages does not count as delivery and does not affect metrics. * * @example * ```ts * const response = await client.queues.messages.purge( * '023e105f4ecef8ad9ca31a8372d0c353', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * refs: [ * { * ref: 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0', * }, * ], * }, * ); * ``` */ purge(queueID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/queues/${queueID}/messages/purge`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Pushes a message to a Queue. * * @example * ```ts * const response = await client.queues.messages.push( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ push(queueID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/queues/${queueID}/messages`, { body, ...options, })._thenUnwrap((obj) => obj.result); } } BaseMessages._key = Object.freeze([ 'queues', 'messages', ]); return BaseMessages; })(); export class Messages extends BaseMessages { } //# sourceMappingURL=messages.mjs.map