@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
288 lines • 9.08 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Utils = __importStar(require("@datocms/rest-client-utils"));
const BaseResource_1 = __importDefault(require("../../BaseResource"));
class BuildTrigger extends BaseResource_1.default {
/**
* List all build triggers for a site
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
list() {
return this.rawList().then((body) => Utils.deserializeResponseBody(body));
}
/**
* List all build triggers for a site
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawList() {
return this.client.request({
method: 'GET',
url: '/build-triggers',
});
}
/**
* Retrieve a build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/self
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
find(buildTriggerId) {
return this.rawFind(Utils.toId(buildTriggerId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Retrieve a build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/self
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawFind(buildTriggerId) {
return this.client.request({
method: 'GET',
url: `/build-triggers/${buildTriggerId}`,
});
}
/**
* Create build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
create(body) {
return this.rawCreate(Utils.serializeRequestBody(body, {
type: 'build_trigger',
attributes: [
'name',
'webhook_token',
'adapter',
'indexing_enabled',
'enabled',
'frontend_url',
'autotrigger_on_scheduled_publications',
'adapter_settings',
],
relationships: [],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Create build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawCreate(body) {
return this.client.request({
method: 'POST',
url: '/build-triggers',
body,
});
}
/**
* Update build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/update
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
update(buildTriggerId, body) {
return this.rawUpdate(Utils.toId(buildTriggerId), Utils.serializeRequestBody(body, {
id: Utils.toId(buildTriggerId),
type: 'build_trigger',
attributes: [
'name',
'adapter',
'indexing_enabled',
'enabled',
'frontend_url',
'autotrigger_on_scheduled_publications',
'adapter_settings',
],
relationships: [],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Update build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/update
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawUpdate(buildTriggerId, body) {
return this.client.request({
method: 'PUT',
url: `/build-triggers/${buildTriggerId}`,
body,
});
}
/**
* Trigger a deploy
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/trigger
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
trigger(buildTriggerId) {
return this.rawTrigger(Utils.toId(buildTriggerId));
}
/**
* Trigger a deploy
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/trigger
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawTrigger(buildTriggerId) {
return this.client.request({
method: 'POST',
url: `/build-triggers/${buildTriggerId}/trigger`,
});
}
/**
* Abort a deploy and mark it as failed
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/abort
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
abort(buildTriggerId) {
return this.rawAbort(Utils.toId(buildTriggerId));
}
/**
* Abort a deploy and mark it as failed
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/abort
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawAbort(buildTriggerId) {
return this.client.request({
method: 'DELETE',
url: `/build-triggers/${buildTriggerId}/abort`,
});
}
/**
* Abort a site search spidering and mark it as failed
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/abort_indexing
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
abortIndexing(buildTriggerId) {
return this.rawAbortIndexing(Utils.toId(buildTriggerId));
}
/**
* Abort a site search spidering and mark it as failed
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/abort_indexing
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawAbortIndexing(buildTriggerId) {
return this.client.request({
method: 'DELETE',
url: `/build-triggers/${buildTriggerId}/abort_indexing`,
});
}
/**
* Trigger a new site search spidering of the website
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/reindex
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
reindex(buildTriggerId) {
return this.rawReindex(Utils.toId(buildTriggerId));
}
/**
* Trigger a new site search spidering of the website
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/reindex
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawReindex(buildTriggerId) {
return this.client.request({
method: 'PUT',
url: `/build-triggers/${buildTriggerId}/reindex`,
});
}
/**
* Delete a build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
destroy(buildTriggerId) {
return this.rawDestroy(Utils.toId(buildTriggerId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Delete a build trigger
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/build-trigger/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawDestroy(buildTriggerId) {
return this.client.request({
method: 'DELETE',
url: `/build-triggers/${buildTriggerId}`,
});
}
}
exports.default = BuildTrigger;
BuildTrigger.TYPE = 'build_trigger';
//# sourceMappingURL=BuildTrigger.js.map