Skip to main content

Where Cameras Come From

The engine runs cameras, the VAPIX service talks to them — but nothing so far says which cameras exist, where they are, or how to log into them. That knowledge doesn't originate in this platform at all. It lives in an external system run by UCSD, and everything here is a mirror of it.

The one idea to hold on to​

UCSD's Metadata API is the source of truth for the camera fleet, and the platform only ever pulls from it — never the reverse. Alert.CA.UCSDService is a thin client for that API: authenticate, then fetch device configs, credentials, and ACAP data.

Auth is a simple token exchange — a username/password POST that returns a bearer token:

var bodyText = $"{{\"username\": \"{_metadataApiOptions.Username}\", \"password\": \"{_metadataApiOptions.Password}\"}}";
var tokenResponse = await _httpClient.PostAsync(_metadataApiOptions.OAuthUrl, body);

Every read method then sends that token as Bearer. The token is threaded through as an optional argument so a caller fetching many things in one pass acquires it once and reuses it, rather than re-authenticating per call:

public async Task<CameraConfigResponse?> GetAllDeviceConfigsAsync(string? existingToken = null)
{
string token = existingToken ?? await GetToken();
// …
}
Gotcha: this platform can't fix bad camera data

Because UCSD is upstream and the flow is one-way, a camera with a wrong location or a bad credential in UCSD stays wrong here until it's fixed in UCSD and the next pull picks it up. Editing the mirrored Cosmos doc directly is not a fix — the next refresh overwrites it. Bad inventory data is reported upstream, not patched locally.

Wrapping up​

The camera fleet is defined by UCSD's Metadata API; UCSDService is a token-authenticated client that pulls device configs, credentials, and ACAP data, and the platform treats that data as read-only truth to mirror. Local edits don't stick — corrections happen upstream.

Next, the loop that does the mirroring — pulling from UCSD and reconciling it into the platform's stores every few minutes: The Refresh Loop.