Skip to content

Spec

client.spec is a Registry built from one copy of the T3 OpenAPI spec. See endpoints and the spec.

Registry

Registry(spec: Mapping[str, Any], source: SpecSource | None = None)

Every operation in one copy of the spec.

version property

version: str

source instance-attribute

source = source

endpoints instance-attribute

endpoints: list[Endpoint] = self._build()

list

list(kind: Kind | None = None) -> builtins.list[Endpoint]

Every endpoint, or every endpoint of one kind.

find

find(query: str = '', kind: Kind | None = None) -> builtins.list[Endpoint]

Endpoints whose ID, path, summary or tags contain every word of query.

endpoint

endpoint(name: str, *, method: str | None = None, kind: Kind | Iterable[Kind] | None = None, path_params: Iterable[str] | None = None) -> Endpoint

Find one operation by endpoint ID or path.

One ID or path can name several operations. method, kind and the names of the path parameters you have narrow it down to one.

ids

ids() -> builtins.list[str]

check_params

check_params(endpoint: Endpoint, query: Mapping[str, Any], path_values: Mapping[str, Any], *, has_body: bool, python_names: Mapping[str, str] | None = None) -> None

Raise SpecError for missing required parameters, warn about unknown ones.

Endpoint dataclass

Endpoint(id: str | None, method: str, path: str, kind: Kind, tags: tuple[str, ...] = (), summary: str = '', params: tuple[Param, ...] = (), body_required: bool = False, has_body: bool = False, response_types: tuple[str, ...] = (), public: bool = False, body_type: str | None = None)

One operation (method + path) in the spec.

Attributes:

Name Type Description
body_type str | None

The JSON schema type of the JSON request body ("array" or "object"), or None when the route takes no JSON body.

id instance-attribute

id: str | None

method instance-attribute

method: str

path instance-attribute

path: str

kind instance-attribute

kind: Kind

tags class-attribute instance-attribute

tags: tuple[str, ...] = ()

summary class-attribute instance-attribute

summary: str = ''

params class-attribute instance-attribute

params: tuple[Param, ...] = ()

body_required class-attribute instance-attribute

body_required: bool = False

has_body class-attribute instance-attribute

has_body: bool = False

response_types class-attribute instance-attribute

response_types: tuple[str, ...] = ()

public class-attribute instance-attribute

public: bool = False

body_type class-attribute instance-attribute

body_type: str | None = None

body_is_array property

body_is_array: bool

True when the JSON body is a list. Most Metrc write routes take one, even for one object.

path_params property

path_params: tuple[Param, ...]

query_params property

query_params: tuple[Param, ...]

is_write property

is_write: bool

param

param(name: str) -> Param | None

label

label() -> str

Param dataclass

Param(name: str, location: str, required: bool = False, description: str = '', schema: Mapping[str, Any] = dict())

One operation parameter, with $refs resolved.

name instance-attribute

name: str

location instance-attribute

location: str

required class-attribute instance-attribute

required: bool = False

description class-attribute instance-attribute

description: str = ''

schema class-attribute instance-attribute

schema: Mapping[str, Any] = field(default_factory=dict)

is_array property

is_array: bool

choices property

choices: tuple[str, ...]

The values the spec allows (its enum, or its items' for an array), else ().

SpecSource dataclass

SpecSource(kind: SourceKind, host: str, path: Path | None = None, fetched_at: float | None = None, etag: str | None = None)

Which copy of the spec is in use.

kind instance-attribute

kind: SourceKind

host instance-attribute

host: str

path class-attribute instance-attribute

path: Path | None = None

fetched_at class-attribute instance-attribute

fetched_at: float | None = None

etag class-attribute instance-attribute

etag: str | None = None

age_seconds

age_seconds(now: Callable[[], float] = time.time) -> float | None

describe

describe() -> str