From 7723ba2ec19c81afafda8449f18e0a3fbe76f770 Mon Sep 17 00:00:00 2001 From: codex-storage-bot <154258435+codex-storage-bot@users.noreply.github.com> Date: Mon, 19 May 2025 10:41:24 +0000 Subject: [PATCH] Generated API update --- README.md | 11 +- codex.yaml | 21 ++ codex_api_client/api/data_api.py | 256 ++++++++++++++++++ .../models/sales_availability_read.py | 2 +- docs/DataApi.md | 66 +++++ docs/SalesAvailabilityREAD.md | 2 +- 6 files changed, 350 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f87e3f3..d100203 100644 --- a/README.md +++ b/README.md @@ -45,15 +45,13 @@ configuration = codex_api_client.Configuration( 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. + cid = 'cid_example' # str | Block or dataset to be deleted. 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) + # Deletes either a single block or an entire dataset from the local node. + api_instance.delete_local(cid) except ApiException as e: - print("Exception when calling DataApi->download_local: %s\n" % e) + print("Exception when calling DataApi->delete_local: %s\n" % e) ``` @@ -63,6 +61,7 @@ All URIs are relative to *http://localhost:8080/api/codex/v1* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*DataApi* | [**delete_local**](docs/DataApi.md#delete_local) | **DELETE** /data/{cid} | Deletes either a single block or an entire dataset from the local node. *DataApi* | [**download_local**](docs/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. *DataApi* | [**download_network**](docs/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. *DataApi* | [**download_network_manifest**](docs/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. diff --git a/codex.yaml b/codex.yaml index 0c3ca9f..a84842f 100644 --- a/codex.yaml +++ b/codex.yaml @@ -205,6 +205,7 @@ components: required: - id - totalRemainingCollateral + - freeSize allOf: - $ref: "#/components/schemas/SalesAvailability" - type: object @@ -627,6 +628,26 @@ paths: "500": description: Well it was bad-bad + delete: + summary: "Deletes either a single block or an entire dataset from the local node." + tags: [Data] + operationId: deleteLocal + parameters: + - in: path + name: cid + required: true + schema: + $ref: "#/components/schemas/Cid" + description: Block or dataset to be deleted. + + responses: + "204": + description: Data was successfully deleted. + "400": + description: Invalid CID is specified + "500": + description: There was an error during deletion + "/data/{cid}/network": post: summary: "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." diff --git a/codex_api_client/api/data_api.py b/codex_api_client/api/data_api.py index 7641560..1eec57f 100644 --- a/codex_api_client/api/data_api.py +++ b/codex_api_client/api/data_api.py @@ -41,6 +41,262 @@ class DataApi: self.api_client = api_client + @validate_call + def delete_local( + self, + cid: Annotated[StrictStr, Field(description="Block or dataset to be deleted.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Deletes either a single block or an entire dataset from the local node. + + + :param cid: Block or dataset to be deleted. (required) + :type cid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_local_serialize( + cid=cid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': None, + '500': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def delete_local_with_http_info( + self, + cid: Annotated[StrictStr, Field(description="Block or dataset to be deleted.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Deletes either a single block or an entire dataset from the local node. + + + :param cid: Block or dataset to be deleted. (required) + :type cid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_local_serialize( + cid=cid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': None, + '500': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def delete_local_without_preload_content( + self, + cid: Annotated[StrictStr, Field(description="Block or dataset to be deleted.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Deletes either a single block or an entire dataset from the local node. + + + :param cid: Block or dataset to be deleted. (required) + :type cid: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_local_serialize( + cid=cid, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': None, + '500': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _delete_local_serialize( + self, + cid, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if cid is not None: + _path_params['cid'] = cid + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/data/{cid}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def download_local( self, diff --git a/codex_api_client/models/sales_availability_read.py b/codex_api_client/models/sales_availability_read.py index 6a32119..b6673f7 100644 --- a/codex_api_client/models/sales_availability_read.py +++ b/codex_api_client/models/sales_availability_read.py @@ -34,7 +34,7 @@ class SalesAvailabilityREAD(BaseModel): enabled: Optional[StrictBool] = Field(default=True, description="Enable the ability to receive sales on this availability.") until: Optional[StrictInt] = Field(default=0, description="Specifies the latest timestamp, after which the availability will no longer host any slots. If set to 0, there will be no restrictions.") id: Annotated[str, Field(min_length=66, strict=True, max_length=66)] = Field(description="32bits identifier encoded in hex-decimal string.") - free_size: Optional[StrictInt] = Field(default=None, description="Unused size of availability's storage in bytes as decimal string", alias="freeSize") + free_size: StrictInt = Field(description="Unused size of availability's storage in bytes as decimal string", alias="freeSize") total_remaining_collateral: StrictStr = Field(description="Total collateral effective (in amount of tokens) that can be used for matching requests", alias="totalRemainingCollateral") __properties: ClassVar[List[str]] = ["totalSize", "duration", "minPricePerBytePerSecond", "totalCollateral", "enabled", "until", "id", "freeSize", "totalRemainingCollateral"] diff --git a/docs/DataApi.md b/docs/DataApi.md index c6ca770..93a9dbb 100644 --- a/docs/DataApi.md +++ b/docs/DataApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://localhost:8080/api/codex/v1* Method | HTTP request | Description ------------- | ------------- | ------------- +[**delete_local**](DataApi.md#delete_local) | **DELETE** /data/{cid} | Deletes either a single block or an entire dataset from the local node. [**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. [**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. @@ -13,6 +14,71 @@ Method | HTTP request | Description [**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. +# **delete_local** +> delete_local(cid) + +Deletes either a single block or an entire dataset from the local node. + +### 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 | Block or dataset to be deleted. + + try: + # Deletes either a single block or an entire dataset from the local node. + api_instance.delete_local(cid) + except Exception as e: + print("Exception when calling DataApi->delete_local: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **cid** | **str**| Block or dataset to be deleted. | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Data was successfully deleted. | - | +**400** | Invalid CID is specified | - | +**500** | There was an error during deletion | - | + +[[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_local** > bytearray download_local(cid) diff --git a/docs/SalesAvailabilityREAD.md b/docs/SalesAvailabilityREAD.md index 95d80e4..ddad166 100644 --- a/docs/SalesAvailabilityREAD.md +++ b/docs/SalesAvailabilityREAD.md @@ -12,7 +12,7 @@ Name | Type | Description | Notes **enabled** | **bool** | Enable the ability to receive sales on this availability. | [optional] [default to True] **until** | **int** | Specifies the latest timestamp, after which the availability will no longer host any slots. If set to 0, there will be no restrictions. | [optional] [default to 0] **id** | **str** | 32bits identifier encoded in hex-decimal string. | -**free_size** | **int** | Unused size of availability's storage in bytes as decimal string | [optional] [readonly] +**free_size** | **int** | Unused size of availability's storage in bytes as decimal string | [readonly] **total_remaining_collateral** | **str** | Total collateral effective (in amount of tokens) that can be used for matching requests | [readonly] ## Example