Package: trs-cli
TRS-cliClient for implementations of theGlobal Alliance for Genomics and
Health (GA4GH)Tool Registry Service APIschema,
including support for additional endpoints defined inELIXIR Cloud &
AAI'sgenericTRS-FilerTRS
implementation.The TRS API version underlying the client can be foundhere.TRS-cli has so far been succesfully tested with theTRS-FilerandWorkflowHubTRS implementations. WorkflowHub's public
TRS API endpoint can be found here:https://dev.workflowhub.eu/ga4gh/trs/v2Table of ContentsUsageConfigure client classCreate client instanceAccess methodsAuthorizationAPI documentationInstallationVia package managerManual installationContributingVersioningLicenseContactUsageTo use the client import it as follows in your Python code afterinstallation:fromtrs_cliimportTRSClientConfigure client classIt is possible to configure theTRSClientclass with the.config()class
method. The following configuration parameters are available:ParameterTypeDefaultDescriptiondebugboolFalseIf set, the exception handler prints tracebacks for every exception encountered.no_validateboolFalseIf set, responses JSON are not validated against the TRS API schemas. In that case, unserializedresponseobjects are returned. Set this flag if the TRS implementation you are working with is not fully compliant with the TRS API specification.Example:fromtrs_cliimportTRSClientTRSClient.config(debug=True,no_validate=True)Note that as aclass method, the.config()method will affectallclient instances, including existing ones.Create client instanceVia TRS hostnameA client instance can be created by specifying the domain name of a TRS
instance, including the URL schema:fromtrs_cliimportTRSClientclient=TRSClient(uri="https://my-trs.app")# Client instantiated for URL: https://my-trs.app:443/ga4gh/trs/v2Fullyspec-compliantTRS implementations will always be
available athttpsURLs, served at port443and at the base pathga4gh/trs/v2. However, to allow the client to be used against development
versions of TRS implementations,httpURLs are supported as well (default
port80), and the port and base path at which the API endpoints are served
can be overridden with theportandbase_patharguments:fromtrs_cliimportTRSClientclient=TRSClient(uri="http://my-trs.app",port=8080,base_path="my/api/route",)# Client instantiated for URL: http://my-trs.app:8080/my/api/routeVia TRS URIClients can also be created by passing ahostname-based TRS
URI:fromtrs_cliimportTRSClientclient=TRSClient(uri="trs://my-trs.app/SOME_TOOL")# Client instantiated for URL: https://my-trs.app:443/ga4gh/trs/v1NOTE: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 theuse_httpflag, which instantiates a
client for anhttpURL when a TRS URI is passed. The flag has no effect
when a TRS hostname URL is provided instead of a TRS URI:fromtrs_cliimportTRSClientclient=TRSClient(uri="trs://my-trs.app/SOME_TOOL",use_http=True,)# Client instantiated for URL: http://my-trs.app:443/ga4gh/trs/v1Access methodsNOTES:All endpoint access methods require aclient
instance.For accessing endpoints that require authorization, see thededicated section.Responses that do not return the tool ID as a single string returnPydanticmodels instead. If dictionaries are preferred
instead, they can be obtained withresponse.dict(). See thePydantic
export documentationfor further details.See theAPI documentationfor further details on each access
method.Endpoints as specified in the TRS APIAccess methods for eachTool Registry Service APIendpoint
are available:MethodEndpointDescription.get_tool_classes()GET ​/toolClassesList all tool types.get_tools()GET ​/toolsList all tools.get_tool()GET ​/tools​/{id}List one specific tool, acts as an anchor for self references.get_versions()GET ​/tools​/{id}​/versionsList versions of a tool.get_version()GET ​/tools​/{id}​/versions​/{version_id}List one specific tool version, acts as an anchor for self references.get_containerfiles()GET ​/tools​/{id}​/versions​/{version_id}​/containerfileGet the container specification(s) for the specified image..get_descriptor()GET ​/tools​/{id}​/versions​/{version_id}​/{type}​/descriptorGet the tool descriptor for the specified tool.get_descriptor_by_path()GET ​/tools​/{id}​/versions​/{version_id}​/{type}​/descriptor​/{relative_path}Get additional tool descriptor files relative to the main file.get_files()GET ​/tools​/{id}​/versions​/{version_id}​/{type}​/filesGet a list of objects that contain the relative path and file type.get_tests()GET ​/tools​/{id}​/versions​/{version_id}​/{type}​/testsGet a list of test JSONs.get_service_info()GET ​/service-infoShow information about this service. It is assumed that removing this endpoint from a URL will result in a valid URL to query againstTRS-Filer-specific endpointsIn addition to TRS API endpoints, theTRSClientclass also provides access
methods for additional endpoints implemented inTRS-Filer:MethodEndpointDescription.post_tool_class()POST ​/toolClassesCreate a tool class.put_tool_class()PUT ​/toolClasses​/{id}Create or update a tool class.delete_tool_class()DELETE ​/toolClasses​/{id}Delete a tool class.post_tool()POST ​/toolsAdd a tool.put_tool()PUT ​/tools​/{id}Add or update a tool.delete_tool()DELETE ​/tools​/{id}Delete a tool.post_version()POST ​/tools​/{id}​/versionsAdd a tool version.put_version()PUT ​/tools​/{id}​/versions​/{version_id}Add or update a tool version.delete_version()DELETE ​/tools​/{id}​/versions​/{version_id}Delete a tool version.post_service_info()POST ​/service-infoRegister service infoAuthorizationAuthorizationbearer tokenscan be provided either during
client instantiation or when calling an endpoint access method. The bearer
token is sent along as anAuthorizationheader with every request sent from
the instantiated client instance.NOTE:Whenever a token is specified when calling an API endpoint, thetokenvariable 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:fromtrs_cliimportTRSClient# No token passed during client instantiationclient=TRSClient(uri="https://my-trs.app")# Value of client.token: None# Token passed during client instantiationclient_2=TRSClient(uri="https://my-trs.app",token="MyT0k3n",)# Value of client_2.token: MyT0k3nAPI documentationAutomatically builtAPI documentationis available.InstallationYou can installTRS-cliin one of two ways:Via package managerpipinstalltrs_cli# Or for the latest development version:pipinstallgit+https://github.com/elixir-cloud-aai/TRS-cli.git#egg=trs_cliManual installationgitclonehttps://github.com/elixir-cloud-aai/TRS-cli.gitcdTRS-cli
pythonsetup.pyinstallContributingThis 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'scontributing
guidelinesif you are interested to contribute.
Please mind thecode of conductfor all interactions
with the community.VersioningThe project adopts thesemantic versioningscheme for versioning.
Currently the service is in beta stage, so the API may change without further
notice.LicenseThis project is covered by theApache License 2.0alsoshipped with this repository.ContactThe project is a collaborative effort under the umbrella ofELIXIR 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.