globalping-ts
Version:
Typescript library for the Globalping API
56 lines (54 loc) • 3.25 kB
TypeScript
import { ApiResponse, ErrorEvent, GlobalpingOptions, LimitsGetResponse, MeasurementGetResponseBody, MeasurementPostResponseBody, MeasurementRequestBody, ProbeGetResponse } from './types';
export declare class Globalping {
private host;
private apiVersion;
private requestHeaders;
private maxCacheSize;
private apiToken;
private cache;
private debug;
private disableEtagCaching;
constructor(options?: GlobalpingOptions | undefined);
/**
* **POST** /v1/measurements
* -
* Creates a new measurement with parameters set in the request body. The measurement runs asynchronously and you can retrieve its current state at the URL returned in the Location header.
* -
* Client guidelines
* - If the application is running in interactive mode, set the **inProgressUpdates** option to **true** to have the API return partial results as soon as they are available. This allows the user to see the measurement progress in real time.
* - If the application is interactive by default but also implements a "CI" mode for scripting, do not set the flag in the CI mode.
* - To perform multiple measurements using exactly the same probes, create a single measurement first, then pass its **id** in the **locations** field for the other measurements.
* */
postMeasurement<R, E>(requestBody: MeasurementRequestBody): Promise<ApiResponse<MeasurementPostResponseBody, ErrorEvent>>;
/**
* **GET** /v1/measurements/{id}
* -
* Returns the status and results of an existing measurement. Measurements are typically available for up to 7 days after creation.
* -
* Tip: A link to this endpoint is returned in the **Location** response header when creating the measurement.
* -
* Client guidelines
* -
* As it can take a few seconds for a measurement to complete, you should use the following process for retrieving the results:
* - Request the measurement to retrieve its status.
* - If the status is **in-progress**, wait 500 milliseconds and start again at step 1. Note that it's important to wait 500 ms after receiving the response rather than using an "every 500ms" interval as for large measurements, the request itself may take a few hundred milliseconds to complete.
* - If the status is anything other than **in-progress**, stop. The measurement is no longer running, and its results are final.
* */
getMeasurement<R, E>(id: string): Promise<ApiResponse<MeasurementGetResponseBody, ErrorEvent>>;
/**
* **GET** /v1/probes
* -
* Returns a list of all probes currently online and their metadata, such as location and assigned tags.
* -
* Note: Probes don't expose unique IDs that would allow you to explicitly select them. Instead, specify the requested location or an ID of an existing measurement when creating new measurements.
* */
probes<R, E>(): Promise<ApiResponse<ProbeGetResponse, ErrorEvent>>;
/**
* **GET** /v1/limits
* -
* Returns rate limits for the current user (if authenticated) or IP address (if not authenticated).
* -
* */
limits<R, E>(): Promise<ApiResponse<LimitsGetResponse, ErrorEvent>>;
private failure;
}