UNPKG

@itwin/reality-data-client

Version:

HTTP Client for the iTwin Platform Reality Management APIs

216 lines 11 kB
/** @packageDocumentation * @module RealityDataClient */ import { type AccessToken } from "@itwin/core-bentley"; import type { AuthorizationClient, CartographicRange, RealityDataAccess } from "@itwin/core-common"; import { ITwinRealityData } from "./RealityData"; import { Project } from "./Projects"; /** Options for initializing Reality Data Client * @beta */ export interface RealityDataClientOptions { /** The authorization client to use to get access token to Context Share API (authority: https://ims.bentley.com ) * When define it will ignore accessToken from API parameters and will get an access token from this client. */ authorizationClient?: AuthorizationClient; /** API Version. v1 by default */ version?: ApiVersion; /** API Url. Used to select environment. Defaults to "https://api.bentley.com/reality-management" */ baseUrl?: string; } /** Available Reality Management API Versions */ export declare enum ApiVersion { v1 = 0 } /** Criteria used to query for reality data associated with an iTwin context. * @see getRealityDatas * @beta */ export interface RealityDataQueryCriteria { /** If supplied, only reality data overlapping this range will be included. */ extent?: CartographicRange; /** If true, return all properties for every reality data found in query. * If false or undefined, return a minimal representation containing id, displayName and type, along with a url to get full reality data details. */ getFullRepresentation?: boolean; /** If supplied, queries a maximum number of first results Found. Max 500. If not supplied, the query should return the first 100 RealityData found.*/ top?: number; /** Continuation token to get current query's next results.*/ continuationToken?: string; /** Parameter that orders reality data in ascending or descending order. Default is ascending (asc). Can be used on any simple text, date or number property. Example : size desc */ orderBy?: string; /** Searches the given text (case insensitive) in reality data's text properties, such as in Group, DisplayName, Description, RootDocument, Acquirer, Tags. */ search?: string; /** Queries for reality data of specified types.*/ types?: string[]; /** Queries for reality data in which the acquisition is in given date range.*/ acquisitionDates?: DateRange; /** Queries for reality data where the creation date is in given date range.*/ createdDateTime?: DateRange; /** Queries for reality data with exact matching tag.*/ tag?: string; } /** Date range*/ export interface DateRange { startDateTime: Date; endDateTime: Date; } /** * Response object containing RealityData and continuation token */ export interface RealityDataResponse { realityDatas: ITwinRealityData[]; continuationToken?: string; } /** * Client wrapper to Reality Management API. * An instance of this class is used to extract reality data from the Reality Management API. * Most important methods enable to obtain a specific reality data, fetch all reality data associated with an iTwin and * all reality data of an iTwin within a provided spatial extent. * This class also implements extraction of the Azure blob address. * @beta */ export declare class RealityDataAccessClient implements RealityDataAccess { readonly baseUrl: string; readonly apiVersion: ApiVersion; readonly authorizationClient: AuthorizationClient | undefined; /** * Creates an instance of RealityDataAccessClient. */ constructor(realityDataClientOptions?: RealityDataClientOptions); /** * Ensures the reality data client points to Reality Management API, as many users hardcode the url to the deprecated Reality Data API. * @param baseUrl base url given by users of this client * @returns base url to Reality Management API */ private setBaseUrl; /** * Try to use authorizationClient in RealityDataClientOptions to get the access token * otherwise, will return the input token * This is a workaround to support different authorization client for the reality data client and iTwin-core. */ private resolveAccessToken; /** * This method returns the URL to obtain the Reality Data details. * Technically it should never be required as the RealityData object returned should have all the information to obtain the * data. * @param iTwinId the iTwin identifier * @param realityDataId realityData identifier * @returns string containing the URL to reality data for indicated tile. * @beta */ getRealityDataUrl(iTwinId: string | undefined, realityDataId: string): Promise<string>; /** * Gets reality data with all of its properties * @param accessToken The client request context. * @param iTwinId id of associated iTwin (or project) * @param realityDataId realityData identifier * @returns The requested reality data. * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 404 when the specified reality data is not found * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ getRealityData(accessToken: AccessToken, iTwinId: string | undefined, realityDataId: string): Promise<ITwinRealityData>; /** * Gets all reality data associated with the iTwin. * @param accessToken The client request context. * @param iTwinId id of associated iTwin * @param criteria Criteria by which to query. * @returns an array of RealityData that are associated to the iTwin. * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ getRealityDatas(accessToken: AccessToken, iTwinId: string | undefined, criteria: RealityDataQueryCriteria | undefined): Promise<RealityDataResponse>; /** * trims milliseconds from date.toISOString() method to conform to for date parameters in the API. * See https://developer.bentley.com/apis/reality-management/operations/get-all-reality-data/#request-parameters * @param date date to format * @returns dateTime string in format YYYY-MM-DDTHH:mm:ssZ e.g. 2021-08-01T00:00:00Z */ private formatIsoString; private extractContinuationToken; /** * Retrieves the list of Projects associated to the specified realityData. * @deprecated in 1.0.1, getRealityDataProjects is deprecated and no longer used as Projects API is deprecated. Use getRealityDatasITwins method. * @param accessToken The client request context. * @param realityDataId realityData identifier * @returns an array of Projects that are associated to the realityData. * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @beta */ getRealityDataProjects(accessToken: AccessToken, realityDataId: string): Promise<Project[]>; /** * Retrieves the list of iTwins associated to the specified realityData. * @param accessToken The client request context. * @param realityDataId realityData identifier * @returns an array of iTwin identifiers that are associated to the realityData. * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @beta */ getRealityDataITwins(accessToken: AccessToken, realityDataId: string): Promise<string[]>; /** * Creates a RealityData * @param accessToken The client request context. * @param iTwinId id of associated iTwin * @param iTwinRealityData the realityData to create * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 403 when user does not have required permissions to create a reality data * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ createRealityData(accessToken: AccessToken, iTwinId: string | undefined, iTwinRealityData: ITwinRealityData): Promise<ITwinRealityData>; /** * Modifies an existing RealityData * @param accessToken The client request context. * @param iTwinId id of associated iTwin * @param iTwinRealityData the realityData to modify * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 404 when the specified reality data was not found * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ modifyRealityData(accessToken: AccessToken, iTwinId: string | undefined, iTwinRealityData: ITwinRealityData): Promise<ITwinRealityData>; /** * Deletes a RealityData * @param accessToken The client request context. * @param realityDataId the realityData to delete * @returns true if successful (204 response), false if not * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 404 when the specified reality data was not found * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ deleteRealityData(accessToken: AccessToken, realityDataId: string): Promise<boolean>; /** * Associates a RealityData to an iTwin * @param accessToken The client request context. * @param iTwinId id of iTwin to associate the realityData to. * @param realityDataId id of the RealityData. * @returns true if successful (200 response) or false if not * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 404 when the specified reality data or iTwin was not found * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ associateRealityData(accessToken: AccessToken, iTwinId: string, realityDataId: string): Promise<boolean>; /** * Dissociates a RealityData from an iTwin * @param accessToken The client request context. * @param iTwinId id of iTwin to dissociate the realityData from. * @param realityDataId id of the RealityData. * @returns true if successful (204 response) or false if not * @throws [[BentleyError]] with code 401 when the request lacks valid authentication credentials * @throws [[BentleyError]] with code 404 when the association between the reality data and iTwin was not found * @throws [[BentleyError]] with code 422 when the request is invalid * @beta */ dissociateRealityData(accessToken: AccessToken, iTwinId: string, realityDataId: string): Promise<boolean>; /** * Handle errors thrown. * Handled errors can be of AxiosError type or BentleyError. * @beta */ private handleError; } //# sourceMappingURL=RealityDataClient.d.ts.map