drs_cli package¶
Submodules¶
drs_cli.client module¶
Class implementing DRS client.
-
class
drs_cli.client.
DRSClient
(uri: str, port: Optional[int] = None, base_path: Optional[str] = 'ga4gh/drs/v1', use_http: bool = False, token: Optional[str] = None)¶ Bases:
object
Client to communicate with a GA4GH DRS instance. Supports additional endpoints defined in DRS-filer (https://github.com/elixir-cloud-aai/drs-filer).
Parameters: - uri – Either the base URI of the DRS instance to connect to in either ‘https’ or ‘http’ schema (note that fully compliant DRS instances will use ‘https’ exclusively), e.g., https://my-drs.app, OR a hostname-based DRS URI, cf. https://ga4gh.github.io/data-repository-service-schemas/preview/develop/docs/#_hostname_based_drs_uris.
- port – Override default port at which the DRS instance can be accessed. Only required for DRS instances that are not fully spec-compliant, as the default port is defined in the DRS documentation, cf. https://ga4gh.github.io/data-repository-service-schemas/preview/develop/docs/#_hostname_based_drs_uris.
- base-path – Override default path at which the DRS API is accessible at the given DRS instance. Only required for DRS instances that are not fully spec-compliant, as the default port is defined in the DRS documentation, cf. https://ga4gh.github.io/data-repository-service-schemas/preview/develop/docs/#_hostname_based_drs_uris.
- use_http – Set the URI schema of the DRS instance to http instead of https`when a DRS URI was provided to `uri.
- token – Bearer token to send along with DRS API requests. Set if required by DRS implementation. Alternatively, specify in API endpoint access methods.
-
uri
¶ URI to DRS endpoints, built from uri, port and base_path, e.g.,”https://my-drs.app:443/ga4gh/drs/v1”.
-
token
¶ Bearer token for gaining access to DRS endpoints.
-
headers
¶ Dictionary of request headers.
-
delete_object
(object_id: str, token: Optional[str] = None) → Union[str, drs_cli.models.Error]¶ Delete DRS object.
Parameters: - object_id – Implementation-specific DRS identifier OR hostname-based DRS URI pointing to a given object, cf. https://ga4gh.github.io/data-repository-service-schemas/preview/develop/docs/#_hostname_based_drs_uris.
- token – Bearer token for authentication. Set if required by DRS implementation and if not provided when instatiating client or if expired.
Returns: ID of previously registered DRS object in case of a 200 response, or an instance of Error for all other responses.
Raises: requests.exceptions.ConnectionError
– A connection to the provided DRS instance could not be established.drs_cli.errors.InvalidResponseError
– The response could not be validated against the API schema.
-
get_access_url
(object_id: str, access_id: str, token: Optional[str] = None) → Union[drs_cli.models.AccessURL, drs_cli.models.Error]¶ Retrieve access URL of DRS object.
Parameters: - object_id – Implementation-specific DRS identifier OR hostname-based DRS URI pointing to a given object, cf. https://ga4gh.github.io/data-repository-service-schemas/preview/develop/docs/#_hostname_based_drs_uris.
- access_id – Identifier of one of a DRS object’s access methods.
- token – Bearer token for authentication. Set if required by DRS implementation and if not provided when instatiating client or if expired.
Returns: Unmarshalled DRS response as either an instance of AccessURL in case of a 200 response, or an instance of Error for all other reponses.
Raises: requests.exceptions.ConnectionError
– A connection to the provided DRS instance could not be established.drs_cli.errors.InvalidResponseError
– The response could not be validated against the API schema.
-
get_object
(object_id: str, token: Optional[str] = None) → Union[drs_cli.models.Error, drs_cli.models.DrsObject]¶ Retrieve DRS object.
Parameters: - object_id – Implementation-specific DRS identifier OR hostname-based DRS URI pointing to a given object, cf. https://ga4gh.github.io/data-repository-service-schemas/preview/develop/docs/#_hostname_based_drs_uris.
- token – Bearer token for authentication. Set if required by DRS implementation and if not provided when instatiating client or if expired.
Returns: Unmarshalled DRS response as either an instance of DRSObject in case of a 200 response, or an instance of Error for all other JSON reponses.
Raises: requests.exceptions.ConnectionError
– A connection to the provided DRS instance could not be established.drs_cli.errors.InvalidResponseError
– The response could not be validated against the API schema.
-
post_object
(object_data: Dict[KT, VT], token: Optional[str] = None) → Union[str, drs_cli.models.Error]¶ Register DRS object.
Parameters: - object_data – DRS object data.
- token – Bearer token for authentication. Set if required by DRS implementation and if not provided when instatiating client or if expired.
Returns: ID of registered DRS object in case of a 200 response, or an instance of Error for all other responses.
Raises: requests.exceptions.ConnectionError
– A connection to the provided DRS instance could not be established.drs_cli.errors.InvalidObjectData
– The object data payload could not be validated against the API schema.drs_cli.errors.InvalidResponseError
– The response could not be validated against the API schema.
drs_cli.errors module¶
-
exception
drs_cli.errors.
InvalidObjectData
¶ Bases:
Exception
Exception raised when object data cannot be validated against the API schema.
-
exception
drs_cli.errors.
InvalidResponseError
¶ Bases:
Exception
Exception raised when an invalid API response is encountered.
-
exception
drs_cli.errors.
InvalidURI
¶ Bases:
Exception
Exception raised for invalid URIs.
-
drs_cli.errors.
exception_handler
(_type: type, value: BaseException, traceback: traceback) → None¶ Error handler for all exceptions.
drs_cli.models module¶
API models; autogenerated by https://github.com/koxudaxi/datamodel-code-generator/.
-
class
drs_cli.models.
AccessMethod
¶ Bases:
pydantic.main.BaseModel
-
class
drs_cli.models.
AccessPostMethod
¶ Bases:
pydantic.main.BaseModel
-
class
drs_cli.models.
AccessURL
¶ Bases:
pydantic.main.BaseModel
-
class
drs_cli.models.
Checksum
¶ Bases:
pydantic.main.BaseModel
-
class
drs_cli.models.
DrsObject
¶ Bases:
pydantic.main.BaseModel
-
class
drs_cli.models.
Error
¶ Bases:
pydantic.main.BaseModel
-
class
drs_cli.models.
PostDrsObject
¶ Bases:
pydantic.main.BaseModel