UNPKG

@itwin/imodels-client-authoring

Version:

iModels API client wrapper for applications that author iModels.

53 lines 2.68 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { EntityListIteratorImpl, OperationsBase, } from "@itwin/imodels-client-management"; export class LockOperations extends OperationsBase { /** * Gets Locks for a specific iModel. This method returns Locks in their full representation. The returned iterator * internally queries entities in pages. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-locks/ Get iModel Locks} operation from * iModels API. * @param {GetLockListParams} params parameters for this operation. See {@link GetLockListParams}. * @returns {EntityListIterator<Lock>} iterator for Lock list. See {@link EntityListIterator}, {@link Lock}. */ getList(params) { return new EntityListIteratorImpl(async () => this.getEntityCollectionPage({ authorization: params.authorization, url: this._options.urlFormatter.getLockListUrl({ iModelId: params.iModelId, urlParams: params.urlParams, }), entityCollectionAccessor: (response) => response.body.locks, headers: params.headers, })); } /** * Updates Lock for a specific Briefcase. This operation is used to acquire new locks and change the lock level for * already existing ones. Wraps the {@link https://developer.bentley.com/apis/imodels-v2/operations/update-imodel-locks/ * Update iModel Locks} operation from iModels API. * @param {UpdateLockParams} params parameters for this operation. See {@link UpdateLockParams}. * @returns {Promise<Lock>} updated Lock. See {@link Lock}. */ async update(params) { const updateLockBody = this.getUpdateLockBody(params); const updateLockResponse = await this.sendPatchRequest({ authorization: params.authorization, url: this._options.urlFormatter.getLockListUrl({ iModelId: params.iModelId, }), body: updateLockBody, headers: params.headers, }); return updateLockResponse.body.lock; } getUpdateLockBody(params) { return { briefcaseId: params.briefcaseId, changesetId: params.changesetId, lockedObjects: params.lockedObjects, }; } } //# sourceMappingURL=LockOperations.js.map