/*
 * 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 { smartUnion } from "../types/smartUnion.js";
import {
  GetDeploymentResponseBody3,
  GetDeploymentResponseBody3$inboundSchema,
} from "./getdeploymentgitsourcedeploymentsresponse200type.js";
import {
  GetDeploymentResponseBody1,
  GetDeploymentResponseBody1$inboundSchema,
  GetDeploymentResponseBody2,
  GetDeploymentResponseBody2$inboundSchema,
} from "./getdeploymentresponsebody1.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * Returns a reduced view of the deployment with public information only. Private fields are omitted when the requester is not the deployment owner.
 *
 * @remarks
 * Returns the deployment object for the authenticated owner, including private fields such as environment variables, build log URLs, and internal metadata.
 * Returns the reduced deployment view for anonymous (`vcn_`) callers. Pool-team details are withheld.
 */
export type GetDeploymentResponseBody =
  | GetDeploymentResponseBody2
  | GetDeploymentResponseBody3
  | GetDeploymentResponseBody1;

/** @internal */
export const GetDeploymentResponseBody$inboundSchema: z.ZodType<
  GetDeploymentResponseBody,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  GetDeploymentResponseBody2$inboundSchema,
  GetDeploymentResponseBody3$inboundSchema,
  GetDeploymentResponseBody1$inboundSchema,
]);

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