cloudflare
Version:
The official TypeScript library for the Cloudflare API
136 lines • 4.89 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as ResourcesAPI from "./resources/resources.mjs";
import { BaseResources, Resources } from "./resources/resources.mjs";
import { SinglePage } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseUser = /* @__PURE__ */ (() => {
class BaseUser extends 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(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(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(path `/zones/${zone_id}/api_gateway/labels/user`, (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(path `/zones/${zone_id}/api_gateway/labels/user`, (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(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(path `/zones/${zone_id}/api_gateway/labels/user/${name}`, {
query,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseUser._key = Object.freeze([
'apiGateway',
'labels',
'user',
]);
return BaseUser;
})();
export var User = /* @__PURE__ */ (() => {
class User extends BaseUser {
constructor() {
super(...arguments);
this.resources = new ResourcesAPI.Resources(this._client);
}
}
User.Resources = Resources;
User.BaseResources = BaseResources;
return User;
})();
//# sourceMappingURL=user.mjs.map