flip_api.trusts_services.get_trusts

Attributes

router

Functions

_as_utc_iso(→ str | None)

Serialise a naive UTC datetime as an ISO-8601 string with a Z marker.

get_trusts(, user_id)

List every trust with its connection status.

Module Contents

flip_api.trusts_services.get_trusts.router
flip_api.trusts_services.get_trusts._as_utc_iso(value: datetime.datetime | None) str | None

Serialise a naive UTC datetime as an ISO-8601 string with a Z marker.

The Trust columns are timestamp without time zone but values are written via datetime.now(timezone.utc) — so they’re already UTC, the timezone is just stripped on persist. Tagging the wire format prevents the browser from treating the naive ISO as local time.

Parameters:

value (datetime | None) – A naive (or aware) UTC datetime, or None.

Returns:

ISO-8601 string with millisecond precision and a trailing Z, or None when value is None.

Return type:

str | None

flip_api.trusts_services.get_trusts.get_trusts(db: sqlmodel.Session = Depends(get_session), user_id: uuid.UUID = Depends(verify_token)) list[flip_api.domain.interfaces.trust.ITrustStatus]

List every trust with its connection status.

The single list-of-trusts endpoint: it powers the trust pickers (project staging, cohort query, charts) and the Connection Status page (trust table + topology). Readable by any authenticated user (Researcher, Viewer, Admin) — the fields are benign trust metadata (name, code, region, heartbeat, project count) with no secrets, so this is deliberately not admin-gated. Creating a trust (POST /admin/trusts) and the plaintext keys it returns stay admin-only.

Parameters:
  • db (Session) – Database session, provided by dependency injection.

  • user_id (UUID) – ID of the authenticated user making the request.

Returns:

Every trust with name, code, region, last_heartbeat, and project_count (count of rows in project_trust_intersect).

Return type:

list[ITrustStatus]

Raises:

HTTPException – 500 on database error.