/** @packageDocumentation * @module iModelHubClient */ import { ClientRequestContext, GuidString } from "@bentley/bentleyjs-core"; import { ContextType } from "@bentley/context-registry-client"; import { AccessToken, AuthorizedClientRequestContext, Response, WsgInstance } from "@bentley/itwin-client"; import { IModelBaseHandler } from "./BaseHandler"; import { BaseEventSAS, EventBaseHandler, IModelHubBaseEvent } from "./EventsBase"; /** Type of [[IModelHubGlobalEvent]]. Global Event type is used to define which events you wish to receive from your [[GlobalEventSubscription]]. See [[GlobalEventSubscriptionHandler.create]] and [[GlobalEventSubscriptionHandler.update]]. * @internal */ export declare type GlobalEventType = /** Sent when an iModel is put into the archive. See [[SoftiModelDeleteEvent]]. * @internal Rename to SoftIModelDeleteEvent */ "SoftiModelDeleteEvent" | /** Sent when an archived iModel is completely deleted from the storage. See [[HardiModelDeleteEvent]]. * @internal Rename to HardIModelDeleteEvent */ "HardiModelDeleteEvent" | /** Sent when an iModel is created. See [[IModelCreatedEvent]]. * @internal Rename to IModelCreatedEvent */ "iModelCreatedEvent" | /** Sent when a [[ChangeSet]] is pushed. See [[ChangeSetCreatedEvent]]. */ "ChangeSetCreatedEvent" | /** Sent when a named [[Version]] is created. See [[NamedVersionCreatedEvent]]. */ "NamedVersionCreatedEvent" | /** Sent when a new [[Checkpoint]] is generated. See [[GlobalCheckpointCreatedEvent]]. */ "CheckpointCreatedEvent" | /** Sent when a new [[CheckpointV2]] is generated. See [[GlobalCheckpointV2CreatedEvent]]. */ "CheckpointV2CreatedEvent"; /** Base type for all iModelHub global events. * @internal */ export declare abstract class IModelHubGlobalEvent extends IModelHubBaseEvent { /** Id of the iModel that caused this event. */ iModelId?: GuidString; /** Id of the [[Project]] that this iModel belongs to. */ projectId?: string; /** Id of the context ([[Project]] or [[Asset]]) that this iModel belongs to. */ contextId?: string; /** Type of the context ([[Project]] or [[Asset]]) that this iModel belongs to. */ contextTypeId?: ContextType; /** Construct this global event from object instance. * @param obj Object instance. * @internal */ fromJson(obj: any): void; } /** Sent when an iModel is put into the archive. See [[IModelHandler.delete]]. * @internal Rename to SoftIModelDeleteEvent */ export declare class SoftiModelDeleteEvent extends IModelHubGlobalEvent { } /** Sent when an archived iModel is completely deleted from the storage. Sent after some time passes after [[IModelHandler.delete]] and iModel is no longer kept in the archive. iModel is kept at least 30 days in the archive. * @internal Rename to HardIModelDeleteEvent */ export declare class HardiModelDeleteEvent extends IModelHubGlobalEvent { } /** Sent when an iModel is created. See [[IModelHandler.create]]. * @internal */ export declare class IModelCreatedEvent extends IModelHubGlobalEvent { } /** Sent when a [[ChangeSet]] is pushed. See [[ChangeSetHandler.create]]. Sent together with [[ChangeSetPostPushEvent]]. * @internal */ export declare class ChangeSetCreatedEvent extends IModelHubGlobalEvent { changeSetId?: string; changeSetIndex?: string; briefcaseId?: number; /** Construct this event from object instance. * @param obj Object instance. */ fromJson(obj: any): void; } /** Sent when a named [[Version]] is created. See [[VersionHandler.create]]. * @internal */ export declare class NamedVersionCreatedEvent extends IModelHubGlobalEvent { versionId?: GuidString; versionName?: string; changeSetId?: string; /** Construct this event from object instance. * @param obj Object instance. */ fromJson(obj: any): void; } /** Sent when a new [[Checkpoint]] is generated. [[Checkpoint]]s can be generated daily when there are new [[ChangeSet]]s pushed or when a new [[Version]] is created. * @internal */ export declare class GlobalCheckpointCreatedEvent extends IModelHubGlobalEvent { changeSetIndex?: string; changeSetId?: string; versionId?: GuidString; /** Construct this event from object instance. * @param obj Object instance. */ fromJson(obj: any): void; } /** Sent when a new [[CheckpointV2]] is generated. [[CheckpointV2]] might be created for every [[ChangeSet]]. * @internal */ export declare class GlobalCheckpointV2CreatedEvent extends IModelHubGlobalEvent { changeSetIndex?: string; changeSetId?: string; versionId?: GuidString; /** Construct this event from object instance. * @param obj Object instance. */ fromJson(obj: any): void; } /** Parse [[IModelHubGlobalEvent]] from response object. * @param response Response object to parse. * @returns Appropriate global event object. * @internal */ export declare function ParseGlobalEvent(response: Response, handler?: IModelBaseHandler, sasToken?: string): IModelHubGlobalEvent; /** Subscription to receive [[IModelHubGlobalEvent]]s. Each subscription has a separate queue for events that it hasn't read yet. Global event subscriptions do not expire and must be deleted by the user. Use wsgId of this instance for the methods that require subscriptionId. See [[GlobalEventSubscriptionHandler]]. * @internal */ export declare class GlobalEventSubscription extends WsgInstance { eventTypes?: GlobalEventType[]; subscriptionId?: string; } /** Shared access signature token for getting [[IModelHubGlobalEvent]]s. It's used to authenticate for [[GlobalEventHandler.getEvent]]. To receive an instance call [[GlobalEventHandler.getSASToken]]. * @internal */ export declare class GlobalEventSAS extends BaseEventSAS { } /** Handler for managing [[GlobalEventSubscription]]s. * Use [[GlobalEventHandler.Subscriptions]] to get an instance of this class. * @internal */ export declare class GlobalEventSubscriptionHandler { private _handler; /** Constructor for GlobalEventSubscriptionHandler. * @param handler Handler for WSG requests. * @internal */ constructor(handler: IModelBaseHandler); /** Get relative url for GlobalEventSubscription requests. * @param instanceId Id of the subscription. */ private getRelativeUrl; /** Create a [[GlobalEventSubscription]]. You can use this to get or update the existing subscription instance, if you only have the original subscriptionId. * @param requestContext The client request context * @param subscriptionId Guid to be used by global event subscription. It will be a part of the resulting subscription id. * @param globalEvents Array of GlobalEventTypes to subscribe to. * @return Created GlobalEventSubscription instance. * @throws [[IModelHubError]] with [IModelHubStatus.EventSubscriptionAlreadyExists]($bentley) if [[GlobalEventSubscription]] already exists with the specified subscriptionId. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ create(requestContext: AuthorizedClientRequestContext, subscriptionId: GuidString, globalEvents: GlobalEventType[]): Promise; /** Update a [[GlobalEventSubscription]]. Can change the [[GlobalEventType]]s specified in the subscription. Must be a valid subscription that was previously created with [[GlobalEventSubscriptionHandler.create]]. * @param requestContext The client request context. * @param subscription Updated GlobalEventSubscription. * @return GlobalEventSubscription instance from iModelHub after update. * @throws [[IModelHubError]] with [IModelHubStatus.EventSubscriptionDoesNotExist]($bentley) if [[GlobalEventSubscription]] does not exist with the specified subscription.wsgId. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ update(requestContext: AuthorizedClientRequestContext, subscription: GlobalEventSubscription): Promise; /** Delete a [[GlobalEventSubscription]]. * @param requestContext The client request context. * @param subscriptionId WSG Id of the GlobalEventSubscription. * @returns Resolves if the GlobalEventSubscription has been successfully deleted. * @throws [[IModelHubError]] with [IModelHubStatus.EventSubscriptionDoesNotExist]($bentley) if GlobalEventSubscription does not exist with the specified subscription.wsgId. * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ delete(requestContext: AuthorizedClientRequestContext, subscriptionId: string): Promise; } /** Type of [[GlobalEventHandler.getEvent]] operations. * @internal */ export declare enum GetEventOperationType { /** Event will be immediately removed from queue. */ Destructive = 0, /** Event will be locked instead of removed. It has to be later removed via [[IModelHubBaseEvent.delete]]. */ Peek = 1 } /** Handler for receiving [[IModelHubGlobalEvent]]s. * Use [[IModelClient.GlobalEvents]] to get an instance of this class. * @internal */ export declare class GlobalEventHandler extends EventBaseHandler { private _subscriptionHandler; /** Constructor for GlobalEventHandler. * @param handler Handler for WSG requests. * @internal */ constructor(handler: IModelBaseHandler); /** Get a handler for managing [[GlobalEventSubscription]]s. */ get subscriptions(): GlobalEventSubscriptionHandler; /** Get relative url for GlobalEventSAS requests. */ private getGlobalEventSASRelativeUrl; /** Get global event SAS Token. Used to authenticate for [[GlobalEventHandler.getEvent]]. * @param requestContext The client request context * @throws [Common iModelHub errors]($docs/learning/iModelHub/CommonErrors) */ getSASToken(requestContext: AuthorizedClientRequestContext): Promise; /** Get absolute url for global event requests. * @param baseAddress Base address for the serviceBus. * @param subscriptionId Id of the subscription instance. * @param timeout Optional timeout for long polling. */ private getGlobalEventUrl; /** Get an [[IModelHubGlobalEvent]] from the [[GlobalEventSubscription]]. You can use long polling timeout, to have requests return when events are available (or request times out), rather than returning immediately when no events are found. * @param requestContext The client request context * @param sasToken SAS Token used to authenticate. See [[GlobalEventSAS.sasToken]]. * @param baseAddress Address for the events. See [[GlobalEventSAS.baseAddress]]. * @param subscriptionId Id of the subscription to the topic. See [[GlobalEventSubscription]]. * @param timeout Optional timeout duration in seconds for request, when using long polling. * @return IModelHubGlobalEvent if it exists, undefined otherwise. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) or [IModelHubStatus.InvalidArgumentError]($bentley) if one of the arguments is undefined or has an invalid value. * @throws [[ResponseError]] if request has failed. */ getEvent(requestContext: ClientRequestContext, sasToken: string, baseAddress: string, subscriptionId: string, timeout?: number, getOperation?: GetEventOperationType): Promise; /** Create a listener for long polling events from a [[GlobalEventSubscription]]. When event is received from the subscription, every registered listener callback is called. This continuously waits for events until all created listeners for that subscriptionInstanceId are deleted. [[GlobalEventSAS]] token expirations are handled automatically, [[AccessToken]] expiration is handled by calling authenticationCallback to get a new token. * @param authenticationCallback Callback used to get AccessToken. Only the first registered authenticationCallback for this subscriptionId will be used. * @param subscriptionInstanceId Id of GlobalEventSubscription. * @param listener Callback that is called when an [[IModelHubGlobalEvent]] is received. * @returns Function that deletes the created listener. * @throws [[IModelHubClientError]] with [IModelHubStatus.UndefinedArgumentError]($bentley) or [IModelHubStatus.InvalidArgumentError]($bentley) if one of the arguments is undefined or has an invalid value. */ createListener(requestContext: AuthorizedClientRequestContext, authenticationCallback: () => Promise, subscriptionInstanceId: string, listener: (event: IModelHubGlobalEvent) => void): () => void; } //# sourceMappingURL=GlobalEvents.d.ts.map