transport_data.util.ckan.Client¶
- class transport_data.util.ckan.Client(address: str)[source]¶
Bases:
object
Wrapper around
ckanapi.RemoteCKAN
.This provides features such as:
Iterating over calls with rate limits.
Caching results, including combined results from multiple calls.
Converting return values to instances of
ModelProxy
subclasses.
Todo
Handle API keys via
transport_data.config
.
Methods
__init__
(address)group_list
([limit, max])license_list
([limit, max])list_action
(kind[, limit, max])Call the
{kind}_list
API endpoint.member_roles_list
([limit, max])organization_list
([limit, max])organization_show
(obj_or_id, *[, _cls])package_list
(*[, kind, limit, max])package_show
(obj_or_id, *[, _cls])show_action
(obj_or_id, _cls)Call the
{kind}_show
API endpoint.tag_list
(*[, kind, limit, max])tag_show
(obj_or_id, *[, _cls])- list_action(kind: str, limit: int | None = None, max: int | None = None) list ¶
Call the
{kind}_list
API endpoint.- Parameters:
kind – String identifying the kind of CKAN object to fetch.
limit – Number of results to fetch in a single query.
max – Maximum number of results to fetch.
- show_action(obj_or_id: str | dict | T, _cls: type[T]) T ¶
Call the
{kind}_show
API endpoint.If obj_or_id is an instance of
ModelProxy
, itsname
orid
is used for the query, and the same instance is updated with the response data and returned. If obj_or_id isstr
ordict
a new instance of aModelProxy
subclass is returned.The return value is cached.