@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
112 lines • 3.31 kB
JavaScript
import * as Utils from '@datocms/rest-client-utils';
import BaseResource from '../../BaseResource';
export default class SsoGroup extends BaseResource {
/**
* List all SSO groups
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
list() {
return this.rawList().then((body) => Utils.deserializeResponseBody(body));
}
/**
* List all SSO groups
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawList() {
return this.client.request({
method: 'GET',
url: '/sso-groups',
});
}
/**
* Sync SSO provider groups to DatoCMS roles
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/copy_roles
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
copyRoles(ssoGroupId) {
return this.rawCopyRoles(Utils.toId(ssoGroupId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Sync SSO provider groups to DatoCMS roles
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/copy_roles
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawCopyRoles(ssoGroupId) {
return this.client.request({
method: 'POST',
url: `/sso-groups/${ssoGroupId}/copy-roles`,
});
}
/**
* Update a SSO group
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/update
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
update(ssoGroupId, body) {
return this.rawUpdate(Utils.toId(ssoGroupId), Utils.serializeRequestBody(body, {
id: Utils.toId(ssoGroupId),
type: 'sso_group',
attributes: ['priority'],
relationships: ['role'],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Update a SSO group
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/update
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawUpdate(ssoGroupId, body) {
return this.client.request({
method: 'PUT',
url: `/sso-groups/${ssoGroupId}`,
body,
});
}
/**
* Delete a group
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
destroy(ssoGroupId) {
return this.rawDestroy(Utils.toId(ssoGroupId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Delete a group
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/sso-group/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawDestroy(ssoGroupId) {
return this.client.request({
method: 'DELETE',
url: `/sso-groups/${ssoGroupId}`,
});
}
}
SsoGroup.TYPE = 'sso_group';
//# sourceMappingURL=SsoGroup.js.map