/*
 * 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 represents a public route in a Vercel Sandbox.
 */
export type SandboxPublicRoute = {
  /**
   * A public URL to access the corresponding port in the Sandbox.
   */
  url: string;
  /**
   * The user port number that the route is mapped to.
   */
  port: number;
  /**
   * The subdomain assigned to this route.
   */
  subdomain: string;
  /**
   * Whether the route is reserved by the system (e.g. for internal use).
   */
  system?: true | undefined;
};

/** @internal */
export const SandboxPublicRoute$inboundSchema: z.ZodType<
  SandboxPublicRoute,
  z.ZodTypeDef,
  unknown
> = z.object({
  url: types.string(),
  port: types.number(),
  subdomain: types.string(),
  system: types.optional(types.literal(true)),
});

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