EOSC Client¶
EOSCClient
¶
A client for interacting with the EOSC Data Transfer API. Handles authentication, request sending, and error parsing.
Source code in eosc_data_transfer_client/client.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
__init__(base_url, token=None)
¶
Initializes the EOSCClient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
str
|
The base URL of the EOSC API. |
required |
token
|
str
|
Bearer token for authorization. |
None
|
Source code in eosc_data_transfer_client/client.py
24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
request(method, endpoint, **kwargs)
¶
Send a request to the API and handle errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
str
|
HTTP method (e.g., 'GET', 'POST'). |
required |
endpoint
|
str
|
API endpoint path. |
required |
**kwargs
|
Any
|
Additional request options. |
{}
|
Returns:
Type | Description |
---|---|
Union[dict, str]
|
Union[dict, str]: Parsed response from the API. |
Raises:
Type | Description |
---|---|
EOSCClientError
|
For 4xx errors. |
EOSCServerError
|
For 5xx errors. |
EOSCRequestError
|
For network issues. |
Source code in eosc_data_transfer_client/client.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|