API Documentation

Subpackages

Submodules

antelope.xdb_tokens module

Authorization Tokens for XDB access

This file contains a routine for constructing JWT grant payloads from a set of grant specifications that satisfy the class definition below. These methods can be used to construct and interpret JWTs generated for interaction with xdb and qdb servers.

class antelope.xdb_tokens.ResourceSpec(*, origin: str, source: str, ds_type: str, interfaces: List[str], static: bool, options: Dict, config: Dict[str, List[List]])

Bases: BaseModel

origin: str
source: str
ds_type: str
interfaces: List[str]
static: bool
options: Dict
config: Dict[str, List[List]]

[[‘air’, ‘to air’], [‘water’, ‘to water’]]}

Type:

n.b. the canonical config is {‘hints’

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class antelope.xdb_tokens.GrantSpec(*, username: str, origin: str, interface: str, grant_duration: int, qdb: bool, values: bool, update: bool, has_quota: bool)

Bases: BaseModel

A grant is assigned to an authorized user for a specific origin (including sub-origins) and interface.

username: str
origin: str
interface: str
grant_duration: int
qdb: bool
values: bool
update: bool
has_quota: bool
serialize()
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class antelope.xdb_tokens.JwtGrant(*, tid: str | None = None, iss: str, sub: str, exp: int, grants: str)

Bases: BaseModel

The contents of the JWT payload granted in response to a successful access request

xdb must have or obtain a publickey from an established keyserver, corresponding with the contents of the iss field

The signature is prepared using the private key associated with the issuer; xdb then verifies the signature with the public key

the grants are used authorize the query

tid: str | None
iss: str
sub: str
exp: int
grants: str
classmethod from_grants(grants: List[GrantSpec], issuer: str)
Parameters:
  • grants – Should be a list of GrantSpec subclasses

  • issuer

Returns:

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class antelope.xdb_tokens.IssuerKey(*, issuer: str, public_key: str, expiry: int)

Bases: BaseModel

An object of this class is exchanged to transmit information required to validate issuer tokens. I suppose this entire thing could be stored in a JWT. but storing a pubkey inside a JWT seems silly. But: it is done, as long as the pubkey being stored is NOT the one used to validate the token! that would be useless.

Anyway, we will stick to our existing plan: an instance of this class used as POST data.

issuer: str
public_key: str
expiry: int
classmethod from_issuer(issuer)
classmethod from_db_issuer(db_issuer)
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Module contents

Antelope Interface Definitions

The abstract classes in this sub-package define what information is made available via a stateless query to an Antelope resource of some kind. The interfaces must be instantiated in order to be used. In the core package

exception antelope.ValuesAccessRequired

Bases: Exception

The requested route requires a grant that has values=True

exception antelope.UpdateAccessRequired

Bases: Exception

The requested route requires a grant that has updates=True

class antelope.BasicQuery(archive, debug=False)

Bases: BasicInterface, IndexInterface, ExchangeInterface, QuantityInterface

A basic query depends on an archive– which has the following API:

  • archive.make_interface(interface): returns an implementation of the designated interface

  • archive.ref: returns the archive’s semantic reference

  • archive.source: returns the physical source (or URI) for the archive’s content

property origin
make_ref(entity)

Query subclasses can return abstracted versions of query results. :param entity: :return: an entity that could have a reference to a grounded query

class antelope.LcQuery(archive, debug=False)

Bases: BasicQuery, BackgroundInterface, ConfigureInterface

class antelope.FgQuery(archive, debug=False)

Bases: LcQuery, ForegroundInterface

antelope.local_ref(source, prefix=None)

Create a semantic ref for a local filename. Just uses basename. what kind of monster would access multiple different files with the same basename without specifying ref?

alternative is splitext(source)[0].translate(maketrans(‘/',’..’), ‘:~’) but ugghh…

Okay, FINE. I’ll use the full path. WITH leading ‘.’ removed.

Anyway, to be clear, local semantic references are not supposed to be distributed. :param source: :param prefix: [None] default ‘local’ :return:

antelope.q_node_activity(fg)

A reference quantity for dimensionless node activity. This should be part of Qdb reference quantities (but isn’t) :param fg: :return:

antelope.enum(iterable, filt=None, invert=True)

Enumerate an iterable for interactive use. return it as a list. Optional negative filter supplied as regex.

Parameters:
  • iterable

  • filt – regex to filter out entries from return and enumeration.

  • invert – [True] sense of filter. note default is negative i.e. to screen out matches (the thinking is that the input is already positive-filtered)

Returns: