API reference
Client
Glance
Top-level client for the ATLAS Glance/Fence API.
__init__
__init__(*, settings: StareSettings | None = None, token_manager: TokenManager | None = None, token: str | None = None) -> None
Build the httpx client, attach the cache transport, and wire up resource accessors.
Resource accessors
AnalysisResource
Bases: _GettableResource[AnalysisSearchResult, Analysis]
Accessor for /analyses/ and /searchAnalysis endpoints.
PaperResource
Bases: _GettableResource[PaperSearchResult, Paper]
Accessor for /papers/ and /searchPaper endpoints.
ConfNoteResource
PubNoteResource
PlotResource
PublicationResource
Bases: _Resource[PublicationSearchResult]
Accessor for the /searchPublication endpoint.
get
get(ref_code: str, *, verbose: bool = False) -> PublicationSummary
Fetch a single publication by reference code via /searchPublication.
LeadingGroupResource
SubgroupResource
TriggerResource
Authentication
TokenManager
Manages OAuth2 tokens: PKCE login flow, storage, and refresh.
__init__
__init__(settings: StareSettings | None = None, token_path: Path | None = None, storage: TokenStorage | None = None) -> None
Initialise the token manager with optional settings, path, and storage overrides.
login
login(*, on_url_ready: Callable[[str], None] | None = None, get_manual_code: Callable[[], str | None] | None = None, offline: bool = False) -> None
Start PKCE browser flow; blocks until redirect received or manual code entered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_url_ready
|
Callable[[str], None] | None
|
Called with the authorization URL before the browser is opened — use this to display the URL to the user. |
None
|
get_manual_code
|
Callable[[], str | None] | None
|
Called in a background thread to obtain a fallback authorization code (e.g. via user input) when the browser redirect cannot reach the local callback server. |
None
|
offline
|
bool
|
Also request the |
False
|
export_refresh_token
Return the stored offline refresh token for transfer to another host.
Refuses online sessions, which would die with the SSO session. With
move=True the local copy is deleted (without server-side
revocation, so the exported token stays valid).
Keycloak rotates refresh tokens, so once the other host refreshes, any copy kept here may be rejected on its next refresh.
move=True is not transactional: the local copy is deleted before
the caller delivers the returned token. If that delivery or the remote
import fails, the session stays valid server-side but can no longer be
revoked from this host (:meth:logout only revokes tokens still
stored). A later login(offline=True) creates a separate session;
it neither recovers nor revokes the orphaned one, which lapses only
after the server's offline-session idle timeout.
import_refresh_token
Store a session from an offline refresh token exported elsewhere.
The token is redeemed immediately, so a bad or expired token fails here rather than on the first unattended run. A rejected token leaves any session already stored on this host untouched.
get_token
Return a valid access token, refreshing and exchanging as needed.
If settings.exchange_audience is set, the PKCE access token is
exchanged for an audience-scoped token via RFC 8693. The exchanged
token is cached in memory to avoid a round-trip on every API call.
get_pkce_access_token
Return the PKCE base access token (refreshing if needed).
Never performs a token exchange regardless of exchange_audience.
Raises :exc:~stare.exceptions.AuthenticationError if not logged in.
get_pkce_id_token
Return the stored PKCE id token, or None if absent or not logged in.
get_exchange_access_token
Return the raw RFC 8693 exchanged access token.
Returns None if exchange_audience is not configured.
Performs the exchange if the cached token is absent or nearly expired.
Raises :exc:~stare.exceptions.AuthenticationError if not logged in.
get_token_info
Return token metadata and decoded JWT claims, or None if not stored.
The JWT payload is decoded without signature verification — suitable only for display purposes, not security decisions.
get_session_info
Return whether the stored session is offline, or None if not stored.
Decoded from the refresh token without signature verification — suitable only for display purposes, not security decisions.
get_exchange_token_info
Decode and return info for the RFC 8693 exchanged token.
Returns None if exchange_audience is not configured.
Performs the exchange if the cached token is absent or nearly expired.
Raises :exc:~stare.exceptions.AuthenticationError if not logged in.
TokenStorage
Bases: ABC
Abstract base class for token storage backends.
FileTokenStorage
Bases: TokenStorage
Stores tokens as a JSON file on disk.
lock_path
property
Return the path to the advisory lock file for this storage backend.
__init__
Store the path where the token JSON file will be read and written.
save
Write tokens to the JSON file, creating parent directories as needed.
Written atomically to a 0o600 temp file in the same directory, then renamed onto the target, so the file is never briefly world-readable or observable mid-write.
KeyringTokenStorage
Bases: TokenStorage
Stores tokens as a JSON blob in the OS-native credential store.
Uses macOS Keychain, Linux Secret Service, or Windows Credential Locker
depending on the platform. The entire :class:_StoredToken is persisted
as a single JSON string to avoid partial-write races.
lock_path
property
Return the path to the advisory lock file for this storage backend.
save
Persist tokens as a JSON blob in the OS-native credential store.
Settings
StareSettings
Exceptions
StareError
Bases: Exception
Base exception for all stare errors.
AuthenticationError
Bases: StareError
Authentication failed or no credentials available.
TokenExpiredError
Bases: AuthenticationError
Stored token is expired; re-run stare login.
NetworkError
Bases: StareError
The Glance API could not be reached or did not respond (e.g. a timeout).
The underlying httpx transport error is kept as __cause__.
ApiError
Bases: StareError
An error response from the Glance API.
NotFoundError
ForbiddenError
UnauthorizedError
ResponseParseError
Bases: StareError
Raised when an API response cannot be parsed into the expected model.
Attributes:
| Name | Type | Description |
|---|---|---|
raw_data |
The raw object that failed validation (typically the parsed JSON dict/list), attached so callers can display it alongside the error message. |
DSL
The query DSL is available for programmatic use. See Query DSL for the syntax reference.
parse_dsl
Parse a DSL query string and return a validated AST.
Raises DSLSyntaxError on grammar violations and DSLValidationError on unknown fields. Normalizes field names to camelCase.
Condition
Bases: BaseModel
A single field OP value predicate.
to_dsl
Serialize to DSL string.
Raises ValueError for values that cannot be represented in the grammar's
STRING token (/"[^"\n\r\t\f\v]*"/):
- embedded double-quotes are unsupported (escaped-quote support not yet implemented)
- non-space whitespace (tabs, newlines, etc.) is excluded by the grammar
Wraps the value in double quotes when it is empty, contains spaces, parentheses, or square brackets, or is a DSL keyword/operator token (which would otherwise be reparsed as syntax); emits bare otherwise. Fields are always emitted bare after normalization.
And
Or
Operator
FieldRegistry
Catalogue of valid DSL field names for a given query mode.
__init__
Initialise with camelCase field names and an optional boolean subset.
for_mode
classmethod
for_mode(mode: Mode) -> FieldRegistry
Load the field catalogue for mode from the bundled TOML data file.
normalize
Convert each dot-separated segment from snake_case to camelCase.
validate
Raise DSLValidationError if the (normalized) field is not in the catalogue.
validate_normalized
Raise DSLValidationError if an already-normalized field is not in the catalogue.
validate_operator
validate_operator(normalized: str, operator: Operator) -> None
Raise DSLValidationError if operator is not valid for normalized field.
Boolean fields only accept = and !=; all other fields accept any operator.
DSLError
Bases: Exception
Base class for all DSL errors.
DSLSyntaxError
Bases: DSLError
Raised when the input cannot be parsed by the grammar.
DSLValidationError
Bases: DSLError
Raised when a field name or operator fails semantic validation.
Enums
All enums are also available in a lenient form via the Lenient* type aliases
(e.g. LenientAnalysisStatus). Lenient aliases accept unknown strings
gracefully — logging a warning and storing the raw value rather than raising a
validation error.
AnalysisStatus
Bases: StrEnum
Auto-generated enum.
PaperStatus
Bases: StrEnum
Auto-generated enum.
ConfnoteStatus
Bases: StrEnum
Auto-generated enum.
PlotStatus
Bases: StrEnum
Auto-generated enum.
AnalysisPhase0State
Bases: StrEnum
Auto-generated enum.
PaperPhase1State
Bases: StrEnum
Auto-generated enum.
PaperPhase2State
Bases: StrEnum
Auto-generated enum.
PaperPublicationphaseState
Bases: StrEnum
Auto-generated enum.
ConfnotePhase1State
Bases: StrEnum
Auto-generated enum.
PlotPhase1State
Bases: StrEnum
Auto-generated enum.
CollisionType
Bases: StrEnum
Observed collision type identifiers.
RepositoryType
Bases: StrEnum
Observed repository type values.
PublicationType
Bases: StrEnum
Observed publication type values (cross-references between record types).
MeetingType
Bases: StrEnum
Phase0 meeting role tags (used internally after flattening the 4 meeting lists).
URLs
URL builders for the ATLAS Glance web UI. Used internally to generate clickable hyperlinks in CLI output; also available for library callers.
analysis_url
Return the Glance web UI URL for an analysis.
paper_url
Return the Glance web UI URL for a paper.
confnote_url
Return the Glance web UI URL for a CONF note.
pubnote_url
Return the Glance web UI URL for a PUB note.
Models
Shared
Link
Meeting
Bases: _Base
A recorded meeting (EOI, editorial board request, pre-approval, approval, etc.).
The API sends a flat linkLabel / link pair; we fold them into a
single nested Link object on ingestion.
Analysis
Analysis
AnalysisSearchResult
Papers and notes
Paper
PaperSearchResult
ConfNote
ConfNoteSearchResult
PubNote
PubNoteSearchResult
Plot
PlotSearchResult
Publications
PublicationSummary
Bases: _Base
A summary record returned by GET /searchPublication.
PublicationSearchResult
Leading groups, subgroups, and triggers
LeadingGroup
Bases: _Base
A leading physics group returned by GET /searchLeadingGroup.
LeadingGroupSearchResult
Subgroup
Bases: _Base
A physics subgroup returned by GET /searchSubgroup.
SubgroupSearchResult
Trigger
Bases: _Base
A trigger entry returned by GET /searchTrigger.