import { Metadata } from "grpc";
import { HttpHeader } from "./types";
import { EnvoyHttpRequestInit } from "./envoy-http-request-params";
import EnvoyContext from "./envoy-context";
/**
 * json header
 * @internal
 */
export declare const APPLICATION_JSON = "application/json";
/**
 * a high level http client that will send traffic to Envoy:
 * 1. all HTTP GET / POST ... will be wrapped as async signature
 * 2. doing JSON RESET API common works: accepting object, return objects, only works with `application/json`
 * 3. none 2XX request will be throw as Error
 */
export default class EnvoyHttpClient {
    /**
     * the envoy context where you can read
     */
    envoyContext: EnvoyContext;
    /**
     * init the client
     * @param ctx context, you can give either EnvoyContext, Metadata or HTTP Header
     *  the last two will be convert to EnvoyContext
     */
    constructor(ctx: EnvoyContext | Metadata | HttpHeader);
    /**
     * the common logic for json processing and error handling
     * @param response response from fetch
     */
    private returnJsonOrError;
    actionWithoutBody(method: string, url: string, init?: EnvoyHttpRequestInit): Promise<any>;
    /**
     * send a GET request and expecting return json or empty
     * @param url the URL to get
     * @param init the params for the request, like retry, timeout
     * @throws Error for none 2XX request, a $statusCode will be available in the error object
     */
    get(url: string, init?: EnvoyHttpRequestInit): Promise<any>;
    /**
     * send a DELETE request and expecting return json or empty
     * @param url the URL to get
     * @param init the params for the request, like retry, timeout
     * @throws Error for none 2XX request, a $statusCode will be available in the error object
     */
    delete(url: string, init?: EnvoyHttpRequestInit): Promise<any>;
    actionWithBody(method: string, url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>;
    /**
     * send a POST request and expecting return json or empty
     * @param url the URL to get
     * @param body the request object, will be serialize to JSON when sending out
     * @param init the params for the request, like retry, timeout
     * @throws Error for none 2XX request, a $statusCode will be available in the error object
     */
    post(url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>;
    /**
     * send a PATCH request and expecting return json or empty
     * @param url the URL to get
     * @param body the request object, will be serialize to JSON when sending out
     * @param init the params for the request, like retry, timeout
     * @throws Error for none 2XX request, a $statusCode will be available in the error object
     */
    patch(url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>;
    /**
     * send a PUT request and expecting return json or empty
     * @param url the URL to get
     * @param body the request object, will be serialize to JSON when sending out
     * @param init the params for the request, like retry, timeout
     * @throws Error for none 2XX request, a $statusCode will be available in the error object
     */
    put(url: string, body: any, init?: EnvoyHttpRequestInit): Promise<any>;
}
