/*
 * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GetMetricRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * The metric key
   */
  metricKey: string;
  /**
   * A comma-separated list of properties that can reveal additional information in the response. Supported fields are `experiments`, `experimentCount`, `metricGroups`, `metricGroupCount`, `eventSources`, `guardedRollouts`, `guardedRolloutCount`, `lastUsedInExperiment`, and `lastUsedInGuardedRollout`.
   */
  expand?: string | undefined;
  /**
   * The specific version ID of the metric
   */
  versionId?: string | undefined;
};

/** @internal */
export const GetMetricRequest$inboundSchema: z.ZodType<
  GetMetricRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectKey: z.string(),
  metricKey: z.string(),
  expand: z.string().optional(),
  versionId: z.string().optional(),
});
/** @internal */
export type GetMetricRequest$Outbound = {
  projectKey: string;
  metricKey: string;
  expand?: string | undefined;
  versionId?: string | undefined;
};

/** @internal */
export const GetMetricRequest$outboundSchema: z.ZodType<
  GetMetricRequest$Outbound,
  z.ZodTypeDef,
  GetMetricRequest
> = z.object({
  projectKey: z.string(),
  metricKey: z.string(),
  expand: z.string().optional(),
  versionId: z.string().optional(),
});

export function getMetricRequestToJSON(
  getMetricRequest: GetMetricRequest,
): string {
  return JSON.stringify(
    GetMetricRequest$outboundSchema.parse(getMetricRequest),
  );
}
export function getMetricRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetMetricRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetMetricRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetMetricRequest' from JSON`,
  );
}
