UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

70 lines 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserMembersClient = void 0; const BaseClient_1 = require("./BaseClient"); class UserMembersClient extends BaseClient_1.BaseClient { 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 queryITwinUserMembersAsync(accessToken, iTwinId, arg) { let url = `${this._baseUrl}/${iTwinId}/members/users`; if (arg) { url += `?${this.getQueryString(arg)}`; } return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "members"); // TODO: Consider how to handle paging } /** 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 getITwinUserMemberAsync(accessToken, iTwinId, memberId) { const url = `${this._baseUrl}/${iTwinId}/members/users/${memberId}`; return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "member"); } /** 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 * @returns AddUserMemberResponse -- the added or invited user members */ async addITwinUserMembersAsync(accessToken, iTwinId, newMembers) { const url = `${this._baseUrl}/${iTwinId}/members/users`; const body = { members: newMembers, }; 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 removeITwinUserMemberAsync(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 updateITwinUserMemberAsync(accessToken, iTwinId, memberId, roleIds) { const url = `${this._baseUrl}/${iTwinId}/members/users/${memberId}`; const body = { roleIds, }; return this.sendGenericAPIRequest(accessToken, "PATCH", url, body, "member"); } } exports.UserMembersClient = UserMembersClient; //# sourceMappingURL=UserMembersClient.js.map