/*
 * 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 {
  VcrImageDetail,
  VcrImageDetail$inboundSchema,
} from "./vcrimagedetail.js";

export type GetRepositoryImageRequest = {
  /**
   * Project ID or name (slug) within the authenticated team. IDs take precedence over names. Missing or empty values return HTTP 400.
   */
  projectId: string;
  idOrName: string;
  /**
   * The internal image id (`image_...`) or the image manifest digest (`sha256:...`).
   */
  imageIdOrDigest: 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 GetRepositoryImageResponseBody = {
  /**
   * A single image with its tags, status and resolved Dockerfile layer history.
   */
  image: VcrImageDetail;
};

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

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

export function getRepositoryImageRequestToJSON(
  getRepositoryImageRequest: GetRepositoryImageRequest,
): string {
  return JSON.stringify(
    GetRepositoryImageRequest$outboundSchema.parse(getRepositoryImageRequest),
  );
}

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

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