/// /** @packageDocumentation * @module iTwinServiceClients */ import { BentleyError, ClientRequestContext, GetMetaDataFunction, HttpStatus } from "@bentley/bentleyjs-core"; import * as https from "https"; /** @beta */ export declare const requestIdHeaderName = "X-Correlation-Id"; /** @beta */ export interface RequestBasicCredentials { user: string; password: string; } /** Typical option to query REST API. Note that services may not quite support these fields, * and the interface is only provided as a hint. * @beta */ export interface RequestQueryOptions { /** * Select string used by the query (use the mapped EC property names, and not TypeScript property names) * Example: "Name,Size,Description" */ $select?: string; /** * Filter string used by the query (use the mapped EC property names, and not TypeScript property names) * Example: "Name like '*.pdf' and Size lt 1000" */ $filter?: string; /** Sets the limit on the number of entries to be returned by the query */ $top?: number; /** Sets the number of entries to be skipped */ $skip?: number; /** * Orders the return values (use the mapped EC property names, and not TypeScript property names) * Example: "Size desc" */ $orderby?: string; /** * Sets the limit on the number of entries to be returned by a single response. * Can be used with a Top option. For example if Top is set to 1000 and PageSize * is set to 100 then 10 requests will be performed to get result. */ $pageSize?: number; } /** @beta */ export interface RequestQueryStringifyOptions { delimiter?: string; encode?: boolean; } /** Option to control the time outs * Use a short response timeout to detect unresponsive networks quickly, and a long deadline to give time for downloads on slow, * but reliable, networks. Note that both of these timers limit how long uploads of attached files are allowed to take. Use long * timeouts if you're uploading files. * @beta */ export interface RequestTimeoutOptions { /** Sets a deadline (in milliseconds) for the entire request (including all uploads, redirects, server processing time) to complete. * If the response isn't fully downloaded within that time, the request will be aborted */ deadline?: number; /** Sets maximum time (in milliseconds) to wait for the first byte to arrive from the server, but it does not limit how long the entire * download can take. Response timeout should be at least few seconds longer than just the time it takes the server to respond, because * it also includes time to make DNS lookup, TCP/IP and TLS connections, and time to upload request data. */ response?: number; } /** @beta */ export interface RequestOptions { method: string; headers?: any; auth?: RequestBasicCredentials; body?: any; qs?: any | RequestQueryOptions; responseType?: string; timeout?: RequestTimeoutOptions; stream?: any; readStream?: any; buffer?: any; parser?: any; accept?: string; redirects?: number; errorCallback?: (response: any) => ResponseError; retryCallback?: (error: any, response: any) => boolean; progressCallback?: (progress: ProgressInfo) => void; agent?: https.Agent; retries?: number; useCorsProxy?: boolean; } /** Response object if the request was successful. Note that the status within the range of 200-299 are considered as a success. * @beta */ export interface Response { body: any; text: string | undefined; header: any; status: number; } /** @beta */ export interface ProgressInfo { percent?: number; total?: number; loaded: number; } /** @beta */ export declare class RequestGlobalOptions { static httpsProxy?: https.Agent; static timeout: RequestTimeoutOptions; } /** Error object that's thrown/rejected if the Request fails due to a network error, or if the status is *not* in the range of 200-299 (inclusive) * @beta */ export declare class ResponseError extends BentleyError { protected _data?: any; status?: number; description?: string; constructor(errorNumber: number | HttpStatus, message?: string, getMetaData?: GetMetaDataFunction); /** * Parses error from server's response * @param response Http response from the server. * @returns Parsed error. * @internal */ static parse(response: any, log?: boolean): ResponseError; /** * Decides whether request should be retried or not * @param error Error returned by request * @param response Response returned by request * @internal */ static shouldRetry(error: any, response: any): boolean; /** * @internal */ static parseHttpStatus(statusType: number): HttpStatus; /** * @internal */ logMessage(): string; /** * Logs this error * @internal */ log(): void; } /** Wrapper around HTTP request utility * @param requestContext The client request context * @param url Server URL to address the request * @param options Options to pass to the request * @returns Resolves to the response from the server * @throws ResponseError if the request fails due to network issues, or if the returned status is *outside* the range of 200-299 (inclusive) * @internal */ export declare function request(requestContext: ClientRequestContext, url: string, options: RequestOptions): Promise; /** * fetch array buffer from HTTP request * @param url server URL to address the request * @internal */ export declare function getArrayBuffer(requestContext: ClientRequestContext, url: string): Promise; /** * fetch json from HTTP request * @param url server URL to address the request * @internal */ export declare function getJson(requestContext: ClientRequestContext, url: string): Promise; //# sourceMappingURL=Request.d.ts.map