export type GetApiPipelinePipelineIdEventMetricsArgs = {bucket: number, field?: ('app' | 'host' | 'label' | 'level') | undefined, from: string, to: string, with_changes?: boolean | undefined, pipeline_id: string}; export type GetApiPipelinePipelineIdEventMetricsOptions = {baseUrl?: string | undefined, PipelineServiceKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get event metrics for a pipeline * * GET /pipeline/{pipeline_id}/event_metrics */ export const getApiPipelinePipelineIdEventMetrics = async (args: GetApiPipelinePipelineIdEventMetricsArgs, options?: GetApiPipelinePipelineIdEventMetricsOptions) => { const {baseUrl = "https://api.mezmo.com/v3", fetch: fetchFn = fetch, PipelineServiceKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.bucket != null) query.append("bucket", String(args.bucket)) if (args.field != null) query.append("field", String(args.field)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.with_changes != null) query.append("with_changes", String(args.with_changes)) if (PipelineServiceKey !== undefined) headers.set("Authorization", PipelineServiceKey) const url = `${baseUrl.replace(/\/+$/, '')}/pipeline/${encodeURIComponent(String(args.pipeline_id))}/event_metrics${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };