UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

111 lines • 4.7 kB
// 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 BaseRecipients = /* @__PURE__ */ (() => { class BaseRecipients extends APIResource { /** * Adds a single recipient to an account-targeted resource share, granting them * access to the shared resources. The recipient account must belong to the same * organization as the share owner. * * To replace the entire recipient list in one call, use * `PUT /accounts/{account_id}/shares/{share_id}/recipients` instead. * * @example * ```ts * const recipient = * await client.resourceSharing.recipients.create( * '3fd85f74b32742f1bff64a85009dda07', * { path_account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ create(shareID, params, options) { const { path_account_id, ...body } = params; return this._client.post(path `/accounts/${path_account_id}/shares/${shareID}/recipients`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List share recipients by share ID. Returns **all** recipients regardless of * their `association_status` (associating, associated, disassociating, * disassociated). Callers that want only "active" recipients must filter * client-side on the `association_status` field. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const recipientListResponse of client.resourceSharing.recipients.list( * '3fd85f74b32742f1bff64a85009dda07', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(shareID, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/shares/${shareID}/recipients`, (V4PagePaginationArray), { query, ...options }); } /** * Performs a **soft delete**: sets the recipient's `desired_association_status` to * `disassociated`, which signals the background reconciliation workflow (Temporal) * to remove the shared resources from the recipient account. The recipient record * remains in the database for audit purposes and is still returned by * `GET /accounts/{account_id}/shares/{share_id}/recipients` with its updated * status. * * Resource access is not fully removed until the workflow completes and * `current_association_status` transitions to `disassociated`. The recipient * record itself is never physically deleted. * * @example * ```ts * const recipient = * await client.resourceSharing.recipients.delete( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * share_id: '3fd85f74b32742f1bff64a85009dda07', * }, * ); * ``` */ delete(recipientID, params, options) { const { account_id, share_id } = params; return this._client.delete(path `/accounts/${account_id}/shares/${share_id}/recipients/${recipientID}`, options)._thenUnwrap((obj) => obj.result); } /** * Get share recipient by ID. * * @example * ```ts * const recipient = * await client.resourceSharing.recipients.get( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * share_id: '3fd85f74b32742f1bff64a85009dda07', * }, * ); * ``` */ get(recipientID, params, options) { const { account_id, share_id, ...query } = params; return this._client.get(path `/accounts/${account_id}/shares/${share_id}/recipients/${recipientID}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseRecipients._key = Object.freeze([ 'resourceSharing', 'recipients', ]); return BaseRecipients; })(); export class Recipients extends BaseRecipients { } //# sourceMappingURL=recipients.mjs.map