@itwin/imodels-client-management
Version:
iModels API client wrapper for applications that manage iModels.
83 lines • 4.63 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* 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 "../../base/internal";
import { PreferReturn, } from "../../base/types";
export class RecentIModelOperations extends OperationsBase {
/**
* Gets recently used iModels for a specific iTwin. A user can only have 25 recently used iModels.
* They are returned in order with the most recently used iModel first in the list. This method returns iModels in their minimal representation.
* The returned iterator internally queries entities in pages. Wraps the
* {@link https://developer.bentley.com/apis/imodels-v2/operations/get-my-recently-used-imodels/ Get My Recently Used iTwin iModels}
* operation from iModels API.
* @param {GetRecentIModelListParams} params parameters for this operation. See {@link GetRecentIModelListParams}.
* @returns {EntityListIterator<MinimalIModel>} iterator for recent iModel list. See {@link EntityListIterator}, {@link MinimalIModel}.
*/
getMinimalList(params) {
return new EntityListIteratorImpl(async () => this.getEntityCollectionPage({
authorization: params.authorization,
url: this._options.urlFormatter.getRecentIModelListUrl({
urlParams: params.urlParams,
}),
preferReturn: PreferReturn.Minimal,
entityCollectionAccessor: (response) => response.body.iModels,
headers: params.headers,
}));
}
/**
* Gets recently used iModels for a specific iTwin. A user can only have 25 recently used iModels.
* They are returned in order with the most recently used iModel first in the list. This method returns iModels in their full representation.
* The returned iterator internally queries entities in pages. Wraps the
* {@link https://developer.bentley.com/apis/imodels-v2/operations/get-my-recently-used-imodels/ Get My Recently Used iTwin iModels}
* operation from iModels API.
* @param {GetRecentIModelListParams} params parameters for this operation. See {@link GetRecentIModelListParams}.
* @returns {EntityListIterator<IModel>} iterator for recent iModel list. See {@link EntityListIterator}, {@link IModel}.
*/
getRepresentationList(params) {
return new EntityListIteratorImpl(async () => this.getEntityCollectionPage({
authorization: params.authorization,
url: this._options.urlFormatter.getRecentIModelListUrl({
urlParams: params.urlParams,
}),
preferReturn: PreferReturn.Representation,
entityCollectionAccessor: (response) => response.body.iModels,
headers: params.headers,
}));
}
/**
* Adds an iModel to the calling user's recently used iModels list. No more than 25 iModels are
* stored in the recently used list. Older ones are removed to make room for new ones. Wraps the
* {@link https://developer.bentley.com/apis/imodels-v2/operations/add-imodel-to-my-recents/ Add iModel to My Recents}
* operation from iModels API.
* @param {AddIModelToRecentsParams} params parameters for this operation. See {@link AddIModelToRecentsParams}.
* @returns {Promise<void>}
*/
async add(params) {
await this.sendPostRequest({
authorization: params.authorization,
url: this._options.urlFormatter.getRecentIModelUrl({
iModelId: params.iModelId,
}),
headers: params.headers,
body: undefined,
});
}
/**
* Removes an iModel from the calling user's recents list. Wraps the
* {@link https://developer.bentley.com/apis/imodels-v2/operations/remove-imodel-from-my-recents/ Remove iModel from My Recents}
* operation from iModels API.
* @param {RemoveIModelFromRecentsParams} params parameters for this operation. See {@link RemoveIModelFromRecentsParams}.
* @returns {Promise<void>}
*/
async remove(params) {
await this.sendDeleteRequest({
authorization: params.authorization,
url: this._options.urlFormatter.getRecentIModelUrl({
iModelId: params.iModelId,
}),
headers: params.headers,
});
}
}
//# sourceMappingURL=RecentIModelOperations.js.map