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

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";

export type DeploymentResponse = {
  /**
   * Unique identifier of the deployment
   */
  id: string;
  /**
   * Deployment name
   */
  name: string;
  /**
   * Whether at least one worker is currently live
   */
  isActive: 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;
};

/** @internal */
export const DeploymentResponse$inboundSchema: z.ZodType<
  DeploymentResponse,
  unknown
> = z.object({
  id: z.string(),
  name: z.string(),
  is_active: z.boolean(),
  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(),
}).transform((v) => {
  return remap$(v, {
    "is_active": "isActive",
    "created_at": "createdAt",
    "updated_at": "updatedAt",
  });
});

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