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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  DeploymentLocation,
  DeploymentLocation$inboundSchema,
} from "./deploymentlocation.js";
import {
  DeploymentWorkerResponse,
  DeploymentWorkerResponse$inboundSchema,
} from "./deploymentworkerresponse.js";

export type DeploymentDetailResponse = {
  /**
   * Unique identifier of the deployment
   */
  id: string;
  /**
   * Deployment name
   */
  name: string;
  /**
   * Whether at least one worker is currently live
   */
  isActive: boolean;
  /**
   * Whether the deployment has at least one authorized credential
   */
  isHardened: boolean;
  /**
   * When the deployment was first registered
   */
  createdAt: Date;
  /**
   * When the deployment was last updated
   */
  updatedAt: Date;
  /**
   * Where the deployment is running
   */
  location?: DeploymentLocation | null | undefined;
  /**
   * Workers registered for the deployment
   */
  workers: Array<DeploymentWorkerResponse>;
};

/** @internal */
export const DeploymentDetailResponse$inboundSchema: z.ZodType<
  DeploymentDetailResponse,
  unknown
> = z.object({
  id: z.string(),
  name: z.string(),
  is_active: z.boolean(),
  is_hardened: z.boolean().default(false),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  updated_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  location: z.nullable(DeploymentLocation$inboundSchema).optional(),
  workers: z.array(DeploymentWorkerResponse$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "is_active": "isActive",
    "is_hardened": "isHardened",
    "created_at": "createdAt",
    "updated_at": "updatedAt",
  });
});

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