UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

65 lines 2.82 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * 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.ITwinJobsClient = void 0; const BaseClient_1 = require("./BaseClient"); /** Client API to perform iTwin job operations. */ class ITwinJobsClient extends BaseClient_1.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}`, }; } } exports.ITwinJobsClient = ITwinJobsClient; //# sourceMappingURL=ITwinJobsClient.js.map