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

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 { FilePurpose, FilePurpose$inboundSchema } from "./filepurpose.js";
import {
  FileVisibility,
  FileVisibility$inboundSchema,
} from "./filevisibility.js";
import { SampleType, SampleType$inboundSchema } from "./sampletype.js";
import { Source, Source$inboundSchema } from "./source.js";

export type CreateFileResponse = {
  /**
   * The unique identifier of the file.
   */
  id: string;
  /**
   * The object type, which is always "file".
   */
  object: string;
  /**
   * The size of the file, in bytes.
   */
  sizeBytes: number;
  /**
   * The UNIX timestamp (in seconds) of the event.
   */
  createdAt: number;
  /**
   * The name of the uploaded file.
   */
  filename: string;
  purpose: FilePurpose;
  sampleType: SampleType;
  numLines?: number | null | undefined;
  mimetype?: string | null | undefined;
  source: Source;
  signature?: string | null | undefined;
  expiresAt?: number | null | undefined;
  visibility?: FileVisibility | null | undefined;
};

/** @internal */
export const CreateFileResponse$inboundSchema: z.ZodType<
  CreateFileResponse,
  unknown
> = z.object({
  id: z.string(),
  object: z.string(),
  bytes: z.int(),
  created_at: z.int(),
  filename: z.string(),
  purpose: FilePurpose$inboundSchema,
  sample_type: SampleType$inboundSchema,
  num_lines: z.nullable(z.int()).optional(),
  mimetype: z.nullable(z.string()).optional(),
  source: Source$inboundSchema,
  signature: z.nullable(z.string()).optional(),
  expires_at: z.nullable(z.int()).optional(),
  visibility: z.nullable(FileVisibility$inboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    "bytes": "sizeBytes",
    "created_at": "createdAt",
    "sample_type": "sampleType",
    "num_lines": "numLines",
    "expires_at": "expiresAt",
  });
});

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