/** @packageDocumentation * @module iTwinServiceClients */ import { ClientRequestContext, GetMetaDataFunction, HttpStatus } from "@bentley/bentleyjs-core"; import { AuthorizedClientRequestContext } from "./AuthorizedClientRequestContext"; import { Client, DefaultRequestOptionsProvider } from "./Client"; import { WsgInstance } from "./ECJsonTypeMap"; import { RequestOptions, RequestQueryOptions, ResponseError } from "./Request"; import { AccessToken, AuthorizationToken } from "./Token"; /** Error that was returned by a WSG based service. * @beta */ export declare class WsgError extends ResponseError { constructor(errorNumber: number | HttpStatus, message?: string, getMetaData?: GetMetaDataFunction); /** Attempt to parse the error from the response. * Attempts to parse error data in a format that is returned by WSG services. * This method only accesses data that was parsed by parent class to avoid dependencies on http libraries. * @param response Response from the server. * @returns Parsed error. */ static parse(response: any, log?: boolean): ResponseError; /** * Decides whether request should be retried or not * @param error Error * @param response Response */ static shouldRetry(error: any, response: any): boolean; /** * Gets error status from current WSError and HTTP Status type * @param error Error returned by request * @param response Response returned by request */ static getErrorStatus(errorId: number, httpStatusType: number): number; /** * Get WSError from error string * @param error error to be returned in WSError enum */ static getWSStatusId(error: string): number; /** * Logs this error */ log(): void; } /** * Provider for wsg RequestOptions, used by WsgClient to set defaults. * @internal */ export declare class DefaultWsgRequestOptionsProvider extends DefaultRequestOptionsProvider { /** * Creates an instance of DefaultWsgRequestOptionsProvider and sets up the default options. */ constructor(); } /** * Options for WSG requests sent to the service * @beta */ export interface WsgRequestOptions { ResponseContent?: "FullInstance" | "Empty" | "InstanceId"; RefreshInstances?: boolean; CustomOptions?: any; } /** * Base class for Client implementations of services that are based on WSG * @beta */ export declare abstract class WsgClient extends Client { apiVersion: string; static readonly configHostRelyingPartyUri = "imjs_default_relying_party_uri"; static readonly configUseHostRelyingPartyUriAsFallback = "imjs_use_default_relying_party_uri_as_fallback"; private static _defaultWsgRequestOptionsProvider; protected _url?: string; /** * Creates an instance of Client. * @param apiVersion ApiVersion if the service supports it */ protected constructor(apiVersion: string); /** * Augments request options with defaults returned by the DefaultWsgRequestOptionsProvider. * @note that 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. */ protected setupOptionDefaults(options: RequestOptions): Promise; /** * Implemented by clients to specify the relyingPartyUrl for the service. * @protected * @returns Default relyingPartyUrl for the service. */ protected abstract getRelyingPartyUrl(): string; /** * Gets the URL of the service. * Attempts to discover and cache the URL from the URL Discovery Service. If not * found uses the default URL provided by client implementations. Note that for consistency * sake, the URL is stripped of any trailing "/" * @param excludeApiVersion Pass true to optionally exclude the API version from the URL. * @returns URL for the service */ getUrl(requestContext: ClientRequestContext, excludeApiVersion?: boolean): Promise; /** * Gets the (delegation) access token to access the service * @param authTokenInfo Access token. * @returns Resolves to the (delegation) access token. * @internal */ getAccessToken(requestContext: ClientRequestContext, authorizationToken: AuthorizationToken): Promise; /** used by clients to delete strongly typed instances through the standard WSG REST API */ protected deleteInstance(requestContext: AuthorizedClientRequestContext, relativeUrlPath: string, instance?: T, requestOptions?: WsgRequestOptions): Promise; /** * Used by clients to post strongly typed instances through standard WSG REST API * @param requestContext The client request context * @param typedConstructor Used by clients to post a strongly typed instance through the REST API that's expected to return a standard response. * @param relativeUrlPath Relative path to the REST resource. * @param instance Strongly typed instance to be posted. * @param requestOptions WSG options for the request. * @returns The posted instance that's returned back from the server. */ protected postInstance(requestContext: AuthorizedClientRequestContext, typedConstructor: new () => T, relativeUrlPath: string, instance: T, requestOptions?: WsgRequestOptions): Promise; /** Used by clients to post multiple strongly typed instances through standard WSG REST API * @param requestContext Client request context * @param typedConstructor Used by clients to post a strongly typed instances through the REST API that's expected to return a standard response. * @param relativeUrlPath Relative path to the REST resource. * @param instances Strongly typed instances to be posted. * @param requestOptions WSG options for the request. * @returns The posted instances that's returned back from the server. */ protected postInstances(requestContext: AuthorizedClientRequestContext, typedConstructor: new () => T, relativeUrlPath: string, instances: T[], requestOptions?: WsgRequestOptions): Promise; /** * Used by clients to get strongly typed instances from standard WSG REST queries that return EC JSON instances. * @param requestContext Client request context * @param typedConstructor Constructor function for the type * @param relativeUrlPath Relative path to the REST resource. * @param queryOptions Query options. * @returns Array of strongly typed instances. */ protected getInstances(requestContext: AuthorizedClientRequestContext, typedConstructor: new () => T, relativeUrlPath: string, queryOptions?: RequestQueryOptions): Promise; private getQueryRequestBody; /** Used by clients to get strongly typed instances from standard WSG REST queries that return EC JSON instances. * @param typedConstructor Constructor function for the type * @param relativeUrlPath Relative path to the REST resource. * @param queryOptions Query options. * @returns Array of strongly typed instances. */ protected postQuery(requestContext: AuthorizedClientRequestContext, typedConstructor: new () => T, relativeUrlPath: string, queryOptions: RequestQueryOptions): Promise; } //# sourceMappingURL=WsgClient.d.ts.map