Package: drs-cli
DRS-cliClient for implementations of theGlobal Alliance for Genomics and
Health (GA4GH)Data Repository Service APIschema,
including support for additional endpoints defined inELIXIR Cloud &
AAI'sgenericDRS-FilerDRS
implementation.UsageTo use the client import it as follows in your Python code afterinstallation:Create client instanceVia DRS hostnameA client instance can be created by specifying the domain name of a DRS
instance, including the URL schema:fromdrs_cli.clientimportDRSClientclient=DRSClient(uri="https://my-drs.app")# Client instantiated for URL: https://my-drs.app:443/ga4gh/drs/v1Fullyspec-compliantDRS implementations will always be
available athttpsURLs, served at port443and at the base pathga4gh/drs/v1. However, to allow the client to be used against development
versions of DRS 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:fromdrs_cli.clientimportDRSClientclient=DRSClient(uri="http://my-drs.app",port=8080,base_path="my/api/route",)# Client instantiated for URL: http://my-drs.app:8080/my/api/routeVia DRS URIClients can also be created by passing ahostname-based DRS
URI:fromdrs_cli.clientimportDRSClientclient=DRSClient(uri="drs://my-drs.app/SOME_OBJECT")# Client instantiated for URL: https://my-drs.app:443/ga4gh/drs/v1NOTE:Only the hostname part of the DRS URI is evaluated, not the object
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 DRS URI is passed. The flag has no effect
when a DRS hostname URL is provided instead of a DRS URI:fromdrs_cli.clientimportDRSClientclient=DRSClient(uri="drs://my-drs.app/SOME_OBJECT",use_http=True,)# Client instantiated for URL: http://my-drs.app:443/ga4gh/drs/v1Access endpointsNOTES:All endpoint access methods require aclient
instance.For accessing endpoints that require authorization, see thededicated section.Responses that do not return the object ID as a single string returnPydanticmodels instead. If dictionaries are preferred
instead, they can be obtained withresponse.dict(). See thePydantic
export documentationfor further details.GETendpointsTheDRSGET /objects/{object_id}endpoint can be accessed
with, e.g.:response=client.get_object(object_id="A3SF4B",)Similarly, theDRSGET /objects/{object_id}/access/{access_id}endpoint can be accessed with, e.g.:response=client.get_access_url(object_id="A3SF4B",access_id="B44FG9",)POSTendpointTheDRS-FilerPOST /objectsendpoint can be
accessed with, e.g.:response=client.post_object(object_data={"created_time":"2019-05-20T00:12:34-07:00","updated_time":"2019-04-24T05:23:43-06:00","version":"1","size":5,"mime_type":"","checksums":[{"checksum":"18c2f5517e4ddc02cd57f6c7554b8e88","type":"md5"}],"access_methods":[{"type":"ftp","access_url":{"url":"ftp://my.ftp.server/my_path/my_file_01.txt","headers":["None"]}}]})DELETEendpointTheDRS-FilerDELETE /objects/{object_id}endpoint can be accessed with, e.g.:response=client.delete_object(object_id="A3SF4B",)AuthorizationAuthorizationbearer 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:fromdrs_cli.clientimportDRSClient# No token passed during client instantiationclient=DRSClient(uri="https://my-drs.app")# Value of client.token: None# Token passed during API callclient.get_object(object_id="SOME_OBJECT",token="N3wT0k3n",)# Value of client.token: N3wT0k3n# Token passed during client instantiationclient_2=DRSClient(uri="https://my-drs.app",token="MyT0k3n",)# Value of client_2.token: MyT0k3n# Token passed during API callclient_2.get_object(object_id="SOME_OBJECT",token="N3wT0k3n",)# Value of client_2.token: N3wT0k3nAPI docsAutomatically builtAPI documentationis available.InstallationYou can installDRS-cliin one of two ways:Installation via package managerpipinstalldrs_cli# Or for latest development version:pipinstallgit+https://github.com/elixir-cloud-aai/DRS-cli.git#egg=drs_cliManual installationgitclonehttps://github.com/elixir-cloud-aai/DRS-cli.gitcdDRS-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.