@itwin/access-control-client
Version:
Access control client for the iTwin platform
68 lines • 2.94 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
*/
import { BaseClient } from "./BaseClient";
/** Client API to perform iTwin role operations.
*/
export class RolesClient extends 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");
}
}
//# sourceMappingURL=RolesClient.js.map