/*
 * 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 { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  Link,
  Link$inboundSchema,
  Link$Outbound,
  Link$outboundSchema,
} from "./link.js";

/**
 * The type of the metric group
 */
export const DependentMetricGroupRepKind = {
  Funnel: "funnel",
  Standard: "standard",
} as const;
/**
 * The type of the metric group
 */
export type DependentMetricGroupRepKind = ClosedEnum<
  typeof DependentMetricGroupRepKind
>;

export type DependentMetricGroupRep = {
  /**
   * A unique key to reference the metric group
   */
  key: string;
  /**
   * A human-friendly name for the metric group
   */
  name: string;
  /**
   * The type of the metric group
   */
  kind: DependentMetricGroupRepKind;
  /**
   * The location and content type of related resources
   */
  links: { [k: string]: Link };
};

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

/** @internal */
export const DependentMetricGroupRep$inboundSchema: z.ZodType<
  DependentMetricGroupRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string(),
  name: z.string(),
  kind: DependentMetricGroupRepKind$inboundSchema,
  _links: z.record(Link$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "_links": "links",
  });
});
/** @internal */
export type DependentMetricGroupRep$Outbound = {
  key: string;
  name: string;
  kind: string;
  _links: { [k: string]: Link$Outbound };
};

/** @internal */
export const DependentMetricGroupRep$outboundSchema: z.ZodType<
  DependentMetricGroupRep$Outbound,
  z.ZodTypeDef,
  DependentMetricGroupRep
> = z.object({
  key: z.string(),
  name: z.string(),
  kind: DependentMetricGroupRepKind$outboundSchema,
  links: z.record(Link$outboundSchema),
}).transform((v) => {
  return remap$(v, {
    links: "_links",
  });
});

export function dependentMetricGroupRepToJSON(
  dependentMetricGroupRep: DependentMetricGroupRep,
): string {
  return JSON.stringify(
    DependentMetricGroupRep$outboundSchema.parse(dependentMetricGroupRep),
  );
}
export function dependentMetricGroupRepFromJSON(
  jsonString: string,
): SafeParseResult<DependentMetricGroupRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => DependentMetricGroupRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'DependentMetricGroupRep' from JSON`,
  );
}
