/*
 * 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";

/**
 * The current state of the endpoint. - `creating`: the endpoint is being created. - `pending-acceptance`: waiting for the endpoint service owner to accept the connection. Only occurs for services that require manual acceptance. - `provisioning`: the connection was accepted and AWS is finishing setup. - `available`: the endpoint is fully provisioned and ready to use. - `rejected`: the endpoint service owner rejected the connection. - `failed`: the endpoint could not be provisioned. - `deleting`: the endpoint is being deleted.
 */
export const PrivateLinkEndpointStatus = {
  Available: "available",
  Creating: "creating",
  Deleting: "deleting",
  Failed: "failed",
  PendingAcceptance: "pending-acceptance",
  Provisioning: "provisioning",
  Rejected: "rejected",
} as const;
/**
 * The current state of the endpoint. - `creating`: the endpoint is being created. - `pending-acceptance`: waiting for the endpoint service owner to accept the connection. Only occurs for services that require manual acceptance. - `provisioning`: the connection was accepted and AWS is finishing setup. - `available`: the endpoint is fully provisioned and ready to use. - `rejected`: the endpoint service owner rejected the connection. - `failed`: the endpoint could not be provisioned. - `deleting`: the endpoint is being deleted.
 */
export type PrivateLinkEndpointStatus = ClosedEnum<
  typeof PrivateLinkEndpointStatus
>;

/**
 * A PrivateLink endpoint, which connects a project to an AWS VPC endpoint service in a single region so that traffic reaches the service over AWS PrivateLink rather than the public internet.
 */
export type PrivateLinkEndpoint = {
  /**
   * The unique identifier of the PrivateLink endpoint.
   */
  endpointId: string;
  /**
   * The name of the PrivateLink endpoint, shown in the Vercel dashboard.
   */
  name: string;
  /**
   * The identifier of the team that owns the PrivateLink endpoint.
   */
  teamId: string;
  /**
   * The identifier of the project the PrivateLink endpoint belongs to.
   */
  projectId: string;
  /**
   * The Vercel region the endpoint is provisioned in.
   */
  vercelRegion: string;
  /**
   * The AWS VPC endpoint service the endpoint connects to.
   */
  awsServiceName: string;
  /**
   * The identifier of the underlying AWS VPC endpoint. Absent until AWS has created the endpoint.
   */
  vpcEndpointId?: string | undefined;
  /**
   * The regional DNS names assigned to the endpoint by AWS. Use these to reach the service when private DNS is not enabled.
   */
  awsDnsEntries?: Array<string> | undefined;
  /**
   * The private DNS names of the endpoint service, populated when private DNS is enabled for the endpoint.
   */
  privateDnsNames?: Array<string> | undefined;
  /**
   * The current state of the endpoint. - `creating`: the endpoint is being created. - `pending-acceptance`: waiting for the endpoint service owner to accept the connection. Only occurs for services that require manual acceptance. - `provisioning`: the connection was accepted and AWS is finishing setup. - `available`: the endpoint is fully provisioned and ready to use. - `rejected`: the endpoint service owner rejected the connection. - `failed`: the endpoint could not be provisioned. - `deleting`: the endpoint is being deleted.
   */
  status: PrivateLinkEndpointStatus;
  /**
   * A human-readable explanation of why the endpoint could not be provisioned. Only set when `status` is `failed`, and absent for every other status including `rejected`, since AWS does not report a rejection reason.
   */
  statusMessage?: string | undefined;
  /**
   * Timestamp in milliseconds since the UNIX epoch for when the endpoint was created.
   */
  createdAt: number;
  /**
   * Timestamp in milliseconds since the UNIX epoch for when the endpoint was last updated.
   */
  updatedAt: number;
};

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

/** @internal */
export const PrivateLinkEndpoint$inboundSchema: z.ZodType<
  PrivateLinkEndpoint,
  z.ZodTypeDef,
  unknown
> = z.object({
  endpointId: types.string(),
  name: types.string(),
  teamId: types.string(),
  projectId: types.string(),
  vercelRegion: types.string(),
  awsServiceName: types.string(),
  vpcEndpointId: types.optional(types.string()),
  awsDnsEntries: types.optional(z.array(types.string())),
  privateDnsNames: types.optional(z.array(types.string())),
  status: PrivateLinkEndpointStatus$inboundSchema,
  statusMessage: types.optional(types.string()),
  createdAt: types.number(),
  updatedAt: types.number(),
});

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