UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

116 lines • 4.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Recipients = exports.BaseRecipients = 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 BaseRecipients = /* @__PURE__ */ (() => { class BaseRecipients extends resource_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/shares/${shareID}/recipients`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/shares/${share_id}/recipients/${recipientID}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseRecipients._key = Object.freeze([ 'resourceSharing', 'recipients', ]); return BaseRecipients; })(); exports.BaseRecipients = BaseRecipients; class Recipients extends BaseRecipients { } exports.Recipients = Recipients; //# sourceMappingURL=recipients.js.map