cloudflare
Version:
The official TypeScript library for the Cloudflare API
142 lines • 5.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = exports.BaseUser = 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 ResourcesAPI = tslib_1.__importStar(require("./resources/resources.js"));
const resources_1 = require("./resources/resources.js");
const pagination_1 = require("../../../../core/pagination.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseUser = /* @__PURE__ */ (() => {
class BaseUser extends resource_1.APIResource {
/**
* Replaces all editable fields on a user-defined label.
*
* @example
* ```ts
* const user = await client.apiGateway.labels.user.update(
* 'login',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(name, params, options) {
const { zone_id, ...body } = params;
return this._client.put((0, path_1.path) `/zones/${zone_id}/api_gateway/labels/user/${name}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Deletes a user-defined label and removes its associations with web and API
* operations.
*
* @example
* ```ts
* const user = await client.apiGateway.labels.user.delete(
* 'login',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(name, params, options) {
const { zone_id } = params;
return this._client.delete((0, path_1.path) `/zones/${zone_id}/api_gateway/labels/user/${name}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Creates one or more user-defined labels for classifying web and API operations.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const userBulkCreateResponse of client.apiGateway.labels.user.bulkCreate(
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* body: [{ name: 'login' }],
* },
* )) {
* // ...
* }
* ```
*/
bulkCreate(params, options) {
const { zone_id, body } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/api_gateway/labels/user`, (pagination_1.SinglePage), { body: body, method: 'post', ...options });
}
/**
* Deletes one or more user-defined labels and removes their associations with web
* and API operations.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const userBulkDeleteResponse of client.apiGateway.labels.user.bulkDelete(
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
bulkDelete(params, options) {
const { zone_id } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/api_gateway/labels/user`, (pagination_1.SinglePage), { method: 'delete', ...options });
}
/**
* Updates only the supplied fields on a user-defined label.
*
* @example
* ```ts
* const response = await client.apiGateway.labels.user.edit(
* 'login',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(name, params, options) {
const { zone_id, ...body } = params;
return this._client.patch((0, path_1.path) `/zones/${zone_id}/api_gateway/labels/user/${name}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a user-defined label and the web and API operations associated with it.
*
* @example
* ```ts
* const user = await client.apiGateway.labels.user.get(
* 'login',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(name, params, options) {
const { zone_id, ...query } = params;
return this._client.get((0, path_1.path) `/zones/${zone_id}/api_gateway/labels/user/${name}`, {
query,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseUser._key = Object.freeze([
'apiGateway',
'labels',
'user',
]);
return BaseUser;
})();
exports.BaseUser = BaseUser;
var User = /* @__PURE__ */ (() => {
class User extends BaseUser {
constructor() {
super(...arguments);
this.resources = new ResourcesAPI.Resources(this._client);
}
}
User.Resources = resources_1.Resources;
User.BaseResources = resources_1.BaseResources;
return User;
})();
exports.User = User;
//# sourceMappingURL=user.js.map