@itwin/access-control-client
Version:
Access control client for the iTwin platform
72 lines • 3.1 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* 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.RolesClient = void 0;
const BaseClient_1 = require("./BaseClient");
/** Client API to perform iTwin role operations.
*/
class RolesClient extends BaseClient_1.BaseClient {
/** Create a new RolesClient 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 available user roles that are defined for a specified iTwin
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @returns Roles
*/
async getITwinRoles(accessToken, iTwinId) {
const url = `${this._baseUrl}/${iTwinId}/roles`;
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "roles");
}
/** Retrieves the specified role for the specified iTwin
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @returns Role
*/
async getITwinRole(accessToken, iTwinId, roleId) {
const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "role");
}
/** Creates a new iTwin Role
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @param role The role to be created
* @returns Role
*/
async createITwinRole(accessToken, iTwinId, role) {
const url = `${this._baseUrl}/${iTwinId}/roles`;
return this.sendGenericAPIRequest(accessToken, "POST", url, role, "role");
}
/** Delete the specified iTwin role
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @param roleId The id of the role to remove
* @returns No Content
*/
async deleteITwinRole(accessToken, iTwinId, roleId) {
const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;
return this.sendGenericAPIRequest(accessToken, "DELETE", url);
}
/** Update the specified iTwin role
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @param roleId The id of the role to update
* @param role The updated role
* @returns Role
*/
async updateITwinRole(accessToken, iTwinId, roleId, role) {
const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;
return this.sendGenericAPIRequest(accessToken, "PATCH", url, role, "role");
}
}
exports.RolesClient = RolesClient;
//# sourceMappingURL=RolesClient.js.map