/*
 * 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";
import {
  MetricInGroupRep,
  MetricInGroupRep$inboundSchema,
  MetricInGroupRep$Outbound,
  MetricInGroupRep$outboundSchema,
} from "./metricingrouprep.js";

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

export type DependentMetricGroupRepWithMetrics = {
  /**
   * 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: DependentMetricGroupRepWithMetricsKind;
  /**
   * The location and content type of related resources
   */
  links: { [k: string]: Link };
  /**
   * The metrics in the metric group
   */
  metrics?: Array<MetricInGroupRep> | undefined;
};

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

/** @internal */
export const DependentMetricGroupRepWithMetrics$inboundSchema: z.ZodType<
  DependentMetricGroupRepWithMetrics,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string(),
  name: z.string(),
  kind: DependentMetricGroupRepWithMetricsKind$inboundSchema,
  _links: z.record(Link$inboundSchema),
  metrics: z.array(MetricInGroupRep$inboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    "_links": "links",
  });
});
/** @internal */
export type DependentMetricGroupRepWithMetrics$Outbound = {
  key: string;
  name: string;
  kind: string;
  _links: { [k: string]: Link$Outbound };
  metrics?: Array<MetricInGroupRep$Outbound> | undefined;
};

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

export function dependentMetricGroupRepWithMetricsToJSON(
  dependentMetricGroupRepWithMetrics: DependentMetricGroupRepWithMetrics,
): string {
  return JSON.stringify(
    DependentMetricGroupRepWithMetrics$outboundSchema.parse(
      dependentMetricGroupRepWithMetrics,
    ),
  );
}
export function dependentMetricGroupRepWithMetricsFromJSON(
  jsonString: string,
): SafeParseResult<DependentMetricGroupRepWithMetrics, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) =>
      DependentMetricGroupRepWithMetrics$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'DependentMetricGroupRepWithMetrics' from JSON`,
  );
}
