cloudflare
Version:
The official TypeScript library for the Cloudflare API
127 lines • 4.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Resources = exports.BaseResources = 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 BaseResources = /* @__PURE__ */ (() => {
class BaseResources extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/shares/${shareID}/resources`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/shares/${share_id}/resources/${shareResourceID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseResources._key = Object.freeze([
'resourceSharing',
'resources',
]);
return BaseResources;
})();
exports.BaseResources = BaseResources;
class Resources extends BaseResources {
}
exports.Resources = Resources;
//# sourceMappingURL=resources.js.map