/**
* Builder function to create request options. Returns an object with helpers to
* easily add commonly used options. The return object is chainable so you can set
* as many options as you want.
* Pass an object to set your own options.
* @param {OptionsHelpers} opts - options to pass to the request
* @returns {OptionsHelpers}
* @function
* @public
* @example
Get with a query an oauth token
* http.get($.data.url, http.options({ query: $.query }).oauth($.configuration.access_token))
*/
export function options(opts?: any): any;
/**
* Make a GET request.
* @public
* @function
* @example Request a resource
* http.get('https://jsonplaceholder.typicode.com/todos')
* @example Request a resource with basic auth
* http.get(
* 'https://jsonplaceholder.typicode.com/todos',
* http.options().basic('user', 'pass')
* )
* @example Request a resource with oauth
* http.get(
* 'https://jsonplaceholder.typicode.com/todos',
* http.options().oauth($.configuration.access_token)
* )
* @param {string} url - URL to access
* @param {CommonRequestOptions} options - Request options
* @state {CommonHttpState}
* @returns {Operation}
*/
export function get(url: string, options: CommonRequestOptions): Operation;
/**
* Make a POST request.
* @public
* @function
* @example Post a JSON object (setting the content-type header)
* http.post(
* "https://jsonplaceholder.typicode.com/todos",
* $.data,
* http.options().json()
* );
* @param {string} url - URL to access
* @param {object} data - Body data to append to the request.
* @param {CommonRequestOptions} options - Request options
* @state {CommonHttpState}
* @returns {Operation}
*/
export function post(url: string, data: object, options: CommonRequestOptions): Operation;
export { req as request };
/**
* Helper functions provided by `http.options`.
*/
export type OptionsHelpers = any;
/**
* Options provided to the HTTP request
*/
export type CommonRequestOptions = {
/**
* - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors.
*/
errors: object | boolean;
/**
* - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
*/
form: object;
/**
* - An object of query parameters to be encoded into the URL.
*/
query: object;
/**
* - An object of headers to append to the request.
*/
headers: object;
/**
* - Parse the response body as json, text or stream. By default will use the response headers.
*/
parseAs: string;
/**
* - Request timeout in ms. Default: 300 seconds.
*/
timeout: number;
/**
* - TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
*/
tls: object;
};
/**
* State object
*/
export type CommonHttpState = any;
/**
* Options provided to the HTTP request
* @typedef {Object} CommonRequestOptions
* @property {object|boolean} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors.
* @property {object} form - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
* @property {object} query - An object of query parameters to be encoded into the URL.
* @property {object} headers - An object of headers to append to the request.
* @property {string} parseAs - Parse the response body as json, text or stream. By default will use the response headers.
* @property {number} timeout - Request timeout in ms. Default: 300 seconds.
* @property {object} tls - TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
*/
/**
* State object
* @typedef {Object} CommonHttpState
* @private
* @property data - the parsed response body
* @property response - the response from the HTTP server, including headers, statusCode, body, etc
* @property references - an array of all previous data objects used in the Job
**/
/**
* Make a HTTP request.
* @public
* @function
* @example
* http.request(
* 'GET',
* 'https://jsonplaceholder.typicode.com/todos'
* )
* @name request
* @param {string} method - The HTTP method to use.
* @param {string} url - URL to resource.
* @param {CommonRequestOptions} options - Request options
* @state {CommonHttpState}
* @returns {Operation}
*/
declare function req(method: string, url: string, options: CommonRequestOptions): Operation;