/*
 * 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 "./sdkvalidationerror.js";
import { VcrTag, VcrTag$inboundSchema } from "./vcrtag.js";

export type GetRepositoryTagRequest = {
  /**
   * Project ID. Missing or empty values return HTTP 400.
   */
  projectId: string;
  idOrName: string;
  tag: string;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
};

export type GetRepositoryTagResponseBody = {
  /**
   * A tag pointing at an image in a Vercel Container Registry repository, enriched with the backing image's metadata and VHS-readiness status.
   */
  tag: VcrTag;
};

/** @internal */
export type GetRepositoryTagRequest$Outbound = {
  projectId: string;
  idOrName: string;
  tag: string;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const GetRepositoryTagRequest$outboundSchema: z.ZodType<
  GetRepositoryTagRequest$Outbound,
  z.ZodTypeDef,
  GetRepositoryTagRequest
> = z.object({
  projectId: z.string(),
  idOrName: z.string(),
  tag: z.string(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function getRepositoryTagRequestToJSON(
  getRepositoryTagRequest: GetRepositoryTagRequest,
): string {
  return JSON.stringify(
    GetRepositoryTagRequest$outboundSchema.parse(getRepositoryTagRequest),
  );
}

/** @internal */
export const GetRepositoryTagResponseBody$inboundSchema: z.ZodType<
  GetRepositoryTagResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  tag: VcrTag$inboundSchema,
});

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