UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

56 lines 2.39 kB
import { BaseClient } from "./BaseClient"; export class GroupsClient extends BaseClient { constructor(url) { super(url); } /** Retrieves a list of available user roles that are defined for a specified iTwin * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @returns Group[] */ async getITwinGroupsAsync(accessToken, iTwinId) { const url = `${this._baseUrl}/${iTwinId}/groups`; return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "groups"); } /** Retrieves the specified role for the specified iTwin * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @returns Group */ async getITwinGroupAsync(accessToken, iTwinId, groupId) { const url = `${this._baseUrl}/${iTwinId}/groups/${groupId}`; return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "group"); } /** Creates a new iTwin group * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param group The group to be created * @returns Group */ async createITwinGroupAsync(accessToken, iTwinId, group) { const url = `${this._baseUrl}/${iTwinId}/groups`; return this.sendGenericAPIRequest(accessToken, "POST", url, group, "group"); } /** Delete the specified iTwin group * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param groupId The id of the group to remove * @returns No Content */ async deleteITwinGroupAsync(accessToken, iTwinId, groupId) { const url = `${this._baseUrl}/${iTwinId}/groups/${groupId}`; return this.sendGenericAPIRequest(accessToken, "DELETE", url); } /** Update the specified iTwin group * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param groupId The id of the role to update * @param group The updated group * @returns Role */ async updateITwinGroupAsync(accessToken, iTwinId, groupId, group) { const url = `${this._baseUrl}/${iTwinId}/groups/${groupId}`; return this.sendGenericAPIRequest(accessToken, "PATCH", url, group, "group"); } } //# sourceMappingURL=GroupsClient.js.map