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

export type AiConfigsMetricDataSourceRefRep = {
  key: string;
  environmentKey?: string | undefined;
  name?: string | undefined;
  integrationKey?: string | undefined;
};

/** @internal */
export const AiConfigsMetricDataSourceRefRep$inboundSchema: z.ZodType<
  AiConfigsMetricDataSourceRefRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  key: z.string(),
  environmentKey: z.string().optional(),
  _name: z.string().optional(),
  _integrationKey: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "_name": "name",
    "_integrationKey": "integrationKey",
  });
});
/** @internal */
export type AiConfigsMetricDataSourceRefRep$Outbound = {
  key: string;
  environmentKey?: string | undefined;
  _name?: string | undefined;
  _integrationKey?: string | undefined;
};

/** @internal */
export const AiConfigsMetricDataSourceRefRep$outboundSchema: z.ZodType<
  AiConfigsMetricDataSourceRefRep$Outbound,
  z.ZodTypeDef,
  AiConfigsMetricDataSourceRefRep
> = z.object({
  key: z.string(),
  environmentKey: z.string().optional(),
  name: z.string().optional(),
  integrationKey: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    name: "_name",
    integrationKey: "_integrationKey",
  });
});

export function aiConfigsMetricDataSourceRefRepToJSON(
  aiConfigsMetricDataSourceRefRep: AiConfigsMetricDataSourceRefRep,
): string {
  return JSON.stringify(
    AiConfigsMetricDataSourceRefRep$outboundSchema.parse(
      aiConfigsMetricDataSourceRefRep,
    ),
  );
}
export function aiConfigsMetricDataSourceRefRepFromJSON(
  jsonString: string,
): SafeParseResult<AiConfigsMetricDataSourceRefRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AiConfigsMetricDataSourceRefRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AiConfigsMetricDataSourceRefRep' from JSON`,
  );
}
