UNPKG

@itwin/imodels-client-management

Version:

iModels API client wrapper for applications that manage iModels.

66 lines 3.63 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 "../../base/internal"; import { PreferReturn, } from "../../base/types"; export class UserOperations extends OperationsBase { /** Gets Users who have ever been connected to the iModel specified by the iModel id. This method returns Users in * their minimal representation. The returned iterator internally queries entities in pages. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-users/ Get iModel Users} * operation from iModels API. * @param {GetUserListParams} params parameters for this operation. See {@link GetUserListParams}. * @returns {EntityListIterator<MinimalUser>} iterator for User list. See {@link EntityListIterator}, {@link MinimalUser}. */ getMinimalList(params) { return new EntityListIteratorImpl(async () => this.getEntityCollectionPage({ authorization: params.authorization, url: this._options.urlFormatter.getUserListUrl({ iModelId: params.iModelId, urlParams: params.urlParams, }), preferReturn: PreferReturn.Minimal, entityCollectionAccessor: (response) => response.body.users, headers: params.headers, })); } /** * Gets Users who have ever been connected to the iModel specified by the iModel id. This method returns Users 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-users/ Get iModel Users} * operation from iModels API. * @param {GetUserListParams} params parameters for this operation. See {@link GetUserListParams}. * @returns {EntityListIterator<User>} iterator for User list. See {@link EntityListIterator}, {@link User}. */ getRepresentationList(params) { return new EntityListIteratorImpl(async () => this.getEntityCollectionPage({ authorization: params.authorization, url: this._options.urlFormatter.getUserListUrl({ iModelId: params.iModelId, urlParams: params.urlParams, }), preferReturn: PreferReturn.Representation, entityCollectionAccessor: (response) => response.body.users, headers: params.headers, })); } /** * Gets a single User by its id. This method returns a User in its full representation. Wraps the * {@link https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-user-details/ Get iModel User} * operation from iModels API. * @param {GetSingleUserParams} params parameters for this operation. See {@link GetSingleUserParams}. * @returns {Promise<User>} a User with specified id. See {@link User}. */ async getSingle(params) { const response = await this.sendGetRequest({ authorization: params.authorization, url: this._options.urlFormatter.getSingleUserUrl({ iModelId: params.iModelId, userId: params.userId, }), headers: params.headers, }); return response.body.user; } } //# sourceMappingURL=UserOperations.js.map