UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

180 lines • 7.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Requests = exports.BaseRequests = void 0; const tslib_1 = require("../../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const AssetsAPI = tslib_1.__importStar(require("./assets.js")); const assets_1 = require("./assets.js"); const MessageAPI = tslib_1.__importStar(require("./message.js")); const message_1 = require("./message.js"); const PriorityAPI = tslib_1.__importStar(require("./priority.js")); const priority_1 = require("./priority.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseRequests = /* @__PURE__ */ (() => { class BaseRequests extends resource_1.APIResource { /** * Creating a request adds the request into the Cloudforce One queue for analysis. * In addition to the content, a short title, type, priority, and releasability * should be provided. If one is not provided, a default will be assigned. * * @example * ```ts * const item = await client.cloudforceOne.requests.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/new`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Updating a request alters the request in the Cloudforce One queue. This API may * be used to update any attributes of the request after the initial submission. * Only fields that you choose to update need to be add to the request body. * * @example * ```ts * const item = await client.cloudforceOne.requests.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(requestID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/${requestID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists Cloudforce One intelligence requests with filtering and pagination. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const listItem of client.cloudforceOne.requests.list( * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * page: 0, * per_page: 10, * }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...body } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests`, (pagination_1.SinglePage), { body, method: 'post', ...options }); } /** * Deletes a Cloudforce One intelligence request and all associated data. * * @example * ```ts * const request = await client.cloudforceOne.requests.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(requestID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/${requestID}`, options); } /** * Retrieves constant values used in Cloudforce One requests, including valid * statuses and types. * * @example * ```ts * const requestConstants = * await client.cloudforceOne.requests.constants({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ constants(params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/constants`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves details for a specific Cloudforce One intelligence request. * * @example * ```ts * const item = await client.cloudforceOne.requests.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(requestID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/${requestID}`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves quota usage for Cloudforce One standard requests. * * @example * ```ts * const quota = await client.cloudforceOne.requests.quota({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ quota(params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/quota`, options)._thenUnwrap((obj) => obj.result); } /** * Lists available request types for Cloudforce One intelligence requests. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const requestTypesResponse of client.cloudforceOne.requests.types( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ types(params, options) { const { account_id } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/cloudforce-one/requests/types`, (pagination_1.SinglePage), options); } } BaseRequests._key = Object.freeze([ 'cloudforceOne', 'requests', ]); return BaseRequests; })(); exports.BaseRequests = BaseRequests; var Requests = /* @__PURE__ */ (() => { class Requests extends BaseRequests { constructor() { super(...arguments); this.message = new MessageAPI.MessageResource(this._client); this.priority = new PriorityAPI.PriorityResource(this._client); this.assets = new AssetsAPI.Assets(this._client); } } Requests.MessageResource = message_1.MessageResource; Requests.BaseMessageResource = message_1.BaseMessageResource; Requests.PriorityResource = priority_1.PriorityResource; Requests.BasePriorityResource = priority_1.BasePriorityResource; Requests.Assets = assets_1.Assets; Requests.BaseAssets = assets_1.BaseAssets; return Requests; })(); exports.Requests = Requests; //# sourceMappingURL=requests.js.map