/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import * as openEnums from "../../types/enums.js";
import { OpenEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  V2DeployDeploymentStep,
  V2DeployDeploymentStep$inboundSchema,
} from "./v2deploydeploymentstep.js";

/**
 * Current deployment status
 */
export const Status = {
  Unspecified: "UNSPECIFIED",
  Pending: "PENDING",
  Starting: "STARTING",
  Building: "BUILDING",
  Deploying: "DEPLOYING",
  Network: "NETWORK",
  Finalizing: "FINALIZING",
  Ready: "READY",
  Failed: "FAILED",
  Skipped: "SKIPPED",
  AwaitingApproval: "AWAITING_APPROVAL",
  Stopped: "STOPPED",
  Superseded: "SUPERSEDED",
  Cancelled: "CANCELLED",
} as const;
/**
 * Current deployment status
 */
export type Status = OpenEnum<typeof Status>;

export type V2DeployGetDeploymentResponseData = {
  /**
   * Unique deployment identifier
   */
  id: string;
  /**
   * Current deployment status
   */
  status: Status;
  /**
   * Error message if deployment failed
   */
  errorMessage?: string | undefined;
  /**
   * Hostnames associated with this deployment
   */
  hostnames?: Array<string> | undefined;
  /**
   * Deployment steps with status and messages
   */
  steps?: Array<V2DeployDeploymentStep> | undefined;
};

/** @internal */
export const Status$inboundSchema: z.ZodType<Status, z.ZodTypeDef, unknown> =
  openEnums.inboundSchema(Status);

/** @internal */
export const V2DeployGetDeploymentResponseData$inboundSchema: z.ZodType<
  V2DeployGetDeploymentResponseData,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  status: Status$inboundSchema,
  errorMessage: z.string().optional(),
  hostnames: z.array(z.string()).optional(),
  steps: z.array(V2DeployDeploymentStep$inboundSchema).optional(),
});

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