export type GetApiPipelineMetricUsageProfileArgs = {from: string, to: string, id: string, annotation: 'app' | 'host' | 'level' | 'log_type', limit?: number | undefined}; export type GetApiPipelineMetricUsageProfileOptions = {baseUrl?: string | undefined, PipelineServiceKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetch usage metrics * * GET /pipeline/metric/usage/profile */ export const getApiPipelineMetricUsageProfile = async (args: GetApiPipelineMetricUsageProfileArgs, options?: GetApiPipelineMetricUsageProfileOptions) => { const {baseUrl = "https://api.mezmo.com/v3", fetch: fetchFn = fetch, PipelineServiceKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.id != null) query.append("id", String(args.id)) if (args.annotation != null) query.append("annotation", String(args.annotation)) if (args.limit != null) query.append("limit", String(args.limit)) if (PipelineServiceKey !== undefined) headers.set("Authorization", PipelineServiceKey) const url = `${baseUrl.replace(/\/+$/, '')}/pipeline/metric/usage/profile${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 };