Skip to main content

GA4GH TRS Client

Project description

TRS-cli

License Build_status Coverage GitHub_tag PyPI_release

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.

Usage

To use the client import it as follows in your Python code after installation:

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.client 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 available at 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 port 80), and the port and base path at which the API endpoints are served can be overridden with the port and base_path arguments:

from trs_cli.client 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.client 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.client 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

Access endpoints

NOTES:

  • 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.

GET endpoints

Coming soon...

POST & PUT endpoints

Coming soon...

DELETE endpoints

Coming soon...

Authorization

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 token variable 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.client 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

API docs

Automatically built API documentation is available.

Installation

You can install TRS-cli in one of two ways:

Installation via package manager

pip install trs_cli

# Or for latest development version:
pip install git+https://github.com/elixir-cloud-aai/TRS-cli.git#egg=trs_cli

Manual installation

git clone https://github.com/elixir-cloud-aai/TRS-cli.git
cd TRS-cli
python setup.py install

Contributing

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.

Versioning

The project adopts the semantic versioning scheme for versioning. Currently the service is in beta stage, so the API may change without further notice.

License

This project is covered by the Apache License 2.0 also shipped with this repository.

Contact

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.

logo_banner

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trs_cli-0.4.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

trs_cli-0.4.0-py3.7.egg (31.4 kB view details)

Uploaded Egg

trs_cli-0.4.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file trs_cli-0.4.0.tar.gz.

File metadata

  • Download URL: trs_cli-0.4.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.4

File hashes

Hashes for trs_cli-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3245df12ca8ab25dec15460b07e9dd921f4fb1d5fe77e0a1635132cf2d6b38de
MD5 d62985270e68f6ec1560eb98ed5cae87
BLAKE2b-256 21c9639368dadbf1979afef2cc07d1d9f0d7a7064165069f9c45c34dbb4ab64e

See more details on using hashes here.

File details

Details for the file trs_cli-0.4.0-py3.7.egg.

File metadata

  • Download URL: trs_cli-0.4.0-py3.7.egg
  • Upload date:
  • Size: 31.4 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4

File hashes

Hashes for trs_cli-0.4.0-py3.7.egg
Algorithm Hash digest
SHA256 5035bb646f5f670f6ccaee86adc0ff004d24f22e6d4711d0df6f4c83e6e73029
MD5 15bb89e326a13450b63a9a11d8973a88
BLAKE2b-256 355eca01aac86ff06313b65a2b9bb31de3ad7216d15dc4e42eee5b011bfc74a3

See more details on using hashes here.

File details

Details for the file trs_cli-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: trs_cli-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.4

File hashes

Hashes for trs_cli-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 674af549d82fd088c87ae3a7f447cc2f2169790529ad5f613917cb3927bef821
MD5 b3e920b707d75399535110bcfd202e66
BLAKE2b-256 e5431e88e02f26c96b62cf5c3b190a9aaa9991bbc6718173b296d9aaaa5495ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page