@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
259 lines • 7.77 kB
JavaScript
import * as Utils from '@datocms/rest-client-utils';
import BaseResource from '../../BaseResource';
export default class BuildTrigger extends BaseResource {
/**
* 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}`,
});
}
}
BuildTrigger.TYPE = 'build_trigger';
//# sourceMappingURL=BuildTrigger.js.map