diff --git a/docs/docs.md b/docs/docs.md index b6ac373..1e04f71 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -6155,22 +6155,3 @@ List all webhook dispatches of a user. * **Return type** [`ListPage`](#listpage) - -*** - -### [](#listpage) ListPage - -A single page of items returned from a list() method. - -#### Instance attributes - -Name | Type | Description ----- | ---- | ----------- -`items` | `list` | List of returned objects on this page -`offset` | `int` | The limit on the number of returned objects offset specified in the API call -`limit` | `int` | The offset of the first object specified in the API call -`count` | `int` | Count of the returned objects on this page -`total` | `int` | Total number of objects matching the API call criteria -`desc` | `bool` | Whether the listing is descending or not - -*** diff --git a/docs/res/sphinx-config/index.rst b/docs/res/sphinx-config/index.rst index 402ff77..e03c6c7 100644 --- a/docs/res/sphinx-config/index.rst +++ b/docs/res/sphinx-config/index.rst @@ -7,5 +7,3 @@ :members: .. automodule:: apify_client.clients.resource_clients :members: -.. autoclass:: apify_client._utils.ListPage - :members: diff --git a/pyproject.toml b/pyproject.toml index daa660c..04f9612 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ requires-python = ">=3.8" dependencies = [ - "apify-shared ~= 1.0.0b2", + "apify-shared ~= 1.0.0b3", "httpx >= 0.24.1", ] diff --git a/src/apify_client/_utils.py b/src/apify_client/_utils.py index 1b0fb89..2d38457 100644 --- a/src/apify_client/_utils.py +++ b/src/apify_client/_utils.py @@ -4,9 +4,9 @@ import random import time from http import HTTPStatus -from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, Generic, List, Optional, Tuple, TypeVar, cast +from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, List, Optional, Tuple, TypeVar, cast -from apify_shared.utils import ignore_docs, is_file_or_bytes, maybe_extract_enum_member_value +from apify_shared.utils import is_file_or_bytes, maybe_extract_enum_member_value if TYPE_CHECKING: from ._errors import ApifyApiError @@ -146,30 +146,3 @@ def _encode_key_value_store_record_value(value: Any, content_type: Optional[str] value = json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False, default=str).encode('utf-8') return (value, content_type) - - -class ListPage(Generic[T]): - """A single page of items returned from a list() method.""" - - #: list: List of returned objects on this page - items: List[T] - #: int: Count of the returned objects on this page - count: int - #: int: The limit on the number of returned objects offset specified in the API call - offset: int - #: int: The offset of the first object specified in the API call - limit: int - #: int: Total number of objects matching the API call criteria - total: int - #: bool: Whether the listing is descending or not - desc: bool - - @ignore_docs - def __init__(self, data: Dict) -> None: - """Initialize a ListPage instance from the API response data.""" - self.items = data['items'] if 'items' in data else [] - self.offset = data['offset'] if 'offset' in data else 0 - self.limit = data['limit'] if 'limit' in data else 0 - self.count = data['count'] if 'count' in data else len(self.items) - self.total = data['total'] if 'total' in data else self.offset + self.count - self.desc = data['desc'] if 'desc' in data else False diff --git a/src/apify_client/clients/base/resource_collection_client.py b/src/apify_client/clients/base/resource_collection_client.py index 3d4427f..408bbf9 100644 --- a/src/apify_client/clients/base/resource_collection_client.py +++ b/src/apify_client/clients/base/resource_collection_client.py @@ -1,8 +1,9 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import ignore_docs, parse_date_fields -from ..._utils import ListPage, _pluck_data +from ..._utils import _pluck_data from .base_client import BaseClient, BaseClientAsync diff --git a/src/apify_client/clients/resource_clients/actor_collection.py b/src/apify_client/clients/resource_clients/actor_collection.py index 1447575..fe25980 100644 --- a/src/apify_client/clients/resource_clients/actor_collection.py +++ b/src/apify_client/clients/resource_clients/actor_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, List, Optional +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync from .actor import _get_actor_representation diff --git a/src/apify_client/clients/resource_clients/actor_env_var_collection.py b/src/apify_client/clients/resource_clients/actor_env_var_collection.py index 6edcfb0..ed41d08 100644 --- a/src/apify_client/clients/resource_clients/actor_env_var_collection.py +++ b/src/apify_client/clients/resource_clients/actor_env_var_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync from .actor_env_var import _get_actor_env_var_representation diff --git a/src/apify_client/clients/resource_clients/actor_version_collection.py b/src/apify_client/clients/resource_clients/actor_version_collection.py index f208e41..106d66b 100644 --- a/src/apify_client/clients/resource_clients/actor_version_collection.py +++ b/src/apify_client/clients/resource_clients/actor_version_collection.py @@ -1,9 +1,9 @@ from typing import Any, Dict, List, Optional from apify_shared.consts import ActorSourceType +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync from .actor_version import _get_actor_version_representation diff --git a/src/apify_client/clients/resource_clients/build_collection.py b/src/apify_client/clients/resource_clients/build_collection.py index b26faa6..26a9557 100644 --- a/src/apify_client/clients/resource_clients/build_collection.py +++ b/src/apify_client/clients/resource_clients/build_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync diff --git a/src/apify_client/clients/resource_clients/dataset.py b/src/apify_client/clients/resource_clients/dataset.py index c2be78e..e718ffb 100644 --- a/src/apify_client/clients/resource_clients/dataset.py +++ b/src/apify_client/clients/resource_clients/dataset.py @@ -4,10 +4,10 @@ import httpx +from apify_shared.models import ListPage from apify_shared.types import JSONSerializable from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceClient, ResourceClientAsync diff --git a/src/apify_client/clients/resource_clients/dataset_collection.py b/src/apify_client/clients/resource_clients/dataset_collection.py index 498930d..5bdba1d 100644 --- a/src/apify_client/clients/resource_clients/dataset_collection.py +++ b/src/apify_client/clients/resource_clients/dataset_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync diff --git a/src/apify_client/clients/resource_clients/key_value_store_collection.py b/src/apify_client/clients/resource_clients/key_value_store_collection.py index 997ff3e..adae7db 100644 --- a/src/apify_client/clients/resource_clients/key_value_store_collection.py +++ b/src/apify_client/clients/resource_clients/key_value_store_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync diff --git a/src/apify_client/clients/resource_clients/request_queue_collection.py b/src/apify_client/clients/resource_clients/request_queue_collection.py index 19d798d..ccc9943 100644 --- a/src/apify_client/clients/resource_clients/request_queue_collection.py +++ b/src/apify_client/clients/resource_clients/request_queue_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync diff --git a/src/apify_client/clients/resource_clients/run_collection.py b/src/apify_client/clients/resource_clients/run_collection.py index f6a63c1..d99af66 100644 --- a/src/apify_client/clients/resource_clients/run_collection.py +++ b/src/apify_client/clients/resource_clients/run_collection.py @@ -1,9 +1,9 @@ from typing import Any, Dict, Optional from apify_shared.consts import ActorJobStatus +from apify_shared.models import ListPage from apify_shared.utils import ignore_docs, maybe_extract_enum_member_value -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync diff --git a/src/apify_client/clients/resource_clients/schedule_collection.py b/src/apify_client/clients/resource_clients/schedule_collection.py index 371dc56..15931be 100644 --- a/src/apify_client/clients/resource_clients/schedule_collection.py +++ b/src/apify_client/clients/resource_clients/schedule_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, List, Optional +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync from .schedule import _get_schedule_representation diff --git a/src/apify_client/clients/resource_clients/task_collection.py b/src/apify_client/clients/resource_clients/task_collection.py index d0afaf2..8f0d21e 100644 --- a/src/apify_client/clients/resource_clients/task_collection.py +++ b/src/apify_client/clients/resource_clients/task_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync from .task import _get_task_representation diff --git a/src/apify_client/clients/resource_clients/webhook_collection.py b/src/apify_client/clients/resource_clients/webhook_collection.py index ec806a5..4ad0e93 100644 --- a/src/apify_client/clients/resource_clients/webhook_collection.py +++ b/src/apify_client/clients/resource_clients/webhook_collection.py @@ -1,9 +1,9 @@ from typing import Any, Dict, List, Optional from apify_shared.consts import WebhookEventType +from apify_shared.models import ListPage from apify_shared.utils import filter_out_none_values_recursively, ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync from .webhook import _get_webhook_representation diff --git a/src/apify_client/clients/resource_clients/webhook_dispatch_collection.py b/src/apify_client/clients/resource_clients/webhook_dispatch_collection.py index 27551c8..7b16b99 100644 --- a/src/apify_client/clients/resource_clients/webhook_dispatch_collection.py +++ b/src/apify_client/clients/resource_clients/webhook_dispatch_collection.py @@ -1,8 +1,8 @@ from typing import Any, Dict, Optional +from apify_shared.models import ListPage from apify_shared.utils import ignore_docs -from ..._utils import ListPage from ..base import ResourceCollectionClient, ResourceCollectionClientAsync