@itwin/access-control-client
Version:
Access control client for the iTwin platform
61 lines • 2.65 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 job operations.
*/
export class ITwinJobsClient extends BaseClient {
/** Create a new ITwinJobsClient instance
* @param url Optional base URL for the access control service. If not provided, defaults to base url.
*/
constructor(url) {
super(url);
}
/** Create a new iTwin Job
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @param iTwinActions The actions of the iTwin Job
* @returns ITwin Job
*/
async createITwinJob(accessToken, iTwinId, iTwinJobActions) {
const url = `${this._baseUrl}/${iTwinId}/jobs`;
return this.sendGenericAPIRequest(accessToken, "POST", url, { actions: iTwinJobActions });
}
/** Gets an iTwin Job.
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @param iTwinJobId The id of the iTwin Job
* @param resultMode (Optional) Access Control result mode: minimal or representation (defaults to minimal)
* @returns ITwin Job
*/
async getITwinJob(accessToken, iTwinId, iTwinJobId, resultMode) {
const headers = this.getResultModeHeaders(resultMode);
const url = `${this._baseUrl}/${iTwinId}/jobs/${iTwinJobId}`;
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, undefined, headers);
}
/** Gets an iTwin Job.
* @param accessToken The client access token string
* @param iTwinId The id of the iTwin
* @param iTwinJobId The id of the iTwin Job
* @returns ITwin Job Actions
*/
async getITwinJobActions(accessToken, iTwinId, iTwinJobId) {
const url = `${this._baseUrl}/${iTwinId}/jobs/${iTwinJobId}/actions`;
return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "actions");
}
/**
* Format result mode parameter into a headers entry
* @param resultMode (Optional) Access Control result mode
* @protected
*/
getResultModeHeaders(resultMode = "minimal") {
return {
prefer: `return=${resultMode}`,
};
}
}
//# sourceMappingURL=ITwinJobsClient.js.map