490 lines
16 KiB
Markdown
Raw Normal View History

2024-12-18 14:22:21 +01:00
# codex_api_client.DataApi
2024-08-23 16:22:29 +02:00
All URIs are relative to *http://localhost:8080/api/codex/v1*
Method | HTTP request | Description
------------- | ------------- | -------------
[**download_local**](DataApi.md#download_local) | **GET** /data/{cid} | Download a file from the local node in a streaming manner. If the file is not available locally, a 404 is returned.
2024-12-18 14:22:21 +01:00
[**download_network**](DataApi.md#download_network) | **POST** /data/{cid}/network | Download a file from the network to the local node if it's not available locally. Note: Download is performed async. Call can return before download is completed.
[**download_network_manifest**](DataApi.md#download_network_manifest) | **GET** /data/{cid}/network/manifest | Download only the dataset manifest from the network to the local node if it's not available locally.
[**download_network_stream**](DataApi.md#download_network_stream) | **GET** /data/{cid}/network/stream | Download a file from the network in a streaming manner. If the file is not available locally, it will be retrieved from other nodes in the network if able.
2024-08-23 16:22:29 +02:00
[**list_data**](DataApi.md#list_data) | **GET** /data | Lists manifest CIDs stored locally in node.
[**space**](DataApi.md#space) | **GET** /space | Gets a summary of the storage space allocation of the node.
[**upload**](DataApi.md#upload) | **POST** /data | Upload a file in a streaming manner. Once finished, the file is stored in the node and can be retrieved by any node in the network using the returned CID.
# **download_local**
> bytearray download_local(cid)
Download a file from the local node in a streaming manner. If the file is not available locally, a 404 is returned.
### Example
```python
2024-12-18 14:22:21 +01:00
import codex_api_client
from codex_api_client.rest import ApiException
2024-08-23 16:22:29 +02:00
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
2024-12-18 14:22:21 +01:00
configuration = codex_api_client.Configuration(
2024-08-23 16:22:29 +02:00
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
2024-12-18 14:22:21 +01:00
with codex_api_client.ApiClient(configuration) as api_client:
2024-08-23 16:22:29 +02:00
# Create an instance of the API class
2024-12-18 14:22:21 +01:00
api_instance = codex_api_client.DataApi(api_client)
2024-08-23 16:22:29 +02:00
cid = 'cid_example' # str | File to be downloaded.
try:
# Download a file from the local node in a streaming manner. If the file is not available locally, a 404 is returned.
api_response = api_instance.download_local(cid)
print("The response of DataApi->download_local:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->download_local: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**cid** | **str**| File to be downloaded. |
### Return type
**bytearray**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Retrieved content specified by CID | - |
**400** | Invalid CID is specified | - |
**404** | Content specified by the CID is unavailable locally | - |
**500** | Well it was bad-bad | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **download_network**
2024-12-18 14:22:21 +01:00
> DataItem download_network(cid)
2024-08-23 16:22:29 +02:00
2024-12-18 14:22:21 +01:00
Download a file from the network to the local node if it's not available locally. Note: Download is performed async. Call can return before download is completed.
2024-08-23 16:22:29 +02:00
### Example
```python
2024-12-18 14:22:21 +01:00
import codex_api_client
from codex_api_client.models.data_item import DataItem
from codex_api_client.rest import ApiException
2024-08-23 16:22:29 +02:00
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
2024-12-18 14:22:21 +01:00
configuration = codex_api_client.Configuration(
2024-08-23 16:22:29 +02:00
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
2024-12-18 14:22:21 +01:00
with codex_api_client.ApiClient(configuration) as api_client:
2024-08-23 16:22:29 +02:00
# Create an instance of the API class
2024-12-18 14:22:21 +01:00
api_instance = codex_api_client.DataApi(api_client)
2024-08-23 16:22:29 +02:00
cid = 'cid_example' # str | File to be downloaded.
try:
2024-12-18 14:22:21 +01:00
# Download a file from the network to the local node if it's not available locally. Note: Download is performed async. Call can return before download is completed.
2024-08-23 16:22:29 +02:00
api_response = api_instance.download_network(cid)
print("The response of DataApi->download_network:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->download_network: %s\n" % e)
```
2024-12-18 14:22:21 +01:00
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**cid** | **str**| File to be downloaded. |
### Return type
[**DataItem**](DataItem.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Manifest information for download that has been started. | - |
**400** | Invalid CID is specified | - |
**404** | Failed to download dataset manifest | - |
**500** | Well it was bad-bad | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **download_network_manifest**
> DataItem download_network_manifest(cid)
Download only the dataset manifest from the network to the local node if it's not available locally.
### Example
```python
import codex_api_client
from codex_api_client.models.data_item import DataItem
from codex_api_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = codex_api_client.Configuration(
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
with codex_api_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = codex_api_client.DataApi(api_client)
cid = 'cid_example' # str | File for which the manifest is to be downloaded.
try:
# Download only the dataset manifest from the network to the local node if it's not available locally.
api_response = api_instance.download_network_manifest(cid)
print("The response of DataApi->download_network_manifest:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->download_network_manifest: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**cid** | **str**| File for which the manifest is to be downloaded. |
### Return type
[**DataItem**](DataItem.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Manifest information. | - |
**400** | Invalid CID is specified | - |
**404** | Failed to download dataset manifest | - |
**500** | Well it was bad-bad | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **download_network_stream**
> bytearray download_network_stream(cid)
Download a file from the network in a streaming manner. If the file is not available locally, it will be retrieved from other nodes in the network if able.
### Example
```python
import codex_api_client
from codex_api_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = codex_api_client.Configuration(
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
with codex_api_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = codex_api_client.DataApi(api_client)
cid = 'cid_example' # str | File to be downloaded.
try:
# Download a file from the network in a streaming manner. If the file is not available locally, it will be retrieved from other nodes in the network if able.
api_response = api_instance.download_network_stream(cid)
print("The response of DataApi->download_network_stream:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->download_network_stream: %s\n" % e)
```
2024-08-23 16:22:29 +02:00
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**cid** | **str**| File to be downloaded. |
### Return type
**bytearray**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Retrieved content specified by CID | - |
**400** | Invalid CID is specified | - |
**404** | Content specified by the CID is not found | - |
**500** | Well it was bad-bad | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **list_data**
> DataList list_data()
Lists manifest CIDs stored locally in node.
### Example
```python
2024-12-18 14:22:21 +01:00
import codex_api_client
from codex_api_client.models.data_list import DataList
from codex_api_client.rest import ApiException
2024-08-23 16:22:29 +02:00
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
2024-12-18 14:22:21 +01:00
configuration = codex_api_client.Configuration(
2024-08-23 16:22:29 +02:00
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
2024-12-18 14:22:21 +01:00
with codex_api_client.ApiClient(configuration) as api_client:
2024-08-23 16:22:29 +02:00
# Create an instance of the API class
2024-12-18 14:22:21 +01:00
api_instance = codex_api_client.DataApi(api_client)
2024-08-23 16:22:29 +02:00
try:
# Lists manifest CIDs stored locally in node.
api_response = api_instance.list_data()
print("The response of DataApi->list_data:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->list_data: %s\n" % e)
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**DataList**](DataList.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Retrieved list of content CIDs | - |
**400** | Invalid CID is specified | - |
**404** | Content specified by the CID is not found | - |
2024-12-18 14:22:21 +01:00
**422** | The content type is not a valid content type or the filename is not valid | - |
2024-08-23 16:22:29 +02:00
**500** | Well it was bad-bad | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **space**
> Space space()
Gets a summary of the storage space allocation of the node.
### Example
```python
2024-12-18 14:22:21 +01:00
import codex_api_client
from codex_api_client.models.space import Space
from codex_api_client.rest import ApiException
2024-08-23 16:22:29 +02:00
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
2024-12-18 14:22:21 +01:00
configuration = codex_api_client.Configuration(
2024-08-23 16:22:29 +02:00
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
2024-12-18 14:22:21 +01:00
with codex_api_client.ApiClient(configuration) as api_client:
2024-08-23 16:22:29 +02:00
# Create an instance of the API class
2024-12-18 14:22:21 +01:00
api_instance = codex_api_client.DataApi(api_client)
2024-08-23 16:22:29 +02:00
try:
# Gets a summary of the storage space allocation of the node.
api_response = api_instance.space()
print("The response of DataApi->space:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->space: %s\n" % e)
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**Space**](Space.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Summary of storage allocation | - |
**500** | It's not working as planned | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload**
2024-12-18 14:22:21 +01:00
> str upload(content_type=content_type, content_disposition=content_disposition, body=body)
2024-08-23 16:22:29 +02:00
Upload a file in a streaming manner. Once finished, the file is stored in the node and can be retrieved by any node in the network using the returned CID.
### Example
```python
2024-12-18 14:22:21 +01:00
import codex_api_client
from codex_api_client.rest import ApiException
2024-08-23 16:22:29 +02:00
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/api/codex/v1
# See configuration.py for a list of all supported configuration parameters.
2024-12-18 14:22:21 +01:00
configuration = codex_api_client.Configuration(
2024-08-23 16:22:29 +02:00
host = "http://localhost:8080/api/codex/v1"
)
# Enter a context with an instance of the API client
2024-12-18 14:22:21 +01:00
with codex_api_client.ApiClient(configuration) as api_client:
2024-08-23 16:22:29 +02:00
# Create an instance of the API class
2024-12-18 14:22:21 +01:00
api_instance = codex_api_client.DataApi(api_client)
content_type = 'image/png' # str | The content type of the file. Must be valid. (optional)
content_disposition = 'attachment; filename=\"codex.png\"' # str | The content disposition used to send the filename. (optional)
2024-08-23 16:22:29 +02:00
body = None # bytearray | (optional)
try:
# Upload a file in a streaming manner. Once finished, the file is stored in the node and can be retrieved by any node in the network using the returned CID.
2024-12-18 14:22:21 +01:00
api_response = api_instance.upload(content_type=content_type, content_disposition=content_disposition, body=body)
2024-08-23 16:22:29 +02:00
print("The response of DataApi->upload:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DataApi->upload: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
2024-12-18 14:22:21 +01:00
**content_type** | **str**| The content type of the file. Must be valid. | [optional]
**content_disposition** | **str**| The content disposition used to send the filename. | [optional]
2024-08-23 16:22:29 +02:00
**body** | **bytearray**| | [optional]
### Return type
**str**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/octet-stream
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | CID of uploaded file | - |
**422** | The mimetype of the filename is invalid | - |
2024-08-23 16:22:29 +02:00
**500** | Well it was bad-bad and the upload did not work out | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)