/*
 * 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 GetExperimentsAnyEnvRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * The maximum number of experiments to return. Defaults to 20.
   */
  limit?: number | undefined;
  /**
   * Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query `limit`.
   */
  offset?: number | undefined;
  /**
   * A comma-separated list of filters. Each filter is of the form `field:value`. Supported fields are explained above.
   */
  filter?: string | undefined;
  /**
   * A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.
   */
  expand?: string | undefined;
  /**
   * A comma-separated list of experiment archived states. Supports `archived`, `active`, or both. Defaults to `active` experiments.
   */
  lifecycleState?: string | undefined;
};

/** @internal */
export const GetExperimentsAnyEnvRequest$inboundSchema: z.ZodType<
  GetExperimentsAnyEnvRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectKey: z.string(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
  filter: z.string().optional(),
  expand: z.string().optional(),
  lifecycleState: z.string().optional(),
});
/** @internal */
export type GetExperimentsAnyEnvRequest$Outbound = {
  projectKey: string;
  limit?: number | undefined;
  offset?: number | undefined;
  filter?: string | undefined;
  expand?: string | undefined;
  lifecycleState?: string | undefined;
};

/** @internal */
export const GetExperimentsAnyEnvRequest$outboundSchema: z.ZodType<
  GetExperimentsAnyEnvRequest$Outbound,
  z.ZodTypeDef,
  GetExperimentsAnyEnvRequest
> = z.object({
  projectKey: z.string(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
  filter: z.string().optional(),
  expand: z.string().optional(),
  lifecycleState: z.string().optional(),
});

export function getExperimentsAnyEnvRequestToJSON(
  getExperimentsAnyEnvRequest: GetExperimentsAnyEnvRequest,
): string {
  return JSON.stringify(
    GetExperimentsAnyEnvRequest$outboundSchema.parse(
      getExperimentsAnyEnvRequest,
    ),
  );
}
export function getExperimentsAnyEnvRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetExperimentsAnyEnvRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetExperimentsAnyEnvRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetExperimentsAnyEnvRequest' from JSON`,
  );
}
