metriceventdefaultrep.ts•2.37 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type MetricEventDefaultRep = {
/**
* Whether to disable defaulting missing unit events when calculating results. Defaults to false
*/
disabled?: boolean | undefined;
/**
* The default value applied to missing unit events. Set to 0 when <code>disabled</code> is false. No other values are currently supported.
*/
value?: number | undefined;
};
/** @internal */
export const MetricEventDefaultRep$inboundSchema: z.ZodType<
MetricEventDefaultRep,
z.ZodTypeDef,
unknown
> = z.object({
disabled: z.boolean().optional(),
value: z.number().optional(),
});
/** @internal */
export type MetricEventDefaultRep$Outbound = {
disabled?: boolean | undefined;
value?: number | undefined;
};
/** @internal */
export const MetricEventDefaultRep$outboundSchema: z.ZodType<
MetricEventDefaultRep$Outbound,
z.ZodTypeDef,
MetricEventDefaultRep
> = z.object({
disabled: z.boolean().optional(),
value: z.number().optional(),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace MetricEventDefaultRep$ {
/** @deprecated use `MetricEventDefaultRep$inboundSchema` instead. */
export const inboundSchema = MetricEventDefaultRep$inboundSchema;
/** @deprecated use `MetricEventDefaultRep$outboundSchema` instead. */
export const outboundSchema = MetricEventDefaultRep$outboundSchema;
/** @deprecated use `MetricEventDefaultRep$Outbound` instead. */
export type Outbound = MetricEventDefaultRep$Outbound;
}
export function metricEventDefaultRepToJSON(
metricEventDefaultRep: MetricEventDefaultRep,
): string {
return JSON.stringify(
MetricEventDefaultRep$outboundSchema.parse(metricEventDefaultRep),
);
}
export function metricEventDefaultRepFromJSON(
jsonString: string,
): SafeParseResult<MetricEventDefaultRep, SDKValidationError> {
return safeParse(
jsonString,
(x) => MetricEventDefaultRep$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'MetricEventDefaultRep' from JSON`,
);
}