UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

83 lines 3.69 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.OwnerMembersClient = void 0; const BaseClient_1 = require("./BaseClient"); /** Client API to perform owner member operations. */ class OwnerMembersClient extends BaseClient_1.BaseClient { /** Create a new OwnerMembersClient 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 owner members on an iTwin. * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param arg Optional query parameters for pagination (top, skip) * @returns Array of owner members, including any "missing users" with null profile data * @remarks * **Missing Users** * * When members are removed from the Bentley Identity Management System, they are not * automatically removed from the iTwin. Therefore, it is possible to have a situation * where the user is no longer valid, yet they are still a member of the iTwin. When * this happens, the user member will be returned from this API endpoint with the * following values: * * ```json * { * "id": "<memberId>", * "email": null, * "givenName": null, * "surname": null, * "organization": null, * ... * } * ``` * * You should account for this in your software if you do not want to show these users. * * **Cleanup** * * The Access Control API will perform a once-a-week cleanup to remove these "Missing Users". * You can rely on this automated clean-up if this timeline is sufficient. * * If not, you can use the Remove iTwin Owner Member API (use the memberId) to remove * the owner member from the iTwin. * */ async queryITwinOwnerMembers(accessToken, iTwinId, arg) { const url = `${this._baseUrl}/${iTwinId}/members/owners${arg ? `?${this.getQueryString(OwnerMembersClient.paginationParamMapping, { top: arg.top, skip: arg.skip })}` : ''}`; return this.sendGenericAPIRequest(accessToken, "GET", url, undefined); } /** Add new iTwin owner member. * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param newMember The new owner member to add or invite * @returns AddOwnerMemberResponse -- the added or invited owner */ async addITwinOwnerMember(accessToken, iTwinId, newMember) { const url = `${this._baseUrl}/${iTwinId}/members/owners`; return this.sendGenericAPIRequest(accessToken, "POST", url, newMember); } /** Remove the specified owner 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 removeITwinOwnerMember(accessToken, iTwinId, memberId) { const url = `${this._baseUrl}/${iTwinId}/members/owners/${memberId}`; return this.sendGenericAPIRequest(accessToken, "DELETE", url); } } exports.OwnerMembersClient = OwnerMembersClient; //# sourceMappingURL=OwnerMembersClient.js.map