diff --git a/CHANGELOG.md b/CHANGELOG.md index e0e4829..ea26abe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- chore(databases): make pagination fields nullable + ### Removed - The legacy `POST /v1/files` upload endpoints have been removed in favor of the diff --git a/docs/DatabasesApi.md b/docs/DatabasesApi.md index b851ea8..a372d15 100644 --- a/docs/DatabasesApi.md +++ b/docs/DatabasesApi.md @@ -720,10 +720,12 @@ Name | Type | Description | Notes [[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_databases** -> ListDatabasesResponse list_databases() +> ListDatabasesResponse list_databases(limit=limit, cursor=cursor) List databases +List databases in the workspace, newest first, one page at a time. When no `limit` is given a default page size is applied, so a single call returns at most one page rather than every database. If the response's `has_more` is true, pass its `next_cursor` value back as the `cursor` query parameter to fetch the next page. + ### Example * Api Key Authentication (WorkspaceId): @@ -761,10 +763,12 @@ configuration = hotdata.Configuration( with hotdata.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = hotdata.DatabasesApi(api_client) + limit = 56 # int | Maximum number of databases to return in this page (1–100). Values outside the range are clamped. (optional) + cursor = 'cursor_example' # str | Opaque pagination cursor from a previous response's `next_cursor`. (optional) try: # List databases - api_response = api_instance.list_databases() + api_response = api_instance.list_databases(limit=limit, cursor=cursor) print("The response of DatabasesApi->list_databases:\n") pprint(api_response) except Exception as e: @@ -775,7 +779,11 @@ with hotdata.ApiClient(configuration) as api_client: ### Parameters -This endpoint does not need any parameter. + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **limit** | **int**| Maximum number of databases to return in this page (1–100). Values outside the range are clamped. | [optional] + **cursor** | **str**| Opaque pagination cursor from a previous response's `next_cursor`. | [optional] ### Return type @@ -794,7 +802,7 @@ This endpoint does not need any parameter. | Status code | Description | Response headers | |-------------|-------------|------------------| -**200** | List of databases | - | +**200** | One page of databases | - | [[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) diff --git a/docs/ListDatabasesResponse.md b/docs/ListDatabasesResponse.md index 0b348c2..891fd78 100644 --- a/docs/ListDatabasesResponse.md +++ b/docs/ListDatabasesResponse.md @@ -1,12 +1,16 @@ # ListDatabasesResponse -Response body for GET /databases +Response body for GET /databases. Results are returned one page at a time, newest first. When `has_more` is true, pass `next_cursor` back as the `cursor` query parameter to fetch the following page. ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**count** | **int** | Number of databases returned in this page. | [optional] **databases** | [**List[DatabaseSummary]**](DatabaseSummary.md) | | +**has_more** | **bool** | Whether more databases exist beyond this page. | [optional] +**limit** | **int** | Page size applied to this response (after clamping to the maximum). | [optional] +**next_cursor** | **str** | Opaque cursor for the next page; present only when `has_more` is true. | [optional] ## Example diff --git a/hotdata/api/databases_api.py b/hotdata/api/databases_api.py index 9d0900d..4a3e5e2 100644 --- a/hotdata/api/databases_api.py +++ b/hotdata/api/databases_api.py @@ -17,6 +17,7 @@ from typing_extensions import Annotated from pydantic import Field, StrictStr +from typing import Optional from typing_extensions import Annotated from hotdata.models.add_managed_schema_request import AddManagedSchemaRequest from hotdata.models.add_managed_table_request import AddManagedTableRequest @@ -2351,6 +2352,8 @@ def _get_database_serialize( @validate_call def list_databases( self, + limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Maximum number of databases to return in this page (1–100). Values outside the range are clamped.")] = None, + cursor: Annotated[Optional[StrictStr], Field(description="Opaque pagination cursor from a previous response's `next_cursor`.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2366,7 +2369,12 @@ def list_databases( ) -> ListDatabasesResponse: """List databases + List databases in the workspace, newest first, one page at a time. When no `limit` is given a default page size is applied, so a single call returns at most one page rather than every database. If the response's `has_more` is true, pass its `next_cursor` value back as the `cursor` query parameter to fetch the next page. + :param limit: Maximum number of databases to return in this page (1–100). Values outside the range are clamped. + :type limit: int + :param cursor: Opaque pagination cursor from a previous response's `next_cursor`. + :type cursor: 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 @@ -2390,6 +2398,8 @@ def list_databases( """ # noqa: E501 _param = self._list_databases_serialize( + limit=limit, + cursor=cursor, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2413,6 +2423,8 @@ def list_databases( @validate_call def list_databases_with_http_info( self, + limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Maximum number of databases to return in this page (1–100). Values outside the range are clamped.")] = None, + cursor: Annotated[Optional[StrictStr], Field(description="Opaque pagination cursor from a previous response's `next_cursor`.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2428,7 +2440,12 @@ def list_databases_with_http_info( ) -> ApiResponse[ListDatabasesResponse]: """List databases + List databases in the workspace, newest first, one page at a time. When no `limit` is given a default page size is applied, so a single call returns at most one page rather than every database. If the response's `has_more` is true, pass its `next_cursor` value back as the `cursor` query parameter to fetch the next page. + :param limit: Maximum number of databases to return in this page (1–100). Values outside the range are clamped. + :type limit: int + :param cursor: Opaque pagination cursor from a previous response's `next_cursor`. + :type cursor: 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 @@ -2452,6 +2469,8 @@ def list_databases_with_http_info( """ # noqa: E501 _param = self._list_databases_serialize( + limit=limit, + cursor=cursor, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2475,6 +2494,8 @@ def list_databases_with_http_info( @validate_call def list_databases_without_preload_content( self, + limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Maximum number of databases to return in this page (1–100). Values outside the range are clamped.")] = None, + cursor: Annotated[Optional[StrictStr], Field(description="Opaque pagination cursor from a previous response's `next_cursor`.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2490,7 +2511,12 @@ def list_databases_without_preload_content( ) -> RESTResponseType: """List databases + List databases in the workspace, newest first, one page at a time. When no `limit` is given a default page size is applied, so a single call returns at most one page rather than every database. If the response's `has_more` is true, pass its `next_cursor` value back as the `cursor` query parameter to fetch the next page. + :param limit: Maximum number of databases to return in this page (1–100). Values outside the range are clamped. + :type limit: int + :param cursor: Opaque pagination cursor from a previous response's `next_cursor`. + :type cursor: 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 @@ -2514,6 +2540,8 @@ def list_databases_without_preload_content( """ # noqa: E501 _param = self._list_databases_serialize( + limit=limit, + cursor=cursor, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2532,6 +2560,8 @@ def list_databases_without_preload_content( def _list_databases_serialize( self, + limit, + cursor, _request_auth, _content_type, _headers, @@ -2554,6 +2584,14 @@ def _list_databases_serialize( # process the path parameters # process the query parameters + if limit is not None: + + _query_params.append(('limit', limit)) + + if cursor is not None: + + _query_params.append(('cursor', cursor)) + # process the header parameters # process the form parameters # process the body parameter diff --git a/hotdata/models/list_databases_response.py b/hotdata/models/list_databases_response.py index 8b47142..89db497 100644 --- a/hotdata/models/list_databases_response.py +++ b/hotdata/models/list_databases_response.py @@ -18,18 +18,23 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated from hotdata.models.database_summary import DatabaseSummary from typing import Optional, Set from typing_extensions import Self class ListDatabasesResponse(BaseModel): """ - Response body for GET /databases + Response body for GET /databases. Results are returned one page at a time, newest first. When `has_more` is true, pass `next_cursor` back as the `cursor` query parameter to fetch the following page. """ # noqa: E501 + count: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="Number of databases returned in this page.") databases: List[DatabaseSummary] - __properties: ClassVar[List[str]] = ["databases"] + has_more: Optional[StrictBool] = Field(default=None, description="Whether more databases exist beyond this page.") + limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="Page size applied to this response (after clamping to the maximum).") + next_cursor: Optional[StrictStr] = Field(default=None, description="Opaque cursor for the next page; present only when `has_more` is true.") + __properties: ClassVar[List[str]] = ["count", "databases", "has_more", "limit", "next_cursor"] model_config = ConfigDict( populate_by_name=True, @@ -77,6 +82,26 @@ def to_dict(self) -> Dict[str, Any]: if _item_databases: _items.append(_item_databases.to_dict()) _dict['databases'] = _items + # set to None if count (nullable) is None + # and model_fields_set contains the field + if self.count is None and "count" in self.model_fields_set: + _dict['count'] = None + + # set to None if has_more (nullable) is None + # and model_fields_set contains the field + if self.has_more is None and "has_more" in self.model_fields_set: + _dict['has_more'] = None + + # set to None if limit (nullable) is None + # and model_fields_set contains the field + if self.limit is None and "limit" in self.model_fields_set: + _dict['limit'] = None + + # set to None if next_cursor (nullable) is None + # and model_fields_set contains the field + if self.next_cursor is None and "next_cursor" in self.model_fields_set: + _dict['next_cursor'] = None + return _dict @classmethod @@ -89,7 +114,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "databases": [DatabaseSummary.from_dict(_item) for _item in obj["databases"]] if obj.get("databases") is not None else None + "count": obj.get("count"), + "databases": [DatabaseSummary.from_dict(_item) for _item in obj["databases"]] if obj.get("databases") is not None else None, + "has_more": obj.get("has_more"), + "limit": obj.get("limit"), + "next_cursor": obj.get("next_cursor") }) return _obj diff --git a/test/test_list_databases_response.py b/test/test_list_databases_response.py index 2189d79..2d8a146 100644 --- a/test/test_list_databases_response.py +++ b/test/test_list_databases_response.py @@ -36,6 +36,7 @@ def make_instance(self, include_optional) -> ListDatabasesResponse: model = ListDatabasesResponse() if include_optional: return ListDatabasesResponse( + count = 0, databases = [ hotdata.models.database_summary.DatabaseSummary( created_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), @@ -44,7 +45,10 @@ def make_instance(self, include_optional) -> ListDatabasesResponse: expires_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), id = '', name = '', ) - ] + ], + has_more = True, + limit = 0, + next_cursor = '' ) else: return ListDatabasesResponse(