/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * This object contains information related to a Vercel Sandbox Drive.
 */
export type Drive = {
  /**
   * The unique drive name within the project.
   */
  name: string;
  /**
   * The project that owns the drive.
   */
  projectId: string;
  /**
   * The maximum drive size in bytes.
   */
  maxSizeBytes: number;
  /**
   * Current session ID the drive is attached to, if any.
   */
  currentSessionId?: string | undefined;
  /**
   * Current sandbox name the drive is attached to, if any.
   */
  currentSandboxName?: string | undefined;
  /**
   * The time when the drive was created, in milliseconds since the epoch.
   */
  createdAt: number;
  /**
   * The last time the drive was updated, in milliseconds since the epoch.
   */
  updatedAt: number;
};

/** @internal */
export const Drive$inboundSchema: z.ZodType<Drive, z.ZodTypeDef, unknown> = z
  .object({
    name: types.string(),
    projectId: types.string(),
    maxSizeBytes: types.number(),
    currentSessionId: types.optional(types.string()),
    currentSandboxName: types.optional(types.string()),
    createdAt: types.number(),
    updatedAt: types.number(),
  });

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