UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

80 lines 3.58 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 user members operations. */ export class UserMembersClient extends BaseClient { /** Create a new UserMembersClient 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 user members and their roles assignments. * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @returns Array of members */ async queryITwinUserMembers(accessToken, iTwinId, arg) { let url = `${this._baseUrl}/${iTwinId}/members/users`; if (arg) { url += `?${this.getQueryString(UserMembersClient.paginationParamMapping, { top: arg.top, skip: arg.skip })}`; } return this.sendGenericAPIRequest(accessToken, "GET", url, undefined); } /** Retrieves a specific user 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 getITwinUserMember(accessToken, iTwinId, memberId) { const url = `${this._baseUrl}/${iTwinId}/members/users/${memberId}`; return this.sendGenericAPIRequest(accessToken, "GET", url, undefined); } /** Add new iTwin user members * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param newMembers The list of members to add or invite, along with their role * @param customMessage Send custom message in welcome email when adding new members * @returns AddUserMemberResponse -- the added or invited user members */ async addITwinUserMembers(accessToken, iTwinId, newMembers, customMessage) { const url = `${this._baseUrl}/${iTwinId}/members/users`; const body = { members: newMembers, customMessage, }; return this.sendGenericAPIRequest(accessToken, "POST", url, body); } /** Remove the specified user 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 removeITwinUserMember(accessToken, iTwinId, memberId) { const url = `${this._baseUrl}/${iTwinId}/members/users/${memberId}`; return this.sendGenericAPIRequest(accessToken, "DELETE", url); } /** Update iTwin user 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 updateITwinUserMember(accessToken, iTwinId, memberId, roleIds) { const url = `${this._baseUrl}/${iTwinId}/members/users/${memberId}`; const body = { roleIds, }; return this.sendGenericAPIRequest(accessToken, "PATCH", url, body); } } //# sourceMappingURL=UserMembersClient.js.map