Class: DirectAPIRequest

DirectAPIRequest(limits)

The DirectAPIRequest class is a wrapper around Axios to more consistently issue and process Dynatrace API requests. It attempts to responds to and recover from 429 and 503 errors gracefully (up till specified limits). It also automatically aggregates paged responses (from both v1 and v2 APIs). Finally, it unifies the various types of errors that may happen while initializating a request, issuing it, and processing its response. This greatly simplifies writing code that makes Dynatrace API requests.

Constructor

new DirectAPIRequest(limits)

Creates an instance with which any number of API requests can be made.

Parameters:
Name Type Description
limits object

Default values for maxRetries, retryAfter and timeout.

Source:

Methods

(async) fetch(options, onDoneopt) → {EventEmitter|Promise}

Required properties in the RequestOptions object (unless an alias is used - see below):

  • url: URL relative to the baseURL. Ex.: '/api/v2/entities'.
  • baseURL: URL of the Dynatrace tenant. Ex.: 'https://abc12345.live.dynatrace.com'.

For convenience aliases have been provided for the following request methods:

  • get(url, options[, onDone])
  • delete(url, options[, onDone])
  • post(url, data, options[, onDone])
  • put(url, data, options[, onDone])
Parameters:
Name Type Attributes Description
options RequestOptions

The request options, Axios-style.

onDone RequestCallback <optional>

Callback that handles the result (alternative to using a Promise).

Source:
Returns:

If onDone is provided, this method returns an EventEmitter. Else, this method returns a Promise.

Type
EventEmitter | Promise