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

/**
 * Order of the returned events based on the timestamp.
 */
export const Direction = {
  Backward: "backward",
  Forward: "forward",
} as const;
/**
 * Order of the returned events based on the timestamp.
 */
export type Direction = ClosedEnum<typeof Direction>;

/**
 * HTTP status code range to filter events by.
 */
export type QueryParamStatusCode = number | string;

export type GetDeploymentEventsRequest = {
  /**
   * The unique identifier or hostname of the deployment.
   */
  idOrUrl: string;
  /**
   * Order of the returned events based on the timestamp.
   */
  direction?: Direction | undefined;
  /**
   * When enabled, this endpoint will return live events as they happen.
   */
  follow?: number | undefined;
  /**
   * Maximum number of events to return. Provide `-1` to return all available logs.
   */
  limit?: number | undefined;
  /**
   * Deployment build ID.
   */
  name?: string | undefined;
  /**
   * Timestamp for when build logs should be pulled from.
   */
  since?: number | undefined;
  /**
   * Timestamp for when the build logs should be pulled up until.
   */
  until?: number | undefined;
  /**
   * HTTP status code range to filter events by.
   */
  statusCode?: number | string | undefined;
  delimiter?: number | undefined;
  builds?: number | undefined;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
};

export type ResponseBodyInfo = {
  type: string;
  name: string;
  entrypoint?: string | undefined;
  path?: string | undefined;
  step?: string | undefined;
  readyState?: string | undefined;
};

export const GetDeploymentEventsResponseBodyDeploymentsResponseType = {
  Command: "command",
  Delimiter: "delimiter",
  DeploymentState: "deployment-state",
  EdgeFunctionInvocation: "edge-function-invocation",
  Exit: "exit",
  Fatal: "fatal",
  Metric: "metric",
  Middleware: "middleware",
  MiddlewareInvocation: "middleware-invocation",
  Report: "report",
  Stderr: "stderr",
  Stdout: "stdout",
} as const;
export type GetDeploymentEventsResponseBodyDeploymentsResponseType = ClosedEnum<
  typeof GetDeploymentEventsResponseBodyDeploymentsResponseType
>;

export const ResponseBodyLevel = {
  Error: "error",
  Warning: "warning",
} as const;
export type ResponseBodyLevel = ClosedEnum<typeof ResponseBodyLevel>;

export type GetDeploymentEventsResponseBodyDeployments2 = {
  created: number;
  date: number;
  deploymentId: string;
  id: string;
  info: ResponseBodyInfo;
  serial: string;
  text?: string | undefined;
  type: GetDeploymentEventsResponseBodyDeploymentsResponseType;
  level?: ResponseBodyLevel | undefined;
};

export const GetDeploymentEventsResponseBodyDeploymentsType = {
  Command: "command",
  Delimiter: "delimiter",
  DeploymentState: "deployment-state",
  EdgeFunctionInvocation: "edge-function-invocation",
  Exit: "exit",
  Fatal: "fatal",
  Metric: "metric",
  Middleware: "middleware",
  MiddlewareInvocation: "middleware-invocation",
  Report: "report",
  Stderr: "stderr",
  Stdout: "stdout",
} as const;
export type GetDeploymentEventsResponseBodyDeploymentsType = ClosedEnum<
  typeof GetDeploymentEventsResponseBodyDeploymentsType
>;

export type GetDeploymentEventsResponseBodyInfo = {
  type: string;
  name: string;
  entrypoint?: string | undefined;
  path?: string | undefined;
  step?: string | undefined;
  readyState?: string | undefined;
};

export const ResponseBodyVercelCache = {
  Bypass: "BYPASS",
  Hit: "HIT",
  Miss: "MISS",
  Prerender: "PRERENDER",
  Revalidated: "REVALIDATED",
  Stale: "STALE",
} as const;
export type ResponseBodyVercelCache = ClosedEnum<
  typeof ResponseBodyVercelCache
>;

export const ResponseBodyWafAction = {
  Bypass: "bypass",
  Challenge: "challenge",
  Deny: "deny",
  Log: "log",
  RateLimit: "rate_limit",
} as const;
export type ResponseBodyWafAction = ClosedEnum<typeof ResponseBodyWafAction>;

export type ResponseBodyProxy = {
  timestamp: number;
  method: string;
  host: string;
  path: string;
  statusCode?: number | undefined;
  userAgent: Array<string>;
  referer: string;
  clientIp?: string | undefined;
  region: string;
  scheme?: string | undefined;
  responseByteSize?: number | undefined;
  cacheId?: string | undefined;
  pathType?: string | undefined;
  pathTypeVariant?: string | undefined;
  vercelId?: string | undefined;
  vercelCache?: ResponseBodyVercelCache | undefined;
  lambdaRegion?: string | undefined;
  wafAction?: ResponseBodyWafAction | undefined;
  wafRuleId?: string | undefined;
};

export type ResponseBodyPayload = {
  deploymentId: string;
  info?: GetDeploymentEventsResponseBodyInfo | undefined;
  text?: string | undefined;
  id: string;
  date: number;
  serial: string;
  created?: number | undefined;
  statusCode?: number | undefined;
  requestId?: string | undefined;
  proxy?: ResponseBodyProxy | undefined;
};

export type GetDeploymentEventsResponseBodyDeployments1 = {
  type: GetDeploymentEventsResponseBodyDeploymentsType;
  created: number;
  payload: ResponseBodyPayload;
};

export type GetDeploymentEventsResponseBody =
  | GetDeploymentEventsResponseBodyDeployments2
  | GetDeploymentEventsResponseBodyDeployments1;

export type Info = {
  type: string;
  name: string;
  entrypoint?: string | undefined;
  path?: string | undefined;
  step?: string | undefined;
  readyState?: string | undefined;
};

export const GetDeploymentEventsResponseBodyType = {
  Command: "command",
  Delimiter: "delimiter",
  DeploymentState: "deployment-state",
  EdgeFunctionInvocation: "edge-function-invocation",
  Exit: "exit",
  Fatal: "fatal",
  Metric: "metric",
  Middleware: "middleware",
  MiddlewareInvocation: "middleware-invocation",
  Report: "report",
  Stderr: "stderr",
  Stdout: "stdout",
} as const;
export type GetDeploymentEventsResponseBodyType = ClosedEnum<
  typeof GetDeploymentEventsResponseBodyType
>;

export const GetDeploymentEventsResponseBodyLevel = {
  Error: "error",
  Warning: "warning",
} as const;
export type GetDeploymentEventsResponseBodyLevel = ClosedEnum<
  typeof GetDeploymentEventsResponseBodyLevel
>;

export type GetDeploymentEventsResponseBody2 = {
  created: number;
  date: number;
  deploymentId: string;
  id: string;
  info: Info;
  serial: string;
  text?: string | undefined;
  type: GetDeploymentEventsResponseBodyType;
  level?: GetDeploymentEventsResponseBodyLevel | undefined;
};

export const ResponseBodyType = {
  Command: "command",
  Delimiter: "delimiter",
  DeploymentState: "deployment-state",
  EdgeFunctionInvocation: "edge-function-invocation",
  Exit: "exit",
  Fatal: "fatal",
  Metric: "metric",
  Middleware: "middleware",
  MiddlewareInvocation: "middleware-invocation",
  Report: "report",
  Stderr: "stderr",
  Stdout: "stdout",
} as const;
export type ResponseBodyType = ClosedEnum<typeof ResponseBodyType>;

export type GetDeploymentEventsResponseBodyDeploymentsInfo = {
  type: string;
  name: string;
  entrypoint?: string | undefined;
  path?: string | undefined;
  step?: string | undefined;
  readyState?: string | undefined;
};

export const VercelCache = {
  Bypass: "BYPASS",
  Hit: "HIT",
  Miss: "MISS",
  Prerender: "PRERENDER",
  Revalidated: "REVALIDATED",
  Stale: "STALE",
} as const;
export type VercelCache = ClosedEnum<typeof VercelCache>;

export const WafAction = {
  Bypass: "bypass",
  Challenge: "challenge",
  Deny: "deny",
  Log: "log",
  RateLimit: "rate_limit",
} as const;
export type WafAction = ClosedEnum<typeof WafAction>;

export type Proxy = {
  timestamp: number;
  method: string;
  host: string;
  path: string;
  statusCode?: number | undefined;
  userAgent: Array<string>;
  referer: string;
  clientIp?: string | undefined;
  region: string;
  scheme?: string | undefined;
  responseByteSize?: number | undefined;
  cacheId?: string | undefined;
  pathType?: string | undefined;
  pathTypeVariant?: string | undefined;
  vercelId?: string | undefined;
  vercelCache?: VercelCache | undefined;
  lambdaRegion?: string | undefined;
  wafAction?: WafAction | undefined;
  wafRuleId?: string | undefined;
};

export type GetDeploymentEventsResponseBodyPayload = {
  deploymentId: string;
  info?: GetDeploymentEventsResponseBodyDeploymentsInfo | undefined;
  text?: string | undefined;
  id: string;
  date: number;
  serial: string;
  created?: number | undefined;
  statusCode?: number | undefined;
  requestId?: string | undefined;
  proxy?: Proxy | undefined;
};

export type GetDeploymentEventsResponseBody1 = {
  type: ResponseBodyType;
  created: number;
  payload: GetDeploymentEventsResponseBodyPayload;
};

export type GetDeploymentEventsDeploymentsResponseBody =
  | GetDeploymentEventsResponseBody2
  | GetDeploymentEventsResponseBody1;

export type GetDeploymentEventsResponse =
  | Array<
    GetDeploymentEventsResponseBody2 | GetDeploymentEventsResponseBody1 | null
  >
  | GetDeploymentEventsResponseBodyDeployments2
  | GetDeploymentEventsResponseBodyDeployments1;

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

/** @internal */
export type QueryParamStatusCode$Outbound = number | string;

/** @internal */
export const QueryParamStatusCode$outboundSchema: z.ZodType<
  QueryParamStatusCode$Outbound,
  z.ZodTypeDef,
  QueryParamStatusCode
> = smartUnion([z.number(), z.string()]);

export function queryParamStatusCodeToJSON(
  queryParamStatusCode: QueryParamStatusCode,
): string {
  return JSON.stringify(
    QueryParamStatusCode$outboundSchema.parse(queryParamStatusCode),
  );
}

/** @internal */
export type GetDeploymentEventsRequest$Outbound = {
  idOrUrl: string;
  direction: string;
  follow?: number | undefined;
  limit?: number | undefined;
  name?: string | undefined;
  since?: number | undefined;
  until?: number | undefined;
  statusCode?: number | string | undefined;
  delimiter?: number | undefined;
  builds?: number | undefined;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const GetDeploymentEventsRequest$outboundSchema: z.ZodType<
  GetDeploymentEventsRequest$Outbound,
  z.ZodTypeDef,
  GetDeploymentEventsRequest
> = z.object({
  idOrUrl: z.string(),
  direction: Direction$outboundSchema.default("forward"),
  follow: z.number().optional(),
  limit: z.number().optional(),
  name: z.string().optional(),
  since: z.number().optional(),
  until: z.number().optional(),
  statusCode: smartUnion([z.number(), z.string()]).optional(),
  delimiter: z.number().optional(),
  builds: z.number().optional(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function getDeploymentEventsRequestToJSON(
  getDeploymentEventsRequest: GetDeploymentEventsRequest,
): string {
  return JSON.stringify(
    GetDeploymentEventsRequest$outboundSchema.parse(getDeploymentEventsRequest),
  );
}

/** @internal */
export const ResponseBodyInfo$inboundSchema: z.ZodType<
  ResponseBodyInfo,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.string(),
  name: types.string(),
  entrypoint: types.optional(types.string()),
  path: types.optional(types.string()),
  step: types.optional(types.string()),
  readyState: types.optional(types.string()),
});

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

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

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

/** @internal */
export const GetDeploymentEventsResponseBodyDeployments2$inboundSchema:
  z.ZodType<
    GetDeploymentEventsResponseBodyDeployments2,
    z.ZodTypeDef,
    unknown
  > = z.object({
    created: types.number(),
    date: types.number(),
    deploymentId: types.string(),
    id: types.string(),
    info: z.lazy(() => ResponseBodyInfo$inboundSchema),
    serial: types.string(),
    text: types.optional(types.string()),
    type: GetDeploymentEventsResponseBodyDeploymentsResponseType$inboundSchema,
    level: types.optional(ResponseBodyLevel$inboundSchema),
  });

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

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

/** @internal */
export const GetDeploymentEventsResponseBodyInfo$inboundSchema: z.ZodType<
  GetDeploymentEventsResponseBodyInfo,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.string(),
  name: types.string(),
  entrypoint: types.optional(types.string()),
  path: types.optional(types.string()),
  step: types.optional(types.string()),
  readyState: types.optional(types.string()),
});

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

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

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

/** @internal */
export const ResponseBodyProxy$inboundSchema: z.ZodType<
  ResponseBodyProxy,
  z.ZodTypeDef,
  unknown
> = z.object({
  timestamp: types.number(),
  method: types.string(),
  host: types.string(),
  path: types.string(),
  statusCode: types.optional(types.number()),
  userAgent: z.array(types.string()),
  referer: types.string(),
  clientIp: types.optional(types.string()),
  region: types.string(),
  scheme: types.optional(types.string()),
  responseByteSize: types.optional(types.number()),
  cacheId: types.optional(types.string()),
  pathType: types.optional(types.string()),
  pathTypeVariant: types.optional(types.string()),
  vercelId: types.optional(types.string()),
  vercelCache: types.optional(ResponseBodyVercelCache$inboundSchema),
  lambdaRegion: types.optional(types.string()),
  wafAction: types.optional(ResponseBodyWafAction$inboundSchema),
  wafRuleId: types.optional(types.string()),
});

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

/** @internal */
export const ResponseBodyPayload$inboundSchema: z.ZodType<
  ResponseBodyPayload,
  z.ZodTypeDef,
  unknown
> = z.object({
  deploymentId: types.string(),
  info: types.optional(
    z.lazy(() => GetDeploymentEventsResponseBodyInfo$inboundSchema),
  ),
  text: types.optional(types.string()),
  id: types.string(),
  date: types.number(),
  serial: types.string(),
  created: types.optional(types.number()),
  statusCode: types.optional(types.number()),
  requestId: types.optional(types.string()),
  proxy: types.optional(z.lazy(() => ResponseBodyProxy$inboundSchema)),
});

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

/** @internal */
export const GetDeploymentEventsResponseBodyDeployments1$inboundSchema:
  z.ZodType<
    GetDeploymentEventsResponseBodyDeployments1,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type: GetDeploymentEventsResponseBodyDeploymentsType$inboundSchema,
    created: types.number(),
    payload: z.lazy(() => ResponseBodyPayload$inboundSchema),
  });

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

/** @internal */
export const GetDeploymentEventsResponseBody$inboundSchema: z.ZodType<
  GetDeploymentEventsResponseBody,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => GetDeploymentEventsResponseBodyDeployments2$inboundSchema),
  z.lazy(() => GetDeploymentEventsResponseBodyDeployments1$inboundSchema),
]);

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

/** @internal */
export const Info$inboundSchema: z.ZodType<Info, z.ZodTypeDef, unknown> = z
  .object({
    type: types.string(),
    name: types.string(),
    entrypoint: types.optional(types.string()),
    path: types.optional(types.string()),
    step: types.optional(types.string()),
    readyState: types.optional(types.string()),
  });

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

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

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

/** @internal */
export const GetDeploymentEventsResponseBody2$inboundSchema: z.ZodType<
  GetDeploymentEventsResponseBody2,
  z.ZodTypeDef,
  unknown
> = z.object({
  created: types.number(),
  date: types.number(),
  deploymentId: types.string(),
  id: types.string(),
  info: z.lazy(() => Info$inboundSchema),
  serial: types.string(),
  text: types.optional(types.string()),
  type: GetDeploymentEventsResponseBodyType$inboundSchema,
  level: types.optional(GetDeploymentEventsResponseBodyLevel$inboundSchema),
});

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

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

/** @internal */
export const GetDeploymentEventsResponseBodyDeploymentsInfo$inboundSchema:
  z.ZodType<
    GetDeploymentEventsResponseBodyDeploymentsInfo,
    z.ZodTypeDef,
    unknown
  > = z.object({
    type: types.string(),
    name: types.string(),
    entrypoint: types.optional(types.string()),
    path: types.optional(types.string()),
    step: types.optional(types.string()),
    readyState: types.optional(types.string()),
  });

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

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

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

/** @internal */
export const Proxy$inboundSchema: z.ZodType<Proxy, z.ZodTypeDef, unknown> = z
  .object({
    timestamp: types.number(),
    method: types.string(),
    host: types.string(),
    path: types.string(),
    statusCode: types.optional(types.number()),
    userAgent: z.array(types.string()),
    referer: types.string(),
    clientIp: types.optional(types.string()),
    region: types.string(),
    scheme: types.optional(types.string()),
    responseByteSize: types.optional(types.number()),
    cacheId: types.optional(types.string()),
    pathType: types.optional(types.string()),
    pathTypeVariant: types.optional(types.string()),
    vercelId: types.optional(types.string()),
    vercelCache: types.optional(VercelCache$inboundSchema),
    lambdaRegion: types.optional(types.string()),
    wafAction: types.optional(WafAction$inboundSchema),
    wafRuleId: types.optional(types.string()),
  });

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

/** @internal */
export const GetDeploymentEventsResponseBodyPayload$inboundSchema: z.ZodType<
  GetDeploymentEventsResponseBodyPayload,
  z.ZodTypeDef,
  unknown
> = z.object({
  deploymentId: types.string(),
  info: types.optional(
    z.lazy(() => GetDeploymentEventsResponseBodyDeploymentsInfo$inboundSchema),
  ),
  text: types.optional(types.string()),
  id: types.string(),
  date: types.number(),
  serial: types.string(),
  created: types.optional(types.number()),
  statusCode: types.optional(types.number()),
  requestId: types.optional(types.string()),
  proxy: types.optional(z.lazy(() => Proxy$inboundSchema)),
});

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

/** @internal */
export const GetDeploymentEventsResponseBody1$inboundSchema: z.ZodType<
  GetDeploymentEventsResponseBody1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: ResponseBodyType$inboundSchema,
  created: types.number(),
  payload: z.lazy(() => GetDeploymentEventsResponseBodyPayload$inboundSchema),
});

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

/** @internal */
export const GetDeploymentEventsDeploymentsResponseBody$inboundSchema:
  z.ZodType<GetDeploymentEventsDeploymentsResponseBody, z.ZodTypeDef, unknown> =
    smartUnion([
      z.lazy(() => GetDeploymentEventsResponseBody2$inboundSchema),
      z.lazy(() => GetDeploymentEventsResponseBody1$inboundSchema),
    ]);

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

/** @internal */
export const GetDeploymentEventsResponse$inboundSchema: z.ZodType<
  GetDeploymentEventsResponse,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.array(types.nullable(smartUnion([
    z.lazy(() => GetDeploymentEventsResponseBody2$inboundSchema),
    z.lazy(() =>
      GetDeploymentEventsResponseBody1$inboundSchema
    ),
  ]))),
  smartUnion([
    z.lazy(() => GetDeploymentEventsResponseBodyDeployments2$inboundSchema),
    z.lazy(() =>
      GetDeploymentEventsResponseBodyDeployments1$inboundSchema
    ),
  ]),
]);

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