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

export type GetEdgeConfigBackupsRequest = {
  edgeConfigId: string;
  next?: string | undefined;
  limit?: number | undefined;
  metadata?: string | 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 GetEdgeConfigBackupsMetadata = {
  updatedAt?: string | undefined;
  updatedBy?: string | undefined;
  itemsCount?: number | undefined;
  itemsBytes?: number | undefined;
};

export type Backups = {
  metadata?: GetEdgeConfigBackupsMetadata | undefined;
  id: string;
  lastModified: number;
};

export type GetEdgeConfigBackupsPagination = {
  hasNext: boolean;
  next?: string | undefined;
};

export type GetEdgeConfigBackupsResponseBody = {
  backups: Array<Backups>;
  pagination: GetEdgeConfigBackupsPagination;
};

/** @internal */
export type GetEdgeConfigBackupsRequest$Outbound = {
  edgeConfigId: string;
  next?: string | undefined;
  limit?: number | undefined;
  metadata?: string | undefined;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const GetEdgeConfigBackupsRequest$outboundSchema: z.ZodType<
  GetEdgeConfigBackupsRequest$Outbound,
  z.ZodTypeDef,
  GetEdgeConfigBackupsRequest
> = z.object({
  edgeConfigId: z.string(),
  next: z.string().optional(),
  limit: z.number().optional(),
  metadata: z.string().optional(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function getEdgeConfigBackupsRequestToJSON(
  getEdgeConfigBackupsRequest: GetEdgeConfigBackupsRequest,
): string {
  return JSON.stringify(
    GetEdgeConfigBackupsRequest$outboundSchema.parse(
      getEdgeConfigBackupsRequest,
    ),
  );
}

/** @internal */
export const GetEdgeConfigBackupsMetadata$inboundSchema: z.ZodType<
  GetEdgeConfigBackupsMetadata,
  z.ZodTypeDef,
  unknown
> = z.object({
  updatedAt: types.optional(types.string()),
  updatedBy: types.optional(types.string()),
  itemsCount: types.optional(types.number()),
  itemsBytes: types.optional(types.number()),
});

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

/** @internal */
export const Backups$inboundSchema: z.ZodType<Backups, z.ZodTypeDef, unknown> =
  z.object({
    metadata: types.optional(
      z.lazy(() => GetEdgeConfigBackupsMetadata$inboundSchema),
    ),
    id: types.string(),
    lastModified: types.number(),
  });

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

/** @internal */
export const GetEdgeConfigBackupsPagination$inboundSchema: z.ZodType<
  GetEdgeConfigBackupsPagination,
  z.ZodTypeDef,
  unknown
> = z.object({
  hasNext: types.boolean(),
  next: types.optional(types.string()),
});

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

/** @internal */
export const GetEdgeConfigBackupsResponseBody$inboundSchema: z.ZodType<
  GetEdgeConfigBackupsResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  backups: z.array(z.lazy(() => Backups$inboundSchema)),
  pagination: z.lazy(() => GetEdgeConfigBackupsPagination$inboundSchema),
});

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