UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

68 lines 2.95 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module AccessControlClient */ import { BaseClient } from "./BaseClient"; /** Client API to perform iTwin group operations. */ export class GroupsClient extends BaseClient { /** Create a new GroupsClient instance * @param url Optional base URL for the access control service. If not provided, defaults to base url. */ 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 getITwinGroups(accessToken, iTwinId) { const url = `${this._baseUrl}/${iTwinId}/groups`; return this.sendGenericAPIRequest(accessToken, "GET", url); } /** 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 getITwinGroup(accessToken, iTwinId, groupId) { const url = `${this._baseUrl}/${iTwinId}/groups/${groupId}`; return this.sendGenericAPIRequest(accessToken, "GET", url); } /** 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 createITwinGroup(accessToken, iTwinId, group) { const url = `${this._baseUrl}/${iTwinId}/groups`; return this.sendGenericAPIRequest(accessToken, "POST", url, 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 deleteITwinGroup(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 Group that was updated */ async updateITwinGroup(accessToken, iTwinId, groupId, group) { const url = `${this._baseUrl}/${iTwinId}/groups/${groupId}`; return this.sendGenericAPIRequest(accessToken, "PATCH", url, group); } } //# sourceMappingURL=GroupsClient.js.map