packageDocumentation module import { AccessToken , GuidString , Logger } from "@itwin/core-bentley" ; import { ECJsonTypeMap , WsgInstance } from "../wsg/ECJsonTypeMap" ; import { IModelHubClientLoggerCategory } from "../IModelHubClientLoggerCategories" ; import { IModelBaseHandler } from "./BaseHandler" ; const loggerCategory = IModelHubClientLoggerCategory . IModelHub ; internal @ ECJsonTypeMap . classToJson ( "wsg" , "iModelScope.Permission" , { schemaPropertyName : "schemaName" , classPropertyName : "className" } ) export class IModelPermissions extends WsgInstance { /** Allows to view iModel in web browser, but does not allow to get its local copy. */ @ ECJsonTypeMap . propertyToJson ( "wsg" , "properties.WebView" ) public webView ? : string ; /** Allows to open and view an iModel only in read-only state. */ @ ECJsonTypeMap . propertyToJson ( "wsg" , "properties.Read" ) public read ? : string ; /** Allows to make changes to an iModel and create/modify named versions. */ @ ECJsonTypeMap . propertyToJson ( "wsg" , "properties.Write" ) public write ? : string ; /** Allows to manage locks, codes or local copies for the entire iModel. */ @ ECJsonTypeMap . propertyToJson ( "wsg" , "properties.Manage" ) public manage ? : string ; } internal export class PermissionHandler { private _handler : IModelBaseHandler ; param handler internal constructor ( handler ) { this . _handler = handler ; } param imodelId public async getiModelPermissions ( accessToken , imodelId ) { Logger . logInfo ( loggerCategory , "Querying permissions for iModel" , ( ) => ( { iModelId : imodelId } ) ) ; const permissions = await this . _handler . getInstances < IModelPermissions > ( accessToken , IModelPermissions , `/Repositories/iModel--${ imodelId }/iModelScope/Permission` ) ; return permissions [ 0 ] ; } }