UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

122 lines • 4.63 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 BaseResources = /* @__PURE__ */ (() => { class BaseResources extends APIResource { /** * Adds a resource to an existing share, making it available to share recipients. * * @example * ```ts * const resource = * await client.resourceSharing.resources.create( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * meta: {}, * resource_account_id: * '023e105f4ecef8ad9ca31a8372d0c353', * resource_id: '023e105f4ecef8ad9ca31a8372d0c353', * resource_type: 'custom-ruleset', * }, * ); * ``` */ create(shareID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/shares/${shareID}/resources`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Update is not immediate, an updated share resource object with a new status will * be returned. * * @example * ```ts * const resource = * await client.resourceSharing.resources.update( * '023e105f4ecef8ad9ca31a8372d0c353', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * share_id: '3fd85f74b32742f1bff64a85009dda07', * meta: {}, * }, * ); * ``` */ update(shareResourceID, params, options) { const { account_id, share_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/shares/${share_id}/resources/${shareResourceID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List share resources by share ID. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const resourceListResponse of client.resourceSharing.resources.list( * '3fd85f74b32742f1bff64a85009dda07', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(shareID, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/shares/${shareID}/resources`, (V4PagePaginationArray), { query, ...options }); } /** * Deletion is not immediate, an updated share resource object with a new status * will be returned. * * @example * ```ts * const resource = * await client.resourceSharing.resources.delete( * '023e105f4ecef8ad9ca31a8372d0c353', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * share_id: '3fd85f74b32742f1bff64a85009dda07', * }, * ); * ``` */ delete(shareResourceID, params, options) { const { account_id, share_id } = params; return this._client.delete(path `/accounts/${account_id}/shares/${share_id}/resources/${shareResourceID}`, options)._thenUnwrap((obj) => obj.result); } /** * Get share resource by ID. * * @example * ```ts * const resource = await client.resourceSharing.resources.get( * '023e105f4ecef8ad9ca31a8372d0c353', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * share_id: '3fd85f74b32742f1bff64a85009dda07', * }, * ); * ``` */ get(shareResourceID, params, options) { const { account_id, share_id } = params; return this._client.get(path `/accounts/${account_id}/shares/${share_id}/resources/${shareResourceID}`, options)._thenUnwrap((obj) => obj.result); } } BaseResources._key = Object.freeze([ 'resourceSharing', 'resources', ]); return BaseResources; })(); export class Resources extends BaseResources { } //# sourceMappingURL=resources.mjs.map