/*
 * 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 GetMetricsRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * A comma-separated list of properties that can reveal additional information in the response.
   */
  expand?: string | undefined;
  /**
   * The number of metrics to return in the response. Defaults to 20. Maximum limit is 50.
   */
  limit?: number | undefined;
  /**
   * Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and returns the next `limit` items.
   */
  offset?: number | undefined;
  /**
   * A field to sort the items by. Prefix field by a dash ( - ) to sort in descending order. This endpoint supports sorting by `createdAt` or `name`.
   */
  sort?: string | undefined;
  /**
   * A comma-separated list of filters. This endpoint accepts filtering by `query`, `tags`, `eventKind`, `isNumeric`, `unitAggregationType`, `hasConnections`, `maintainerIds`, `maintainerTeamKey`, `view`, `dataSourceKeys`, `metricUsedIn`, `eventKeys`, and `versionIds`. To learn more about the filter syntax, read the 'Filtering metrics' section above.
   */
  filter?: string | undefined;
};

/** @internal */
export const GetMetricsRequest$inboundSchema: z.ZodType<
  GetMetricsRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectKey: z.string(),
  expand: z.string().optional(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
  sort: z.string().optional(),
  filter: z.string().optional(),
});
/** @internal */
export type GetMetricsRequest$Outbound = {
  projectKey: string;
  expand?: string | undefined;
  limit?: number | undefined;
  offset?: number | undefined;
  sort?: string | undefined;
  filter?: string | undefined;
};

/** @internal */
export const GetMetricsRequest$outboundSchema: z.ZodType<
  GetMetricsRequest$Outbound,
  z.ZodTypeDef,
  GetMetricsRequest
> = z.object({
  projectKey: z.string(),
  expand: z.string().optional(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
  sort: z.string().optional(),
  filter: z.string().optional(),
});

export function getMetricsRequestToJSON(
  getMetricsRequest: GetMetricsRequest,
): string {
  return JSON.stringify(
    GetMetricsRequest$outboundSchema.parse(getMetricsRequest),
  );
}
export function getMetricsRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetMetricsRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetMetricsRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetMetricsRequest' from JSON`,
  );
}
