cloudflare
Version:
The official TypeScript library for the Cloudflare API
136 lines • 4.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Environments = exports.BaseEnvironments = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const path_1 = require("../../internal/utils/path.js");
var BaseEnvironments = /* @__PURE__ */ (() => {
class BaseEnvironments extends resource_1.APIResource {
/**
* Creates environments for a zone.
*
* @example
* ```ts
* const environment = await client.zones.environments.create({
* zone_id: 'zone_id',
* environments: [
* {
* expression: 'expression',
* locked_on_deployment: true,
* name: 'name',
* position: {},
* ref: 'ref',
* version: 0,
* },
* ],
* });
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post((0, path_1.path) `/zones/${zone_id}/environments`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Replaces the full environment configuration for a zone.
*
* @example
* ```ts
* const environment = await client.zones.environments.update({
* zone_id: 'zone_id',
* environments: [
* {
* expression: 'expression',
* locked_on_deployment: true,
* name: 'name',
* position: {},
* ref: 'ref',
* version: 0,
* },
* ],
* });
* ```
*/
update(params, options) {
const { zone_id, ...body } = params;
return this._client.put((0, path_1.path) `/zones/${zone_id}/environments`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Lists configured environments for a zone.
*
* @example
* ```ts
* const environments = await client.zones.environments.list({
* zone_id: 'zone_id',
* });
* ```
*/
list(params, options) {
const { zone_id } = params;
return this._client.get((0, path_1.path) `/zones/${zone_id}/environments`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Deletes a zone environment by reference identifier.
*
* @example
* ```ts
* const environment = await client.zones.environments.delete(
* 'environment_id',
* { zone_id: 'zone_id' },
* );
* ```
*/
delete(environmentID, params, options) {
const { zone_id } = params;
return this._client.delete((0, path_1.path) `/zones/${zone_id}/environments/${environmentID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Applies partial updates to zone environments.
*
* @example
* ```ts
* const response = await client.zones.environments.edit({
* zone_id: 'zone_id',
* environments: [
* {
* expression: 'expression',
* locked_on_deployment: true,
* name: 'name',
* position: {},
* ref: 'ref',
* version: 0,
* },
* ],
* });
* ```
*/
edit(params, options) {
const { zone_id, ...body } = params;
return this._client.patch((0, path_1.path) `/zones/${zone_id}/environments`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Rolls a zone environment back to its previous version.
*
* @example
* ```ts
* const response = await client.zones.environments.rollback(
* 'environment_id',
* { zone_id: 'zone_id' },
* );
* ```
*/
rollback(environmentID, params, options) {
const { zone_id } = params;
return this._client.post((0, path_1.path) `/zones/${zone_id}/environments/${environmentID}/rollback`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseEnvironments._key = Object.freeze([
'zones',
'environments',
]);
return BaseEnvironments;
})();
exports.BaseEnvironments = BaseEnvironments;
class Environments extends BaseEnvironments {
}
exports.Environments = Environments;
//# sourceMappingURL=environments.js.map