GA4GH TRS Client
Client for implementations of the Global Alliance for Genomics and Health (GA4GH) Tool Registry Service API schema, including support for additional endpoints defined in ELIXIR Cloud & AAI's generic TRS-Filer TRS implementation.
The TRS API version underlying the client can be found here.
Table of Contents
- API documentation
To use the client import it as follows in your Python code after installation:
from trs_cli import TRSClient
Configure client class
It is possible to configure the
TRSClient class with the
method. The following configuration parameters are available:
||If set, the exception handler prints tracebacks for every exception encountered.|
||If set, responses JSON are not validated against the TRS API schemas. In that case, unserialized
from trs_cli import TRSClient TRSClient.config(debug=True, no_validate=True)
Note that as a class method, the
.config()method will affect all client instances, including existing ones.
Create client instance
Via TRS hostname
A client instance can be created by specifying the domain name of a TRS instance, including the URL schema:
from trs_cli import TRSClient client = TRSClient(uri="https://my-trs.app") # Client instantiated for URL: https://my-trs.app:443/ga4gh/trs/v2
Fully spec-compliant TRS implementations will always be
https URLs, served at port
443 and at the base path
ga4gh/trs/v2. However, to allow the client to be used against development
versions of TRS implementations,
http URLs are supported as well (default
80), and the port and base path at which the API endpoints are served
can be overridden with the
from trs_cli import TRSClient client = TRSClient( uri="http://my-trs.app", port=8080, base_path="my/api/route", ) # Client instantiated for URL: http://my-trs.app:8080/my/api/route
Via TRS URI
Clients can also be created by passing a hostname-based TRS URI:
from trs_cli import TRSClient client = TRSClient(uri="trs://my-trs.app/SOME_TOOL") # Client instantiated for URL: https://my-trs.app:443/ga4gh/trs/v1
NOTE: Only the hostname part of the TRS URI is evaluated, not the tool ID.
Port and base path can be overridden as described above. In addition, the
client constructor also defines the
use_http flag, which instantiates a
client for an
http URL when a TRS URI is passed. The flag has no effect
when a TRS hostname URL is provided instead of a TRS URI:
from trs_cli import TRSClient client = TRSClient( uri="trs://my-trs.app/SOME_TOOL", use_http=True, ) # Client instantiated for URL: http://my-trs.app:443/ga4gh/trs/v1
- All endpoint access methods require a client instance.
- For accessing endpoints that require authorization, see the dedicated section.
- Responses that do not return the tool ID as a single string return Pydantic models instead. If dictionaries are preferred instead, they can be obtained with
response.dict(). See the Pydantic export documentation for further details.
- See the API documentation for further details on each access method.
Endpoints as specified in the TRS API
Access methods for each Tool Registry Service API endpoint are available:
||List all tool types|
||List all tools|
||List one specific tool, acts as an anchor for self references|
||List versions of a tool|
||List one specific tool version, acts as an anchor for self references|
||Get the container specification(s) for the specified image.|
||Get the tool descriptor for the specified tool|
||Get additional tool descriptor files relative to the main file|
||Get a list of objects that contain the relative path and file type|
||Get a list of test JSONs|
||Show information about this service. It is assumed that removing this endpoint from a URL will result in a valid URL to query against|
In addition to TRS API endpoints, the
TRSClient class also provides access
methods for additional endpoints implemented in
||Create a tool class|
||Create or update a tool class|
||Delete a tool class|
||Add a tool|
||Add or update a tool|
||Delete a tool|
||Add a tool version|
||Add or update a tool version|
||Delete a tool version|
||Register service info|
Authorization bearer tokens can be provided either during
client instantiation or when calling an endpoint access method. The bearer
token is sent along as an
Authorization header with every request sent from
the instantiated client instance.
NOTE: Whenever a token is specified when calling an API endpoint, the
tokenvariable of that particular client instance is overridden. Thus, subsequent calls from that client will all carry the new token value, unless overridden again.
The following example illustrates this behavior:
from trs_cli import TRSClient # No token passed during client instantiation client = TRSClient(uri="https://my-trs.app") # Value of client.token: None # Token passed during client instantiation client_2 = TRSClient( uri="https://my-trs.app", token="MyT0k3n", ) # Value of client_2.token: MyT0k3n
Automatically built API documentation is available.
You can install
TRS-cli in one of two ways:
Via package manager
pip install trs_cli # Or for the latest development version: pip install git+https://github.com/elixir-cloud-aai/TRS-cli.git#egg=trs_cli
git clone https://github.com/elixir-cloud-aai/TRS-cli.git cd TRS-cli python setup.py install
This project is a community effort and lives off your contributions, be it in the form of bug reports, feature requests, discussions, or fixes and other code changes. Please refer to our organization's contributing guidelines if you are interested to contribute. Please mind the code of conduct for all interactions with the community.
The project adopts the semantic versioning scheme for versioning. Currently the service is in beta stage, so the API may change without further notice.
The project is a collaborative effort under the umbrella of ELIXIR Cloud & AAI. Follow the link to get in touch with us via chat or email. Please mention the name of this service for any inquiry, proposal, question etc.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.