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

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 {
  DeploymentResponse,
  DeploymentResponse$inboundSchema,
} from "./deploymentresponse.js";

export type DeploymentListResponse = {
  /**
   * List of deployments
   */
  deployments: Array<DeploymentResponse>;
  /**
   * Cursor for the next page of results
   */
  nextCursor: string | null;
  /**
   * Workspace ID the results are scoped to
   */
  workspaceId: string;
};

/** @internal */
export const DeploymentListResponse$inboundSchema: z.ZodType<
  DeploymentListResponse,
  unknown
> = z.object({
  deployments: z.array(DeploymentResponse$inboundSchema),
  next_cursor: z.nullable(z.string()),
  workspace_id: z.string(),
}).transform((v) => {
  return remap$(v, {
    "next_cursor": "nextCursor",
    "workspace_id": "workspaceId",
  });
});

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