@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
169 lines • 5.12 kB
JavaScript
import * as Utils from '@datocms/rest-client-utils';
import BaseResource from '../../BaseResource';
export default class Environment extends BaseResource {
/**
* Fork an existing environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/fork
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
fork(environmentId, body, queryParams) {
return this.rawFork(Utils.toId(environmentId), Utils.serializeRequestBody(body, {
id: Utils.toId(environmentId),
type: 'environment',
attributes: [],
relationships: [],
}), queryParams).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Fork an existing environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/fork
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawFork(environmentId, body, queryParams) {
return this.client.request({
method: 'POST',
url: `/environments/${environmentId}/fork`,
body,
queryParams,
});
}
/**
* Promote an environment to primary
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/promote
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
promote(environmentId) {
return this.rawPromote(Utils.toId(environmentId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Promote an environment to primary
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/promote
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawPromote(environmentId) {
return this.client.request({
method: 'PUT',
url: `/environments/${environmentId}/promote`,
});
}
/**
* Rename an environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/rename
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rename(environmentId, body) {
return this.rawRename(Utils.toId(environmentId), Utils.serializeRequestBody(body, {
id: Utils.toId(environmentId),
type: 'environment',
attributes: [],
relationships: [],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Rename an environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/rename
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawRename(environmentId, body) {
return this.client.request({
method: 'PUT',
url: `/environments/${environmentId}/rename`,
body,
});
}
/**
* List all environments
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
list() {
return this.rawList().then((body) => Utils.deserializeResponseBody(body));
}
/**
* List all environments
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawList() {
return this.client.request({
method: 'GET',
url: '/environments',
});
}
/**
* Retrieve a environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/self
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
find(environmentId) {
return this.rawFind(Utils.toId(environmentId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Retrieve a environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/self
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawFind(environmentId) {
return this.client.request({
method: 'GET',
url: `/environments/${environmentId}`,
});
}
/**
* Delete a environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
destroy(environmentId) {
return this.rawDestroy(Utils.toId(environmentId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Delete a environment
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/environment/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawDestroy(environmentId) {
return this.client.request({
method: 'DELETE',
url: `/environments/${environmentId}`,
});
}
}
Environment.TYPE = 'environment';
//# sourceMappingURL=Environment.js.map