qhana_plugin_runner.registry_client.client module
- class qhana_plugin_runner.registry_client.client.PluginRegistryClient(app: Flask | None = None, timeout=5)
Bases:
AbstractContextManagerA minimal client for the qhana plugin registry.
- fetch_by_api_link(link: ApiLink, query_params: dict | None = None, body: bytes | None = None, json: Any | None = None) ApiResponse
Fetch a response for a specific api link.
- Parameters:
link (ApiLink) – the link to the resource
query_params (Optional[dict], optional) – additional query params to use. Defaults to None.
body (Optional[bytes]) – a body to use for put or post requests. Defaults to None.
json (Optional[Any]) – a json serializable object to use as a body for put or post requests. Defaults to None.
- Returns:
the api response
- Return type:
- fetch_by_rel(rels: Sequence[str | Sequence[str]], query_params: dict | None = None, body: bytes | None = None, json: Any | None = None, allow_collection_resource: bool = True, base: ApiResponse | None = None) ApiResponse | None
Search the api following the provided path of rels.
This method is intended to be used inside a requests session.
Each step in the rels path will be searched for by
search_by_rel.- Parameters:
rels (Sequence[Union[str, Sequence[str]]]) – the path of rels to follow
query_params (Optional[dict], optional) – additional query params to use (will be used for every request during the search). Defaults to None.
body (Optional[bytes]) – a body to use for put or post requests. Defaults to None.
json (Optional[Any]) – a json serializable object to use as a body for put or post requests. Defaults to None.
allow_collection_resource (bool, optional) – if False this method will not return a collection resource as its final result. Defaults to True.
base (Optional[ApiResponse], optional) – a base resource to start the search from. Defaults to None.
- Returns:
the found api response
- Return type:
Optional[ApiResponse]
- init_app(app: Flask)
- search_by_rel(rel: str | Sequence[str], query_params: dict | None = None, body: bytes | None = None, json: Any | None = None, allow_collection_resource: bool = True, base: ApiResponse | None = None, ignore_base_match: bool = False) ApiResponse | None
search the api for a resource matching the given rel starting from the given base resource.
This method is intended to be used inside a requests session.
- Parameters:
rel (Union[str, Sequence[str]]) – the rel (or rels) to search for
query_params (Optional[dict], optional) – additional query params to use (will be used for every request during the search). Defaults to None.
body (Optional[bytes]) – a body to use for put or post requests. Defaults to None.
json (Optional[Any]) – a json serializable object to use as a body for put or post requests. Defaults to None.
allow_collection_resource (bool, optional) – if False this method will not return a collection resource as its final result. Defaults to True.
base (Optional[ApiResponse], optional) – the starting point of the search (in form of a resource). Defaults to None.
ignore_base_match (bool, optional) – if True ignore a match of the given base resource (use this if you pass a base and do not want it back immediately). Defaults to False.
- Raises:
ValueError – if no base is given and the plugin registry url is None
- Returns:
the found api response
- Return type:
Optional[ApiResponse]