// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../../core/resource'; import * as DEXAPI from '../dex'; import * as PercentilesAPI from './percentiles'; import { BasePercentiles, HTTPDetailsPercentiles, PercentileGetParams, Percentiles, TestStatOverTime, } from './percentiles'; import { APIPromise } from '../../../../core/api-promise'; import { RequestOptions } from '../../../../internal/request-options'; import { path } from '../../../../internal/utils/path'; export class BaseHTTPTests extends APIResource { static override readonly _key: readonly ['zeroTrust', 'dex', 'httpTests'] = Object.freeze([ 'zeroTrust', 'dex', 'httpTests', ] as const); /** * Get test details and aggregate performance metrics for an http test for a given * time period between 1 hour and 7 days. * * @example * ```ts * const httpDetails = * await client.zeroTrust.dex.httpTests.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { * account_id: '01a7362d577a6c3019a474fd6f485823', * from: '1689520412000', * interval: 'minute', * to: '1689606812000', * }, * ); * ``` */ get(testID: string, params: HTTPTestGetParams, options?: RequestOptions): APIPromise { const { account_id, ...query } = params; return ( this._client.get(path`/accounts/${account_id}/dex/http-tests/${testID}`, { query, ...options, }) as APIPromise<{ result: HTTPDetails }> )._thenUnwrap((obj) => obj.result); } } export class HTTPTests extends BaseHTTPTests { percentiles: PercentilesAPI.Percentiles = new PercentilesAPI.Percentiles(this._client); } export interface HTTPDetails { /** * The url of the HTTP synthetic application test. */ host?: string; httpStats?: HTTPDetails.HTTPStats | null; httpStatsByColo?: Array; /** * The interval at which the HTTP synthetic application test is set to run. */ interval?: string; kind?: 'http'; /** * The HTTP method to use when running the test. */ method?: string; /** * The name of the HTTP synthetic application test. */ name?: string; target_policies?: Array | null; targeted?: boolean; } export namespace HTTPDetails { export interface HTTPStats { availabilityPct: HTTPStats.AvailabilityPct; dnsResponseTimeMs: PercentilesAPI.TestStatOverTime; httpStatusCode: Array; resourceFetchTimeMs: PercentilesAPI.TestStatOverTime; serverResponseTimeMs: PercentilesAPI.TestStatOverTime; /** * Count of unique devices that have run this test in the given time period. */ uniqueDevicesTotal: number; } export namespace HTTPStats { export interface AvailabilityPct { slots: Array; /** * average observed in the time period. */ avg?: number | null; /** * highest observed in the time period. */ max?: number | null; /** * lowest observed in the time period. */ min?: number | null; } export namespace AvailabilityPct { export interface Slot { timestamp: string; value: number; } } export interface HTTPStatusCode { status200: number; status300: number; status400: number; status500: number; timestamp: string; } } export interface HTTPStatsByColo { availabilityPct: HTTPStatsByColo.AvailabilityPct; colo: string; dnsResponseTimeMs: PercentilesAPI.TestStatOverTime; httpStatusCode: Array; resourceFetchTimeMs: PercentilesAPI.TestStatOverTime; serverResponseTimeMs: PercentilesAPI.TestStatOverTime; /** * Count of unique devices that have run this test in the given time period. */ uniqueDevicesTotal: number; } export namespace HTTPStatsByColo { export interface AvailabilityPct { slots: Array; /** * average observed in the time period. */ avg?: number | null; /** * highest observed in the time period. */ max?: number | null; /** * lowest observed in the time period. */ min?: number | null; } export namespace AvailabilityPct { export interface Slot { timestamp: string; value: number; } } export interface HTTPStatusCode { status200: number; status300: number; status400: number; status500: number; timestamp: string; } } } export interface HTTPTestGetParams { /** * Path param: Unique identifier linked to an account. */ account_id: string; /** * Query param: Start time for aggregate metrics in ISO ms. */ from: string; /** * Query param: Time interval for aggregate time slots. */ interval: 'minute' | 'hour'; /** * Query param: End time for aggregate metrics in ISO ms. */ to: string; /** * Query param: Optionally filter result stats to a Cloudflare colo. Cannot be used * in combination with deviceId param. */ colo?: string; /** * Query param: Optionally filter result stats to a specific device(s). Cannot be * used in combination with colo param. */ deviceId?: Array; } HTTPTests.Percentiles = Percentiles; HTTPTests.BasePercentiles = BasePercentiles; export declare namespace HTTPTests { export { type HTTPDetails as HTTPDetails, type HTTPTestGetParams as HTTPTestGetParams }; export { Percentiles as Percentiles, BasePercentiles as BasePercentiles, type HTTPDetailsPercentiles as HTTPDetailsPercentiles, type TestStatOverTime as TestStatOverTime, type PercentileGetParams as PercentileGetParams, }; }