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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  AuditLogEntryListingRep,
  AuditLogEntryListingRep$inboundSchema,
  AuditLogEntryListingRep$Outbound,
  AuditLogEntryListingRep$outboundSchema,
} from "./auditlogentrylistingrep.js";
import {
  Link,
  Link$inboundSchema,
  Link$Outbound,
  Link$outboundSchema,
} from "./link.js";

export type AuditLogEntryListingRepCollection = {
  /**
   * An array of audit log entries
   */
  items: Array<AuditLogEntryListingRep>;
  /**
   * The location and content type of related resources
   */
  links: { [k: string]: Link };
};

/** @internal */
export const AuditLogEntryListingRepCollection$inboundSchema: z.ZodType<
  AuditLogEntryListingRepCollection,
  z.ZodTypeDef,
  unknown
> = z.object({
  items: z.array(AuditLogEntryListingRep$inboundSchema),
  _links: z.record(Link$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "_links": "links",
  });
});
/** @internal */
export type AuditLogEntryListingRepCollection$Outbound = {
  items: Array<AuditLogEntryListingRep$Outbound>;
  _links: { [k: string]: Link$Outbound };
};

/** @internal */
export const AuditLogEntryListingRepCollection$outboundSchema: z.ZodType<
  AuditLogEntryListingRepCollection$Outbound,
  z.ZodTypeDef,
  AuditLogEntryListingRepCollection
> = z.object({
  items: z.array(AuditLogEntryListingRep$outboundSchema),
  links: z.record(Link$outboundSchema),
}).transform((v) => {
  return remap$(v, {
    links: "_links",
  });
});

export function auditLogEntryListingRepCollectionToJSON(
  auditLogEntryListingRepCollection: AuditLogEntryListingRepCollection,
): string {
  return JSON.stringify(
    AuditLogEntryListingRepCollection$outboundSchema.parse(
      auditLogEntryListingRepCollection,
    ),
  );
}
export function auditLogEntryListingRepCollectionFromJSON(
  jsonString: string,
): SafeParseResult<AuditLogEntryListingRepCollection, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AuditLogEntryListingRepCollection$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AuditLogEntryListingRepCollection' from JSON`,
  );
}
