UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

49 lines 2.05 kB
import { BaseClient } from "./BaseClient"; export class ITwinJobsClient extends BaseClient { 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 createITwinJobAsync(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 getITwinJobAsync(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 getITwinJobActionsAsync(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