@itwin/access-control-client
Version:
Access control client for the iTwin platform
60 lines • 2.54 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RolesClient = void 0;
const BaseClient_1 = require("./BaseClient");
class RolesClient extends BaseClient_1.BaseClient {
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 getITwinRolesAsync(accessToken, iTwinId, additionalHeaders) {
const url = `${this._baseUrl}/${iTwinId}/roles`;
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "roles", additionalHeaders);
}
/** 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 getITwinRoleAsync(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 createITwinRoleAsync(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 deleteITwinRoleAsync(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 updateITwinRoleAsync(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
;