UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

79 lines 3.53 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupMembersClient = void 0; const BaseClient_1 = require("./BaseClient"); /** Client API to perform iTwin group members operations. */ class GroupMembersClient extends BaseClient_1.BaseClient { /** Create a new GroupMembersClient 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 iTwin group members and their roles assignments. * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @returns Array of members */ async queryITwinGroupMembers(accessToken, iTwinId, arg) { let url = `${this._baseUrl}/${iTwinId}/members/groups`; if (arg) { url += `?${this.getQueryString(GroupMembersClient.paginationParamMapping, { top: arg.top, skip: arg.skip })}`; } return this.sendGenericAPIRequest(accessToken, "GET", url, undefined); } /** Retrieves a specific group member for a specified iTwin. * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param memberId The id of the member * @returns Member */ async getITwinGroupMember(accessToken, iTwinId, memberId) { const url = `${this._baseUrl}/${iTwinId}/members/groups/${memberId}`; return this.sendGenericAPIRequest(accessToken, "GET", url, undefined); } /** Add new iTwin group members * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param newMembers The list of new members to be added along with their role * @returns Member[] */ async addITwinGroupMembers(accessToken, iTwinId, newMembers) { const url = `${this._baseUrl}/${iTwinId}/members/groups`; return this.sendGenericAPIRequest(accessToken, "POST", url, newMembers); } /** Remove the specified group member from the iTwin * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param memberId The id of the member * @returns No Content */ async removeITwinGroupMember(accessToken, iTwinId, memberId) { const url = `${this._baseUrl}/${iTwinId}/members/groups/${memberId}`; return this.sendGenericAPIRequest(accessToken, "DELETE", url); } /** Update iTwin group member roles * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param memberId The id of the member * @param roleIds The ids of the roles to be assigned * @returns Member */ async updateITwinGroupMember(accessToken, iTwinId, memberId, roleIds) { const url = `${this._baseUrl}/${iTwinId}/members/groups/${memberId}`; const body = { roleIds, }; return this.sendGenericAPIRequest(accessToken, "PATCH", url, body); } } exports.GroupMembersClient = GroupMembersClient; //# sourceMappingURL=GroupMembersClient.js.map