UNPKG

@itwin/imodels-client-management

Version:

iModels API client wrapper for applications that manage iModels.

99 lines 4.84 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { AxiosRestClient, AxiosRetryPolicy, ExponentialBackoffAlgorithm, } from "./base/axios"; import { IModelsErrorParser } from "./base/internal"; import { Constants } from "./Constants"; import { BriefcaseOperations, ChangesetOperations, IModelOperations, NamedVersionOperations, OperationOperations, ThumbnailOperations, UserOperations, UserPermissionOperations, } from "./operations"; import { ChangesetExtendedDataOperations } from "./operations/changeset-extended-data/ChangesetExtendedDataOperations"; import { ChangesetGroupOperations } from "./operations/changeset-group/ChangesetGroupOperations"; import { CheckpointOperations } from "./operations/checkpoint/CheckpointOperations"; import { IModelsApiUrlFormatter } from "./operations/IModelsApiUrlFormatter"; /** * iModels API client for iModel management workflows. For more information on the API visit the * {@link https://developer.bentley.com/apis/imodels-v2/ iModels API documentation page}. */ export class IModelsClient { _operationsOptions; /** * Class constructor. * @param {iModelsClientOptions} options client options. If `options` are `undefined` or if some of the properties * are `undefined` the client uses defaults. See {@link iModelsClientOptions}. */ constructor(options) { const filledIModelsClientOptions = IModelsClient.fillManagementClientConfiguration(options); this._operationsOptions = { ...filledIModelsClientOptions, parseErrorFunc: (response, originalError) => IModelsErrorParser.parse(response, originalError), urlFormatter: new IModelsApiUrlFormatter(filledIModelsClientOptions.api.baseUrl), }; } /** iModel operations. See {@link iModelOperations}. */ get iModels() { return new IModelOperations(this._operationsOptions, this); } /** Briefcase operations. See {@link BriefcaseOperations}. */ get briefcases() { return new BriefcaseOperations(this._operationsOptions, this); } /** Changeset operations. See {@link ChangesetOperations}. */ get changesets() { return new ChangesetOperations(this._operationsOptions, this); } /** Changeset Extended Data operations. See {@link ChangesetExtendedDataOperations}. */ get changesetExtendedData() { return new ChangesetExtendedDataOperations(this._operationsOptions); } /** Changeset Group operations. See {@link ChangesetGroupOperations}. */ get changesetGroups() { return new ChangesetGroupOperations(this._operationsOptions, this); } /** Named version operations. See {@link NamedVersionOperations}. */ get namedVersions() { return new NamedVersionOperations(this._operationsOptions, this); } /** Checkpoint operations. See {@link CheckpointOperations}. */ get checkpoints() { return new CheckpointOperations(this._operationsOptions); } /** Thumbnail operations. See {@link ThumbnailOperations}. */ get thumbnails() { return new ThumbnailOperations(this._operationsOptions); } /** User operations. See {@link UserOperations}. */ get users() { return new UserOperations(this._operationsOptions); } /** User Permission operations. See {@link UserPermissionOperations}. */ get userPermissions() { return new UserPermissionOperations(this._operationsOptions); } /** Operation operations. See {@link OperationOperations}. */ get operations() { return new OperationOperations(this._operationsOptions); } static fillManagementClientConfiguration(options) { const retryPolicy = options?.retryPolicy ?? new AxiosRetryPolicy({ maxRetries: Constants.retryPolicy.maxRetries, backoffAlgorithm: new ExponentialBackoffAlgorithm({ baseDelayInMs: Constants.retryPolicy.baseDelayInMs, factor: Constants.retryPolicy.delayFactor, }), }); return { api: this.fillApiConfiguration(options?.api), restClient: options?.restClient ?? new AxiosRestClient(retryPolicy), headers: options?.headers ?? {}, retryPolicy, }; } static fillApiConfiguration(apiOptions) { return { baseUrl: apiOptions?.baseUrl ?? Constants.api.baseUrl, version: apiOptions?.version ?? Constants.api.version, }; } } //# sourceMappingURL=IModelsClient.js.map