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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * Metadata about any AWS Route53 Hosted Zones associated with the Network.
 */
export type HostedZones = {
  /**
   * The number of AWS Route53 Hosted Zones associated with the Network.
   */
  count: number;
};

/**
 * Metadata about any AWS Route53 Hosted Zones associated with the Network.
 */
export type PeeringConnections = {
  /**
   * The number of AWS Route53 Hosted Zones associated with the Network.
   */
  count: number;
};

/**
 * Metadata about any projects associated with the Network.
 */
export type Projects = {
  count: number;
  ids: Array<string>;
};

/**
 * The status of the Network.
 */
export const Status = {
  CreateInProgress: "create_in_progress",
  DeleteInProgress: "delete_in_progress",
  Error: "error",
  Ready: "ready",
} as const;
/**
 * The status of the Network.
 */
export type Status = ClosedEnum<typeof Status>;

export type Network = {
  /**
   * The ID of the AWS Account in which the network exists.
   */
  awsAccountId: string;
  /**
   * The IDs of the AWS Availability Zones in which the network exists, if specified during creation.
   */
  awsAvailabilityZoneIds?: Array<string> | undefined;
  /**
   * The AWS Region in which the network exists.
   */
  awsRegion: string;
  /**
   * The CIDR range of the Network.
   */
  cidr: string;
  /**
   * The date at which the Network was created, represented as a UNIX timestamp since EPOCH.
   */
  createdAt: number;
  egressIpAddresses?: Array<string> | undefined;
  /**
   * Metadata about any AWS Route53 Hosted Zones associated with the Network.
   */
  hostedZones?: HostedZones | undefined;
  /**
   * The unique identifier of the Network.
   */
  id: string;
  /**
   * The name of the network.
   */
  name: string;
  /**
   * Metadata about any AWS Route53 Hosted Zones associated with the Network.
   */
  peeringConnections?: PeeringConnections | undefined;
  /**
   * Metadata about any projects associated with the Network.
   */
  projects?: Projects | undefined;
  /**
   * The Vercel region in which the Network exists.
   */
  region?: string | undefined;
  /**
   * The status of the Network.
   */
  status: Status;
  /**
   * The unique identifier of the Team that owns the Network.
   */
  teamId: string;
  /**
   * The ID of the VPC which hosts the network.
   */
  vpcId?: string | undefined;
};

/** @internal */
export const HostedZones$inboundSchema: z.ZodType<
  HostedZones,
  z.ZodTypeDef,
  unknown
> = z.object({
  count: types.number(),
});

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

/** @internal */
export const PeeringConnections$inboundSchema: z.ZodType<
  PeeringConnections,
  z.ZodTypeDef,
  unknown
> = z.object({
  count: types.number(),
});

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

/** @internal */
export const Projects$inboundSchema: z.ZodType<
  Projects,
  z.ZodTypeDef,
  unknown
> = z.object({
  count: types.number(),
  ids: z.array(types.string()),
});

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

/** @internal */
export const Status$inboundSchema: z.ZodNativeEnum<typeof Status> = z
  .nativeEnum(Status);

/** @internal */
export const Network$inboundSchema: z.ZodType<Network, z.ZodTypeDef, unknown> =
  z.object({
    awsAccountId: types.string(),
    awsAvailabilityZoneIds: types.optional(z.array(types.string())),
    awsRegion: types.string(),
    cidr: types.string(),
    createdAt: types.number(),
    egressIpAddresses: types.optional(z.array(types.string())),
    hostedZones: types.optional(z.lazy(() => HostedZones$inboundSchema)),
    id: types.string(),
    name: types.string(),
    peeringConnections: types.optional(
      z.lazy(() => PeeringConnections$inboundSchema),
    ),
    projects: types.optional(z.lazy(() => Projects$inboundSchema)),
    region: types.optional(types.string()),
    status: Status$inboundSchema,
    teamId: types.string(),
    vpcId: types.optional(types.string()),
  });

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