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

import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as SCIMAPI from './scim/scim';

export class AccessRequests extends APIResource {
  /**
   * Gets a list of Access authentication audit logs for an account.
   *
   * @example
   * ```ts
   * const accessRequests =
   *   await client.zeroTrust.access.logs.accessRequests.list({
   *     account_id: '023e105f4ecef8ad9ca31a8372d0c353',
   *   });
   * ```
   */
  list(
    params?: AccessRequestListParams,
    options?: Core.RequestOptions,
  ): Core.APIPromise<AccessRequestListResponse>;
  list(options?: Core.RequestOptions): Core.APIPromise<AccessRequestListResponse>;
  list(
    params: AccessRequestListParams | Core.RequestOptions = {},
    options?: Core.RequestOptions,
  ): Core.APIPromise<AccessRequestListResponse> {
    if (isRequestOptions(params)) {
      return this.list({}, params);
    }
    const { account_id = this._client.accountId, ...query } = params;
    return (
      this._client.get(`/accounts/${account_id}/access/logs/access_requests`, {
        query,
        ...options,
      }) as Core.APIPromise<{ result: AccessRequestListResponse }>
    )._thenUnwrap((obj) => obj.result);
  }
}

export type AccessRequestListResponse = Array<SCIMAPI.AccessRequest>;

export interface AccessRequestListParams {
  /**
   * Path param: Identifier.
   */
  account_id?: string;

  /**
   * Query param: Operator for the `allowed` filter.
   */
  allowedOp?: 'eq' | 'neq';

  /**
   * Query param: Operator for the `app_type` filter.
   */
  app_typeOp?: 'eq' | 'neq';

  /**
   * Query param: Operator for the `app_uid` filter.
   */
  app_uidOp?: 'eq' | 'neq';

  /**
   * Query param: Operator for the `country_code` filter.
   */
  country_codeOp?: 'eq' | 'neq';

  /**
   * Query param: The chronological sorting order for the logs.
   */
  direction?: 'desc' | 'asc';

  /**
   * Query param: Filter by user email. Defaults to substring matching. To force
   * exact matching, set `email_exact=true`. Example (default): `email=@example.com`
   * returns all events with that domain. Example (exact):
   * `email=user@example.com&email_exact=true` returns only that user.
   */
  email?: string;

  /**
   * Query param: When true, `email` is matched exactly instead of substring
   * matching.
   */
  email_exact?: boolean;

  /**
   * Query param: Operator for the `email` filter.
   */
  emailOp?: 'eq' | 'neq';

  /**
   * Query param: Comma-separated list of fields to include in the response. When
   * omitted, all fields are returned.
   */
  fields?: string;

  /**
   * Query param: Operator for the `idp` filter.
   */
  idpOp?: 'eq' | 'neq';

  /**
   * Query param: The maximum number of log entries to retrieve.
   */
  limit?: number;

  /**
   * Query param: Operator for the `non_identity` filter.
   */
  non_identityOp?: 'eq' | 'neq';

  /**
   * Query param: Page number of results.
   */
  page?: number;

  /**
   * Query param: Number of results per page.
   */
  per_page?: number;

  /**
   * Query param: Operator for the `ray_id` filter.
   */
  ray_idOp?: 'eq' | 'neq';

  /**
   * Query param: The earliest event timestamp to query.
   */
  since?: string;

  /**
   * Query param: The latest event timestamp to query.
   */
  until?: string;

  /**
   * Query param: Filter by user UUID.
   */
  user_id?: string;

  /**
   * Query param: Operator for the `user_id` filter.
   */
  user_idOp?: 'eq' | 'neq';
}

export declare namespace AccessRequests {
  export {
    type AccessRequestListResponse as AccessRequestListResponse,
    type AccessRequestListParams as AccessRequestListParams,
  };
}
