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

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

export type V2RatelimitListOverridesRequestBody = {
  /**
   * The id of the namespace to list overrides for.
   */
  namespaceId?: string | undefined;
  /**
   * The name of the namespace to list overrides for.
   */
  namespaceName?: string | undefined;
  /**
   * Pagination cursor from a previous response
   */
  cursor?: string | undefined;
  /**
   * Maximum number of results to return
   */
  limit?: number | undefined;
};

/** @internal */
export const V2RatelimitListOverridesRequestBody$inboundSchema: z.ZodType<
  V2RatelimitListOverridesRequestBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  namespaceId: z.string().optional(),
  namespaceName: z.string().optional(),
  cursor: z.string().optional(),
  limit: z.number().int().default(10),
});

/** @internal */
export type V2RatelimitListOverridesRequestBody$Outbound = {
  namespaceId?: string | undefined;
  namespaceName?: string | undefined;
  cursor?: string | undefined;
  limit: number;
};

/** @internal */
export const V2RatelimitListOverridesRequestBody$outboundSchema: z.ZodType<
  V2RatelimitListOverridesRequestBody$Outbound,
  z.ZodTypeDef,
  V2RatelimitListOverridesRequestBody
> = z.object({
  namespaceId: z.string().optional(),
  namespaceName: z.string().optional(),
  cursor: z.string().optional(),
  limit: z.number().int().default(10),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace V2RatelimitListOverridesRequestBody$ {
  /** @deprecated use `V2RatelimitListOverridesRequestBody$inboundSchema` instead. */
  export const inboundSchema =
    V2RatelimitListOverridesRequestBody$inboundSchema;
  /** @deprecated use `V2RatelimitListOverridesRequestBody$outboundSchema` instead. */
  export const outboundSchema =
    V2RatelimitListOverridesRequestBody$outboundSchema;
  /** @deprecated use `V2RatelimitListOverridesRequestBody$Outbound` instead. */
  export type Outbound = V2RatelimitListOverridesRequestBody$Outbound;
}

export function v2RatelimitListOverridesRequestBodyToJSON(
  v2RatelimitListOverridesRequestBody: V2RatelimitListOverridesRequestBody,
): string {
  return JSON.stringify(
    V2RatelimitListOverridesRequestBody$outboundSchema.parse(
      v2RatelimitListOverridesRequestBody,
    ),
  );
}

export function v2RatelimitListOverridesRequestBodyFromJSON(
  jsonString: string,
): SafeParseResult<V2RatelimitListOverridesRequestBody, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) =>
      V2RatelimitListOverridesRequestBody$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'V2RatelimitListOverridesRequestBody' from JSON`,
  );
}
