dt-app
Version:
The Dynatrace App Toolkit is a tool you can use from your command line to create, develop, and deploy apps on your Dynatrace environment.
55 lines (54 loc) • 1.48 kB
TypeScript
import * as dtFetch from 'http';
import type { Readable } from 'stream';
import { URL } from 'url';
/**
* Request options used for the outgoing dt-fetch call
*/
export declare class RequestOptions {
headers?: dtFetch.OutgoingHttpHeaders;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
timeout?: number;
body?: Buffer;
bodyStream?: Readable;
redirect?: 'error' | 'follow' | 'manual';
follow?: number;
counter?: number;
referrer?: string;
referrerPolicy?: string;
}
/**
* Response object returned by a dt-fetch call.
*/
export declare class Response {
statusCode?: number;
statusMessage?: string;
headers?: dtFetch.IncomingHttpHeaders;
url?: string;
private body?;
/**
*
* @returns the body as a JSON object
*/
json(): Promise<any>;
/**
* @returns the body buffer
*/
blob(): Promise<Buffer | undefined>;
/**
* Returns true if the http request was successful
*/
get ok(): boolean;
/**
* Returns true if the response is html
*/
get isHtmlResponse(): boolean | undefined;
}
/**
* Basic implementation of the "fetch" API.
* Executes a http | https request and returns a Response
* object containing status code, status message and response body.
*
* @param url the URL object or plain url string
* @param requestOptions the request options
*/
export declare function fetch(url: string | URL, requestOptions?: RequestOptions): Promise<Response>;