@itwin/access-control-client
Version:
Access control client for the iTwin platform
70 lines • 3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupMembersClient = void 0;
const BaseClient_1 = require("./BaseClient");
class GroupMembersClient extends BaseClient_1.BaseClient {
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 queryITwinGroupMembersAsync(accessToken, iTwinId, arg) {
let url = `${this._baseUrl}/${iTwinId}/members/groups`;
if (arg) {
url += `?${this.getQueryString(arg)}`;
}
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "members"); // TODO: Consider how to handle paging
}
/** 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 getITwinGroupMemberAsync(accessToken, iTwinId, memberId) {
const url = `${this._baseUrl}/${iTwinId}/members/groups/${memberId}`;
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "member");
}
/** 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 addITwinGroupMembersAsync(accessToken, iTwinId, newMembers) {
const url = `${this._baseUrl}/${iTwinId}/members/groups`;
const body = {
members: newMembers,
};
return this.sendGenericAPIRequest(accessToken, "POST", url, body, "members");
}
/** 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 removeITwinGroupMemberAsync(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 updateITwinGroupMemberAsync(accessToken, iTwinId, memberId, roleIds) {
const url = `${this._baseUrl}/${iTwinId}/members/groups/${memberId}`;
const body = {
roleIds,
};
return this.sendGenericAPIRequest(accessToken, "PATCH", url, body, "member");
}
}
exports.GroupMembersClient = GroupMembersClient;
//# sourceMappingURL=GroupMembersClient.js.map
;