Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- feat(databases): add pagination support to list endpoint

### Removed

- The legacy `POST /v1/files` upload endpoints have been removed in favor of the
Expand Down
16 changes: 12 additions & 4 deletions docs/DatabasesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion docs/ListDatabasesResponse.md
Original file line number Diff line number Diff line change
@@ -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. |
**databases** | [**List[DatabaseSummary]**](DatabaseSummary.md) | |
**has_more** | **bool** | Whether more databases exist beyond this page. |
**limit** | **int** | Page size applied to this response (after clamping to the maximum). |
**next_cursor** | **str** | Opaque cursor for the next page; present only when `has_more` is true. | [optional]

## Example

Expand Down
38 changes: 38 additions & 0 deletions hotdata/api/databases_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)],
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)],
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)],
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -2532,6 +2560,8 @@ def list_databases_without_preload_content(

def _list_databases_serialize(
self,
limit,
cursor,
_request_auth,
_content_type,
_headers,
Expand All @@ -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
Expand Down
24 changes: 19 additions & 5 deletions hotdata/models/list_databases_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: Annotated[int, Field(strict=True, ge=0)] = Field(description="Number of databases returned in this page.")
databases: List[DatabaseSummary]
__properties: ClassVar[List[str]] = ["databases"]
has_more: StrictBool = Field(description="Whether more databases exist beyond this page.")
limit: Annotated[int, Field(strict=True, ge=0)] = Field(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,
Expand Down Expand Up @@ -77,6 +82,11 @@ def to_dict(self) -> Dict[str, Any]:
if _item_databases:
_items.append(_item_databases.to_dict())
_dict['databases'] = _items
# 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
Expand All @@ -89,7 +99,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

Expand Down
9 changes: 8 additions & 1 deletion test/test_list_databases_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -44,10 +45,14 @@ 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(
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'),
Expand All @@ -57,6 +62,8 @@ def make_instance(self, include_optional) -> ListDatabasesResponse:
id = '',
name = '', )
],
has_more = True,
limit = 0,
)
"""

Expand Down
Loading