/** @packageDocumentation * @module iModelHubClient */ import { GuidString } from "@bentley/bentleyjs-core"; import { AuthorizedClientRequestContext, FileHandler, ProgressCallback, WsgInstance } from "@bentley/itwin-client"; import { IModelBaseHandler } from "./BaseHandler"; import { InstanceIdQuery } from "./HubQuery"; /** * HubIModel represents an iModel on iModelHub. Getting a valid HubIModel instance from iModelHub is required for majority of iModelHub method calls, as wsgId of this object needs to be passed as iModelId argument to those methods. * * For iModel representation in iModel.js, see [IModel]($common). For the file that is used for that iModel, see [BriefcaseDb]($backend). * @public */ export declare class HubIModel extends WsgInstance { /** Id of the iModel. */ id?: GuidString; /** Description of the iModel. */ description?: string; /** Name of the iModel. iModels must have unique names per context ([[Project]] or [[Asset]]). */ name?: string; /** Id of the user that created the iModel. */ userCreated?: string; /** Date when iModel was created. */ createdDate?: string; /** Set to true, when iModel is ready to be used. See [[IModelHandler.create]]. */ initialized?: boolean; /** Set when creating iModel from empty seed file * @internal */ iModelTemplate?: string; /** Type of the iModel */ iModelType?: IModelType; /** Extent of iModel. Array of coordinates: [0] - south latitude, [1] - west longitude, [2] - north latitude, [3] - east longitude */ extent?: number[]; /** Set to true, when iModel has custom access control. */ secured?: boolean; /** Data center location id where iModel is stored. */ dataLocationId?: string; } /** Initialization state of seed file. Can be queried with [[IModelHandler.getInitializationState]]. See [iModel creation]($docs/learning/iModelHub/iModels/CreateiModel.md). * @public */ export declare enum InitializationState { /** Initialization was successful. */ Successful = 0, /** Initialization has not started, seed file has not yet been uploaded. */ NotStarted = 1, /** Initialization has been scheduled and has not completed yet. */ Scheduled = 2, /** Initialization failed with a generic error. */ Failed = 3, /** Initialization failed due to file having outdated schemas. */ OutdatedFile = 4, /** Initialization failed due to file having [[Code]] values that are too long. */ CodeTooLong = 5, /** Initialization failed due to file being a [[Briefcase]]. Only standalone and master files are supported for iModel creation, see [BriefcaseId]($backend). */ SeedFileIsBriefcase = 6 } /** iModel type * @public */ export declare enum IModelType { /** iModel has no type. */ Undefined = 0, /** iModel contains metadata used for other iModel creation. */ Library = 1 } /** SeedFile * @internal */ export declare class SeedFile extends WsgInstance { /** Id of the iModel. */ id?: GuidString; fileName?: string; fileDescription?: string; fileSize?: string; fileId?: GuidString; index?: number; iModelName?: string; mergedChangeSetId?: string; userUploaded?: string; uploadedDate?: string; isUploaded?: boolean; initializationState?: InitializationState; downloadUrl?: string; uploadUrl?: string; } /** * Query object for getting [[HubIModel]] instances. You can use this to modify the [[IModelsHandler.get]] results. * @public */ export declare class IModelQuery extends InstanceIdQuery { /** * Query iModel by its name. * @param name Name of the iModel. * @returns This query. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) if name is undefined or empty. */ byName(name: string): this; /** * Query iModel by its type. * @param iModelType Type of the iModel. * @returns This query. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) if iModelType is undefined. */ byiModelType(iModelType: IModelType): this; /** * Query iModel by its template. * @param type Type of the iModel. * @returns This query. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) if iModelTemplate is undefined or empty. * @internal */ byiModelTemplate(iModelTemplate: string): this; } /** * Create an iModel by cloning another. * @internal */ export interface CloneIModelTemplate { /** Source iModel's Id. */ imodelId: string; /** Id of the [[ChangeSet]] on source iModel that should be used as the baseline version. */ changeSetId?: string; } /** * Create an iModel from an empty file. * @internal */ export declare type EmptyIModelTemplate = "Empty"; /** * Options used when creating an [[HubIModel]] with [[IModelHandler.create]] or [[IModelsHandler.create]]. * @public */ export interface IModelCreateOptions { /** iModel seed file path. If not defined, iModel will be created from template. */ path?: string; /** Description of the iModel on the Hub. */ description?: string; /** Callback for tracking progress. */ progressCallback?: ProgressCallback; /** * Time to wait for iModel initialization. When it times out the initialization will continue, but the promise will be rejected. * Default is 2 minutes. */ timeOutInMilliseconds?: number; /** * Template used to create the seed file. Works only when path is not provided. Creates iModel from empty file by default. * @internal */ template?: CloneIModelTemplate | EmptyIModelTemplate; /** Type of iModel. */ iModelType?: IModelType; /** Extent of iModel. Array of coordinates: [0] - south latitude, [1] - west longitude, [2] - north latitude, [3] - east longitude */ extent?: number[]; } /** * Provider for default IModelCreateOptions, used by IModelHandler and IModelsHandler to set defaults. * @internal */ export declare class DefaultIModelCreateOptionsProvider { protected _defaultOptions: IModelCreateOptions; /** Creates an instance of DefaultRequestOptionsProvider and sets up the default options. */ constructor(); /** * Augments options with the provider's default values. The options passed in override any defaults where necessary. * @param options Options that should be augmented. */ assignOptions(options: IModelCreateOptions): Promise; /** * Formats iModel template value as a string. * @param options Options that have the template value. */ templateToString(options: IModelCreateOptions): string | undefined; } /** * Handler for managing [[HubIModel]] instances. Use [[IModelHubClient.IModels]] to get an instance of this handler. * @note Use [[IModelHubClient.IModel]] for the preferred single iModel per context workflow. * @public */ export declare class IModelsHandler { private _handler; private _fileHandler?; private _seedFileHandler; private static _defaultCreateOptionsProvider; private static readonly _imodelExtentLength; private static readonly _imodelExtentLatitudeLimit; private static readonly _imodelExtentLongitudeLimit; /** Constructor for IModelsHandler. Should use @see IModelClient instead of directly constructing this. * @param handler Handler for WSG requests. * @param fileHandler Handler for file system. * @note Use [[IModelHubClient.IModel]] for the preferred single iModel per context workflow. * @internal */ constructor(handler: IModelBaseHandler, fileHandler?: FileHandler); /** Get relative url for iModel requests. * @param contextId Id of the context. * @param iModelId Id of the iModel. See [[HubIModel]]. */ private getRelativeUrl; /** Get iModels that belong to the specified context. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param query Optional query object to filter the queried iModels or select different data from them. * @returns [[HubIModel]] instances that match the query. * @throws [WsgError]($itwin-client) with [WSStatus.InstanceNotFound]($bentley) if [[InstanceIdQuery.byId]] is used and an HubIModel with the specified id could not be found. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ get(requestContext: AuthorizedClientRequestContext, contextId: string, query?: IModelQuery): Promise; /** Delete an iModel with specified id from a context. This method is not supported in iModelBank. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param iModelId Id of the iModel to be deleted. See [[HubIModel]]. * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel with specified id does not exist. * @throws [[IModelHubError]] with [IModelHubStatus.UserDoesNotHavePermission]($bentley) if the user does not have DeleteiModel permission. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ delete(requestContext: AuthorizedClientRequestContext, contextId: string, iModelId: GuidString): Promise; /** Create an iModel instance * @param requestContext The client request context. * @param contextId Id of the iTwin context. * @param iModelName Name of the iModel on the Hub. * @param description Description of the iModel on the Hub. * @param iModelTemplate iModel template. * @param iModelType iModel type. */ private createIModelInstance; /** Get the [[InitializationState]] for the specified iModel. See [iModel creation]($docs/learning/iModelHub/iModels/CreateiModel.md). * @param requestContext The client request context. * @param iModelId Id of the iModel. See [[HubIModel]]. * @returns State of the seed file initialization. * @throws [[IModelHubError]] with [IModelHubStatus.FileDoesNotExist]($bentley) if the seed file was not found. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) * @internal */ getInitializationState(requestContext: AuthorizedClientRequestContext, iModelId: GuidString): Promise; /** * Augment update options with defaults returned by the DefaultIModelCreateOptionsProvider. The options passed in by clients override any defaults where necessary. * @param options Options the caller wants to augment with the defaults. * @returns Promise resolves after the defaults are setup. */ private setupOptionDefaults; /** Wait until the iModel is initialized. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param imodel iModel instance that will be returned if initialization is successful. * @param timeOutInMilliseconds Maximum time to wait for the initialization. */ private waitForInitialization; /** * Verifies iModel extent * @param extent iModel extent * @throws [[IModelHubError]] with [IModelHubStatus.UndefinedArgumentError] if extent is invalid. */ private validateExtent; /** * Validates iModel extent coordinate * @param coordinate iModel extent coordinate * @param limit Coordinate limit value (latitude/longitude max value) * @throws [[IModelHubError]] with [IModelHubStatus.UndefinedArgumentError] if coordinate is invalid. */ private validateExtentCoordinate; /** Create an iModel from given seed file. See [iModel creation]($docs/learning/iModelHub/iModels/CreateiModel.md). * This method does not work on browsers. If iModel creation fails before finishing file upload, partially created iModel is deleted. This method is not supported in iModelBank. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param name Name of the iModel on the Hub. * @param createOptions Optional arguments for iModel creation. * @throws [[IModelHubError]] with [IModelHubStatus.UserDoesNotHavePermission]($bentley) if the user does not have CreateiModel permission. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) * @internal */ create(requestContext: AuthorizedClientRequestContext, contextId: string, name: string, createOptions?: IModelCreateOptions): Promise; /** Update iModel's name and/or description * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param imodel iModel to update. See [[HubIModel]]. * @throws [[IModelHubError]] with [IModelHubStatus.UserDoesNotHavePermission]($bentley) if the user does not have CreateiModel permission. * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel does not exist. * @throws [[IModelHubError]] with [IModelHubStatus.iModelIsNotInitialized]$(bentley) if iModel is not initialized. * @throws [[IModelHubError]] with [IModelHubStatus.iModelAlreadyExists]$(bentley) if iModel with specified name already exists. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ update(requestContext: AuthorizedClientRequestContext, contextId: string, imodel: HubIModel): Promise; /** Method to download the seed file for iModel. This will download the original seed file, that was uploaded when creating iModel. To download a file that was updated with ChangeSets on iModelHub, see [[BriefcaseHandler.download]]. * @param requestContext The client request context. * @param iModelId Id of the iModel. See [[HubIModel]]. * @param path Path to download the seed file to, including file name. * @param progressCallback Callback for tracking progress. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) * @internal */ download(requestContext: AuthorizedClientRequestContext, iModelId: GuidString, path: string, progressCallback?: ProgressCallback): Promise; } /** * Handler for managing [[HubIModel]] instance. Use [[IModelHubClient.IModel]] to get an instance of this handler. * @note Use [[IModelHubClient.IModels]] if multiple iModels per context are supported. * @beta */ export declare class IModelHandler { private _handler; /** * Constructor for IModelHandler. Should use @see IModelClient instead of directly constructing this. * @param handler Handler for managing [[HubIModel]] instances. * @note Use [[IModelHubClient.IModels]] if multiple iModels per context are supported. * @internal */ constructor(handler: IModelsHandler); /** * Get iModel that belong to the specified context. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @returns [[HubIModel]] instances that match the query. * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel does not exist. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ get(requestContext: AuthorizedClientRequestContext, contextId: string): Promise; /** * Delete an iModel from a context. This method is not supported in iModelBank. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel does not exist. * @throws [[IModelHubError]] with [IModelHubStatus.UserDoesNotHavePermission]($bentley) if the user does not have DeleteiModel permission. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ delete(requestContext: AuthorizedClientRequestContext, contextId: string): Promise; /** * Get the [[InitializationState]] for the specified iModel. See [iModel creation]($docs/learning/iModelHub/iModels/CreateiModel.md). * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @returns State of the seed file initialization. * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel does not exist. * @throws [[IModelHubError]] with [IModelHubStatus.FileDoesNotExist]($bentley) if the seed file was not found. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) * @internal */ getInitializationState(requestContext: AuthorizedClientRequestContext, contextId: string): Promise; /** * Create an iModel from given seed file. In most cases [BriefcaseManager.create]($backend) should be used instead. See [iModel creation]($docs/learning/iModelHub/iModels/CreateiModel.md). * * This method does not work on browsers. If iModel creation fails before finishing file upload, partially created iModel is deleted. This method is not supported in iModelBank. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param name Name of the iModel on the Hub. * @param createOptions Optional arguments for iModel creation. * @throws [[IModelHubError]] with [IModelHubStatus.UserDoesNotHavePermission]($bentley) if the user does not have CreateiModel permission. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) * @internal */ create(requestContext: AuthorizedClientRequestContext, contextId: string, name: string, createOptions?: IModelCreateOptions): Promise; /** * Update iModel's name and/or description * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param imodel iModel to update. See [[HubIModel]]. * @throws [[IModelHubError]] with [IModelHubStatus.UserDoesNotHavePermission]($bentley) if the user does not have CreateiModel permission. * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel does not exist. * @throws [[IModelHubError]] with [IModelHubStatus.iModelIsNotInitialized]$(bentley) if iModel is not initialized. * @throws [[IModelHubError]] with [IModelHubStatus.iModelAlreadyExists]$(bentley) if iModel with specified name already exists. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ update(requestContext: AuthorizedClientRequestContext, contextId: string, imodel: HubIModel): Promise; /** * Method to download the seed file for iModel. This will download the original seed file, that was uploaded when creating iModel. To download a file that was updated with ChangeSets on iModelHub, see [[BriefcaseHandler.download]]. * @param requestContext The client request context. * @param contextId Id for the iModel's context. For iModelHub it should be the id of the iTwin context ([[Project]] or [[Asset]]). * @param path Path where seed file should be downloaded, including filename. * @param progressCallback Callback for tracking progress. * @throws [[IModelHubError]] with [IModelHubStatus.iModelDoesNotExist]$(bentley) if iModel does not exist. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) * @internal */ download(requestContext: AuthorizedClientRequestContext, contextId: string, path: string, progressCallback?: ProgressCallback): Promise; } //# sourceMappingURL=iModels.d.ts.map