/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 9da31ad0b572
 */

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

export type APIKeyAuth = {
  type: "api-key";
  value: string;
};

/** @internal */
export const APIKeyAuth$inboundSchema: z.ZodType<APIKeyAuth, unknown> = z
  .object({
    type: z.literal("api-key"),
    value: z.string(),
  });
/** @internal */
export type APIKeyAuth$Outbound = {
  type: "api-key";
  value: string;
};

/** @internal */
export const APIKeyAuth$outboundSchema: z.ZodType<
  APIKeyAuth$Outbound,
  APIKeyAuth
> = z.object({
  type: z.literal("api-key"),
  value: z.string(),
});

export function apiKeyAuthToJSON(apiKeyAuth: APIKeyAuth): string {
  return JSON.stringify(APIKeyAuth$outboundSchema.parse(apiKeyAuth));
}
export function apiKeyAuthFromJSON(
  jsonString: string,
): SafeParseResult<APIKeyAuth, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => APIKeyAuth$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'APIKeyAuth' from JSON`,
  );
}
