// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../../core/resource';
import { PagePromise, V4PagePagination, type V4PagePaginationParams } from '../../../../core/pagination';
import { RequestOptions } from '../../../../internal/request-options';
import { path } from '../../../../internal/utils/path';

export class BaseDevices extends APIResource {
  static override readonly _key: readonly ['zeroTrust', 'dex', 'commands', 'devices'] = Object.freeze([
    'zeroTrust',
    'dex',
    'commands',
    'devices',
  ] as const);

  /**
   * List devices with WARP client support for remote captures which have been
   * connected in the last 1 hour.
   *
   * @example
   * ```ts
   * // Automatically fetches more pages as needed.
   * for await (const deviceListResponse of client.zeroTrust.dex.commands.devices.list(
   *   {
   *     account_id: '01a7362d577a6c3019a474fd6f485823',
   *     page: 1,
   *     per_page: 10,
   *   },
   * )) {
   *   // ...
   * }
   * ```
   */
  list(
    params: DeviceListParams,
    options?: RequestOptions,
  ): PagePromise<DeviceListResponsesV4PagePagination, DeviceListResponse> {
    const { account_id, ...query } = params;
    return this._client.getAPIList(
      path`/accounts/${account_id}/dex/commands/devices`,
      V4PagePagination<DeviceListResponse>,
      { query, ...options },
    );
  }
}
export class Devices extends BaseDevices {}

export type DeviceListResponsesV4PagePagination = V4PagePagination<DeviceListResponse>;

export interface DeviceListResponse {
  /**
   * List of eligible devices
   */
  devices?: Array<DeviceListResponse.Device>;
}

export namespace DeviceListResponse {
  export interface Device {
    /**
     * Device identifier (UUID v4)
     */
    deviceId?: string;

    /**
     * Device identifier (human readable)
     */
    deviceName?: string;

    /**
     * Whether the device is eligible for remote captures
     */
    eligible?: boolean;

    /**
     * If the device is not eligible, the reason why.
     */
    ineligibleReason?: string;

    /**
     * User contact email address
     */
    personEmail?: string;

    /**
     * Operating system.
     */
    platform?: string;

    /**
     * Device registration identifier (UUID v4). On multi-user devices, this uniquely
     * identifies a user's registration on the device.
     */
    registrationId?: string;

    /**
     * Network status.
     */
    status?: string;

    timestamp?: string;

    /**
     * WARP client version.
     */
    version?: string;
  }
}

export interface DeviceListParams extends V4PagePaginationParams {
  /**
   * Path param: Unique Cloudflare account ID.
   */
  account_id: string;

  /**
   * Query param: Filter devices by name or email.
   */
  search?: string;
}

export declare namespace Devices {
  export {
    type DeviceListResponse as DeviceListResponse,
    type DeviceListResponsesV4PagePagination as DeviceListResponsesV4PagePagination,
    type DeviceListParams as DeviceListParams,
  };
}
