/** @packageDocumentation * @module iModelHubClient */ import { GuidString } from "@bentley/bentleyjs-core"; import { AuthorizedClientRequestContext, CancelRequest, FileHandler, ProgressCallback, WsgInstance, WsgQuery } from "@bentley/itwin-client"; import { IModelBaseHandler } from "./BaseHandler"; import { IModelClient } from "../IModelClient"; /** Controls whether the user has exclusive or shared access to a local briefcase * @internal */ export declare enum BriefcaseAccessMode { Shared = 0, Exclusive = 1 } /** * Briefcase is a copy of the master file, that user acquires to work with the iModel. Briefcase instance represents metadata about a copy of iModel's master file. * * File properties describe the file that would be downloaded through downloadUrl. It is the most recently updated copy of master file that is stored on iModelHub. These copies do not necessarily have the latest [[ChangeSet]] applied to them. * * briefcaseId is the id that user needs to write into the local copy of master file and use for other iModelHub requests. briefcaseId ranges from 2 to 16777215, see [BriefcaseId]($backend). * @internal */ export declare class Briefcase extends WsgInstance { /** File name of the master file. */ fileName?: string; /** Description of the master file. */ fileDescription?: string; /** Size of the latest copy of the master file in iModelHub. */ fileSize?: string; /** FileId of the master file. */ fileId?: GuidString; /** Id of the briefcase. See [BriefcaseId]($backend) */ briefcaseId?: number; /** Id of the user that acquired this briefcase. */ userId?: string; /** Id of the last [[ChangeSet]] that was merged into the latest copy of master file on iModelHub. */ mergedChangeSetId?: string; /** Date when this briefcase was acquired. */ acquiredDate?: string; /** Date until this briefcase is valid. */ expirationDate?: string; /** Name of the device on which this briefcase is downloaded. */ deviceName?: string; /** Id of the latest [[ChangeSet]] on device. */ changeSetIdOnDevice?: string; /** Shows whether the user who acquired this briefcase can perform write operations. */ isReadOnly?: boolean; /** URL that can be used to download the latest copy of master file from iModelHub. See [[BriefcaseQuery.selectDownloadUrl]]. */ downloadUrl?: string; /** Id of the application that created this Briefcase. */ applicationId?: string; /** Name of the application that created this Briefcase. */ applicationName?: string; accessMode?: BriefcaseAccessMode; localPathname?: string; lastAccessedAt?: Date; iModelId?: GuidString; } /** * Query object for getting [[Briefcase]]s. You can use this to modify the [[BriefcaseHandler.get]] results. * @internal */ export declare class BriefcaseQuery extends WsgQuery { private _byId?; /** * Query single [[Briefcase]] by its id. If briefcase is not found, request will be rejected with a [[WsgError]] and status [WSStatus.InstanceNotFound]($bentley). * @param id Id of the Briefcase. * @returns This query. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) or [IModelHubStatus.InvalidArgumentError]($bentley) if id is undefined or it is not a valid Briefcase id value. */ byId(id: number): this; /** * Used by handler to get the id that is queried. * @returns Value that was set with byId method. * @internal */ getId(): number | undefined; /** * Query will additionally select [[Briefcase]] file download URL. This is needed to use the Briefcase object with [[BriefcaseHandler.download]]. * @returns This query. */ selectDownloadUrl(): this; /** * Query will additionally select data about application that created this [[Briefcase]]. * @returns This query. */ selectApplicationData(): this; /** * Query will select [[Briefcase]]s owned by this user. * @returns This query. */ ownedByMe(): this; } /** * Handler for managing [[Briefcase]]s. Use [[IModelClient.Briefcases]] to get an instance of this class. * In most cases, you should use [BriefcaseDb]($backend) methods instead. * @internal */ export declare class BriefcaseHandler { private _handler; private _imodelClient; private _fileHandler?; /** Constructor for BriefcaseHandler. Use [[IModelClient]] instead of directly constructing this. * @param handler Handler for WSG requests. * @param fileHandler Handler for file system. * @internal */ constructor(handler: IModelBaseHandler, imodelClient: IModelClient, fileHandler?: FileHandler); /** Get relative url for Briefcase requests. * @param iModelId Id of the iModel. See [[HubIModel]]. * @param briefcaseId Id of the briefcase. */ private getRelativeUrl; /** Acquire a [[Briefcase]] for the specified iModel. This assigns you a new briefcaseId and returns you a download link. * A briefcase is automatically acquired when calling [BriefcaseManager.download]($backend) or [BriefcaseDb.create]($backend). You should use this method only when you want to acquire the briefcaseId without downloading the file. If you need just the download link, you can call [[BriefcaseHandler.get]] with [[BriefcaseQuery.selectDownloadUrl]]. * @param requestContext The client request context * @param iModelId Id of the iModel. See [[HubIModel]]. * @param briefcase Information of the Briefcase to acquire. * @returns The acquired Briefcase instance. * @throws [[IModelHubError]] with [IModelHubStatus.MaximumNumberOfBriefcasesPerUser]($bentley) or [IModelHubStatus.MaximumNumberOfBriefcasesPerUserPerMinute]($bentley) if a limit of Briefcases for that user was reached. Users should use the Briefcases they have previously acquired. If that is no longer possible, they should delete them, to be able to acquire new ones. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ create(requestContext: AuthorizedClientRequestContext, iModelId: GuidString, briefcase?: Briefcase): Promise; /** Update the [[Briefcase]] of an iModel. Only [[Briefcase.deviceName]] and [[Briefcase.changeSetIdOnDevice]] can be changed when updating the briefcase. * Briefcase expiration date is also extended with each update request for a configured period of time (default is 30 days). * @param requestContext The client request context. * @param iModelId Id of the iModel. See [[HubIModel]]. * @param briefcase Briefcase to update. * @returns Updated Briefcase instance from iModelHub. * @throws [[IModelHubError]] with [IModelHubStatus.FailedToGetProductSettings]($bentley) if request to get settings to Product Settings service fails. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ update(requestContext: AuthorizedClientRequestContext, iModelId: GuidString, briefcase: Briefcase): Promise; /** Delete the [[Briefcase]] from iModelHub. This frees up the id to be reused later and allows user to acquire additional briefcases if one of the briefcase limits was reached. * @param requestContext The client request context * @param iModelId Id of the iModel. See [[HubIModel]]. * @param briefcaseId Id of the Briefcase to be deleted. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ delete(requestContext: AuthorizedClientRequestContext, iModelId: GuidString, briefcaseId: number): Promise; /** Get the [[Briefcase]]s. * @param requestContext The client request context * @param iModelId Id of the iModel. See [[HubIModel]]. * @param query Optional query object to filter the queried Briefcases or select different data from them. * @returns Briefcases that match the query. * @throws [[WsgError]] with [WSStatus.InstanceNotFound]($bentley) if [[BriefcaseQuery.byId]] is used and a Briefcase with the specified id could not be found. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ get(requestContext: AuthorizedClientRequestContext, iModelId: GuidString, query?: BriefcaseQuery): Promise; /** Download the latest copy of master file. This only downloads the file and does not write the [[Briefcase]] id into it. Use [IModelDb.open]($backend) instead if you want to get a Briefcase file you can work with. * This method does not work on the browser. Directory containing the Briefcase file is created if it does not exist. If there is an error during download, any partially downloaded file is deleted from disk. * @param requestContext The client request context * @param briefcase Briefcase to download. This needs to include a download link. See [[BriefcaseQuery.selectDownloadUrl]]. * @param path Path where briefcase file should be downloaded, including filename. * @param progressCallback Callback for tracking progress. * @param cancelRequest Request used to cancel download * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) or [IModelHubStatus.InvalidArgumentError]($bentley) if one of the arguments is undefined or has an invalid value. * @throws [[IModelHubClientError]] with [IModelHubStatus.NotSupportedInBrowser]($bentley) if called in a browser. * @throws [[IModelHubClientError]] with [IModelHubStatus.FileHandlerNotSet]($bentley) if [[FileHandler]] instance was not set for [[IModelClient]]. * @throws [[ResponseError]] if the briefcase cannot be downloaded. */ download(requestContext: AuthorizedClientRequestContext, briefcase: Briefcase, path: string, progressCallback?: ProgressCallback, cancelRequest?: CancelRequest): Promise; } //# sourceMappingURL=Briefcases.d.ts.map