/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GetAuditLogEntriesRequest = {
  /**
   * A timestamp filter, expressed as a Unix epoch time in milliseconds.  All entries this returns occurred before the timestamp.
   */
  before?: number | undefined;
  /**
   * A timestamp filter, expressed as a Unix epoch time in milliseconds. All entries this returns occurred after the timestamp.
   */
  after?: number | undefined;
  /**
   * Text to search for. You can search for the full or partial name of the resource.
   */
  q?: string | undefined;
  /**
   * A limit on the number of audit log entries that return. Set between 1 and 20. The default is 10.
   */
  limit?: number | undefined;
  /**
   * A resource specifier that lets you filter audit log listings by resource
   */
  spec?: string | undefined;
  /**
   * A member ID that lets you filter audit log listings by the member who made the change. Repeat the parameter to filter by multiple members.
   */
  member?: string | undefined;
  /**
   * An access token ID that lets you filter audit log listings by the token that made the change. Repeat the parameter to filter by multiple tokens.
   */
  token?: string | undefined;
};

/** @internal */
export const GetAuditLogEntriesRequest$inboundSchema: z.ZodType<
  GetAuditLogEntriesRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  before: z.number().int().optional(),
  after: z.number().int().optional(),
  q: z.string().optional(),
  limit: z.number().int().optional(),
  spec: z.string().optional(),
  member: z.string().optional(),
  token: z.string().optional(),
});
/** @internal */
export type GetAuditLogEntriesRequest$Outbound = {
  before?: number | undefined;
  after?: number | undefined;
  q?: string | undefined;
  limit?: number | undefined;
  spec?: string | undefined;
  member?: string | undefined;
  token?: string | undefined;
};

/** @internal */
export const GetAuditLogEntriesRequest$outboundSchema: z.ZodType<
  GetAuditLogEntriesRequest$Outbound,
  z.ZodTypeDef,
  GetAuditLogEntriesRequest
> = z.object({
  before: z.number().int().optional(),
  after: z.number().int().optional(),
  q: z.string().optional(),
  limit: z.number().int().optional(),
  spec: z.string().optional(),
  member: z.string().optional(),
  token: z.string().optional(),
});

export function getAuditLogEntriesRequestToJSON(
  getAuditLogEntriesRequest: GetAuditLogEntriesRequest,
): string {
  return JSON.stringify(
    GetAuditLogEntriesRequest$outboundSchema.parse(getAuditLogEntriesRequest),
  );
}
export function getAuditLogEntriesRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetAuditLogEntriesRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetAuditLogEntriesRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetAuditLogEntriesRequest' from JSON`,
  );
}
