@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
142 lines • 4.21 kB
JavaScript
import * as Utils from '@datocms/rest-client-utils';
import BaseResource from '../../BaseResource';
export default class UploadFilter extends BaseResource {
/**
* Create a new filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
create(body) {
return this.rawCreate(Utils.serializeRequestBody(body, {
type: 'upload_filter',
attributes: ['name', 'filter', 'shared'],
relationships: [],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Create a new filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawCreate(body) {
return this.client.request({
method: 'POST',
url: '/upload-filters',
body,
});
}
/**
* Update a filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/update
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
update(uploadFilterId, body) {
return this.rawUpdate(Utils.toId(uploadFilterId), Utils.serializeRequestBody(body, {
id: Utils.toId(uploadFilterId),
type: 'upload_filter',
attributes: ['name', 'shared', 'filter'],
relationships: [],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Update a filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/update
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawUpdate(uploadFilterId, body) {
return this.client.request({
method: 'PUT',
url: `/upload-filters/${uploadFilterId}`,
body,
});
}
/**
* List all filters
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
list() {
return this.rawList().then((body) => Utils.deserializeResponseBody(body));
}
/**
* List all filters
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawList() {
return this.client.request({
method: 'GET',
url: '/upload-filters',
});
}
/**
* Retrieve a filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/self
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
find(uploadFilterId) {
return this.rawFind(Utils.toId(uploadFilterId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Retrieve a filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/self
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawFind(uploadFilterId) {
return this.client.request({
method: 'GET',
url: `/upload-filters/${uploadFilterId}`,
});
}
/**
* Delete a filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
destroy(uploadFilterId) {
return this.rawDestroy(Utils.toId(uploadFilterId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Delete a filter
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawDestroy(uploadFilterId) {
return this.client.request({
method: 'DELETE',
url: `/upload-filters/${uploadFilterId}`,
});
}
}
UploadFilter.TYPE = 'upload_filter';
//# sourceMappingURL=UploadFilter.js.map