UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

143 lines • 5.23 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseLabels = /* @__PURE__ */ (() => { class BaseLabels extends APIResource { /** * Attaches one or more labels to a web or API operation. * * @example * ```ts * const label = * await client.apiGateway.operations.labels.create( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ create(operationID, params, options) { const { zone_id, ...body } = params; return this._client.post(path `/zones/${zone_id}/api_gateway/operations/${operationID}/labels`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Replaces the complete label set on a web or API operation. * * @example * ```ts * const label = * await client.apiGateway.operations.labels.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(operationID, params, options) { const { zone_id, ...body } = params; return this._client.put(path `/zones/${zone_id}/api_gateway/operations/${operationID}/labels`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Removes one or more labels from a web or API operation. * * @example * ```ts * const label = * await client.apiGateway.operations.labels.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(operationID, params, options) { const { zone_id } = params; return this._client.delete(path `/zones/${zone_id}/api_gateway/operations/${operationID}/labels`, options)._thenUnwrap((obj) => obj.result); } /** * Attaches labels to multiple web or API operations in one request. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const labelBulkCreateResponse of client.apiGateway.operations.labels.bulkCreate( * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * selector: { * include: { * operation_ids: [ * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * ], * }, * }, * }, * )) { * // ... * } * ``` */ bulkCreate(params, options) { const { zone_id, ...body } = params; return this._client.getAPIList(path `/zones/${zone_id}/api_gateway/operations/labels`, (SinglePage), { body, method: 'post', ...options }); } /** * Removes labels from multiple web or API operations in one request. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const labelBulkDeleteResponse of client.apiGateway.operations.labels.bulkDelete( * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ bulkDelete(params, options) { const { zone_id } = params; return this._client.getAPIList(path `/zones/${zone_id}/api_gateway/operations/labels`, (SinglePage), { method: 'delete', ...options }); } /** * Replaces the complete label sets on multiple web or API operations in one * request. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const labelBulkUpdateResponse of client.apiGateway.operations.labels.bulkUpdate( * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * managed: { labels: ['login'] }, * selector: { * include: { * operation_ids: [ * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * ], * }, * }, * user: { labels: ['login'] }, * }, * )) { * // ... * } * ``` */ bulkUpdate(params, options) { const { zone_id, ...body } = params; return this._client.getAPIList(path `/zones/${zone_id}/api_gateway/operations/labels`, (SinglePage), { body, method: 'put', ...options }); } } BaseLabels._key = Object.freeze([ 'apiGateway', 'operations', 'labels', ]); return BaseLabels; })(); export class Labels extends BaseLabels { } //# sourceMappingURL=labels.mjs.map