UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

131 lines • 4.4 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseEnvironments = /* @__PURE__ */ (() => { class BaseEnvironments extends 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(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(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(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(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(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(path `/zones/${zone_id}/environments/${environmentID}/rollback`, options)._thenUnwrap((obj) => obj.result); } } BaseEnvironments._key = Object.freeze([ 'zones', 'environments', ]); return BaseEnvironments; })(); export class Environments extends BaseEnvironments { } //# sourceMappingURL=environments.mjs.map