/*
 * 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";

/**
 * Gets the configuration of an existing override.
 */
export type V2RatelimitGetOverrideRequestBody = {
  /**
   * The id of the namespace. Either namespaceId or namespaceName must be provided
   */
  namespaceId?: string | undefined;
  /**
   * The name of the namespace. Either namespaceId or namespaceName must be provided
   */
  namespaceName?: string | undefined;
  /**
   * Identifier of your user, this can be their userId, an email, an ip or anything else. Wildcards ( * ) can be used to match multiple identifiers, More info can be found at https://www.unkey.com/docs/ratelimiting/overrides#wildcard-rules
   */
  identifier: string;
};

/** @internal */
export const V2RatelimitGetOverrideRequestBody$inboundSchema: z.ZodType<
  V2RatelimitGetOverrideRequestBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  namespaceId: z.string().optional(),
  namespaceName: z.string().optional(),
  identifier: z.string(),
});

/** @internal */
export type V2RatelimitGetOverrideRequestBody$Outbound = {
  namespaceId?: string | undefined;
  namespaceName?: string | undefined;
  identifier: string;
};

/** @internal */
export const V2RatelimitGetOverrideRequestBody$outboundSchema: z.ZodType<
  V2RatelimitGetOverrideRequestBody$Outbound,
  z.ZodTypeDef,
  V2RatelimitGetOverrideRequestBody
> = z.object({
  namespaceId: z.string().optional(),
  namespaceName: z.string().optional(),
  identifier: z.string(),
});

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

export function v2RatelimitGetOverrideRequestBodyToJSON(
  v2RatelimitGetOverrideRequestBody: V2RatelimitGetOverrideRequestBody,
): string {
  return JSON.stringify(
    V2RatelimitGetOverrideRequestBody$outboundSchema.parse(
      v2RatelimitGetOverrideRequestBody,
    ),
  );
}

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