Files
zooqueen 252e1cb076 Generated clients call the API where it is mounted
`insights/mount.py` is explicit: `/v1/` is the mount and `/api/` is the older
spelling, kept on the wire for released CLI builds and personal-API-key
holders and rewritten once at the edge by `ApiRewriteMiddleware`. Our own
frontend was still on the older spelling: the orval clients were generated
two days before the mount moved and the move did not regenerate them, so 70
files and 2323 paths said `/api/`.

That is not only a spelling. `prepareUrl` in `lib/api.ts` rewrites `/v1/*` to
the selected region's host in OAuth mode and nothing else, because that is
what the cloud CORS allowlist covers — so every generated call quietly stayed
same-origin, and `getExportsContentRetrieveUrl` builds an `<img src>` that
never reaches `lib/api.ts` at all.

The clients are regenerated from a spec that needs postgres, the datastore and
Django, so this is the path strings only, which is the whole of what the mount
move changes in them: orval copies paths verbatim from the spec, and the spec
takes them from the URLconf. Doc comments carried the same stale prefix and
move with them; their Python docstrings already say `/v1/`. The two frozen
OAuth client-metadata paths are identifiers rather than API surface and appear
in none of these files.

The Slack task prompt told the agent to POST to
`$INSIGHTS_API_URL/api/projects/...`, which is a live request path, not prose.
2026-08-24 23:13:08 -07:00

239 lines
7.9 KiB
TypeScript
Generated

import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
/**
* Auto-generated from the Django backend OpenAPI schema.
* To modify these types, update the Django serializers or views, then run:
* insightscli build:openapi
* Questions or issues? #team-devex on Slack
*
* Insights API - generated
* OpenAPI spec version: 1.0.0
*/
import type {
AppMetricsResponseApi,
AppMetricsTotalsResponseApi,
MetricsAttributeValuesRetrieveParams,
MetricsAttributesRetrieveParams,
MetricsValuesRetrieveParams,
_HasMetricsResponseApi,
_MetricAnomalyReportApi,
_MetricAnomalyRequestApi,
_MetricAttributeKeysResponseApi,
_MetricAttributeValuesResponseApi,
_MetricNamesResponseApi,
_MetricQueryRequestApi,
_MetricQueryResponseApi,
_MetricSamplesRequestApi,
_MetricSamplesResponseApi,
} from './api.schemas'
export const getEventFilterMetricsRetrieveUrl = (projectId: string) => {
return `/v1/projects/${projectId}/event_filter/metrics/`
}
/**
* Single event filter per team.
* GET /event_filter/ — returns the config (or null if not yet created)
* POST /event_filter/ — creates or updates the config (upsert)
* GET /event_filter/metrics/ — time-series metrics
* GET /event_filter/metrics/totals/ — aggregate totals
*/
export const eventFilterMetricsRetrieve = async (
projectId: string,
options?: RequestInit
): Promise<AppMetricsResponseApi> => {
return apiMutator<AppMetricsResponseApi>(getEventFilterMetricsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}
export const getEventFilterMetricsTotalsRetrieveUrl = (projectId: string) => {
return `/v1/projects/${projectId}/event_filter/metrics/totals/`
}
/**
* Single event filter per team.
* GET /event_filter/ — returns the config (or null if not yet created)
* POST /event_filter/ — creates or updates the config (upsert)
* GET /event_filter/metrics/ — time-series metrics
* GET /event_filter/metrics/totals/ — aggregate totals
*/
export const eventFilterMetricsTotalsRetrieve = async (
projectId: string,
options?: RequestInit
): Promise<AppMetricsTotalsResponseApi> => {
return apiMutator<AppMetricsTotalsResponseApi>(getEventFilterMetricsTotalsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}
export const getMetricsAttributeValuesRetrieveUrl = (
projectId: string,
params: MetricsAttributeValuesRetrieveParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/v1/projects/${projectId}/metrics/attribute_values/?${stringifiedParams}`
: `/v1/projects/${projectId}/metrics/attribute_values/`
}
/**
* Observed values for one metric attribute key, most frequent first.
* Backs the filter bar's value autocomplete.
*/
export const metricsAttributeValuesRetrieve = async (
projectId: string,
params: MetricsAttributeValuesRetrieveParams,
options?: RequestInit
): Promise<_MetricAttributeValuesResponseApi> => {
return apiMutator<_MetricAttributeValuesResponseApi>(getMetricsAttributeValuesRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getMetricsAttributesRetrieveUrl = (projectId: string, params?: MetricsAttributesRetrieveParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/v1/projects/${projectId}/metrics/attributes/?${stringifiedParams}`
: `/v1/projects/${projectId}/metrics/attributes/`
}
/**
* Distinct attribute keys seen on the team's metrics (datapoint and
* resource attributes merged), most frequent first. Backs the filter
* bar's key autocomplete.
*/
export const metricsAttributesRetrieve = async (
projectId: string,
params?: MetricsAttributesRetrieveParams,
options?: RequestInit
): Promise<_MetricAttributeKeysResponseApi> => {
return apiMutator<_MetricAttributeKeysResponseApi>(getMetricsAttributesRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getMetricsCharacterizeCreateUrl = (projectId: string) => {
return `/v1/projects/${projectId}/metrics/characterize/`
}
/**
* Characterize a metric anomaly: compare an anomaly window against a
* baseline, find the onset, and rank which label values moved.
*/
export const metricsCharacterizeCreate = async (
projectId: string,
_metricAnomalyRequestApi: _MetricAnomalyRequestApi,
options?: RequestInit
): Promise<_MetricAnomalyReportApi> => {
return apiMutator<_MetricAnomalyReportApi>(getMetricsCharacterizeCreateUrl(projectId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(_metricAnomalyRequestApi),
})
}
export const getMetricsHasMetricsRetrieveUrl = (projectId: string) => {
return `/v1/projects/${projectId}/metrics/has_metrics/`
}
export const metricsHasMetricsRetrieve = async (
projectId: string,
options?: RequestInit
): Promise<_HasMetricsResponseApi> => {
return apiMutator<_HasMetricsResponseApi>(getMetricsHasMetricsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}
export const getMetricsQueryCreateUrl = (projectId: string) => {
return `/v1/projects/${projectId}/metrics/query/`
}
export const metricsQueryCreate = async (
projectId: string,
_metricQueryRequestApi: _MetricQueryRequestApi,
options?: RequestInit
): Promise<_MetricQueryResponseApi> => {
return apiMutator<_MetricQueryResponseApi>(getMetricsQueryCreateUrl(projectId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(_metricQueryRequestApi),
})
}
export const getMetricsSamplesCreateUrl = (projectId: string) => {
return `/v1/projects/${projectId}/metrics/samples/`
}
/**
* Raw individual emissions for a metric (the events model), newest
* first — backs the Samples view and the metric->trace pivot.
*/
export const metricsSamplesCreate = async (
projectId: string,
_metricSamplesRequestApi: _MetricSamplesRequestApi,
options?: RequestInit
): Promise<_MetricSamplesResponseApi> => {
return apiMutator<_MetricSamplesResponseApi>(getMetricsSamplesCreateUrl(projectId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(_metricSamplesRequestApi),
})
}
export const getMetricsValuesRetrieveUrl = (projectId: string, params?: MetricsValuesRetrieveParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/v1/projects/${projectId}/metrics/values/?${stringifiedParams}`
: `/v1/projects/${projectId}/metrics/values/`
}
/**
* Distinct metric names for the team. Backs the picker UI.
*/
export const metricsValuesRetrieve = async (
projectId: string,
params?: MetricsValuesRetrieveParams,
options?: RequestInit
): Promise<_MetricNamesResponseApi> => {
return apiMutator<_MetricNamesResponseApi>(getMetricsValuesRetrieveUrl(projectId, params), {
...options,
method: 'GET',
})
}