From d41a6859244c0af6a005a840b39939a4ff494bf3 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Tue, 10 Dec 2024 16:03:50 +0100 Subject: [PATCH 1/2] docs: update docstrings and align to 120 line width --- CONTRIBUTING.md | 2 +- pyproject.toml | 2 +- scripts/check_async_docstrings.py | 4 +- scripts/fix_async_docstrings.py | 3 +- src/apify_client/_errors.py | 23 +- src/apify_client/_http_client.py | 8 +- src/apify_client/client.py | 94 +-- .../clients/base/actor_job_base_client.py | 16 +- src/apify_client/clients/base/base_client.py | 28 +- .../clients/resource_clients/actor.py | 337 ++++++----- .../resource_clients/actor_collection.py | 128 ++-- .../clients/resource_clients/actor_env_var.py | 22 +- .../actor_env_var_collection.py | 22 +- .../clients/resource_clients/actor_version.py | 79 +-- .../actor_version_collection.py | 70 ++- .../clients/resource_clients/build.py | 26 +- .../resource_clients/build_collection.py | 28 +- .../clients/resource_clients/dataset.py | 566 +++++++++--------- .../resource_clients/dataset_collection.py | 34 +- .../resource_clients/key_value_store.py | 84 +-- .../key_value_store_collection.py | 34 +- .../clients/resource_clients/log.py | 14 +- .../clients/resource_clients/request_queue.py | 116 ++-- .../request_queue_collection.py | 30 +- .../clients/resource_clients/run.py | 140 ++--- .../resource_clients/run_collection.py | 34 +- .../clients/resource_clients/schedule.py | 52 +- .../resource_clients/schedule_collection.py | 60 +- .../resource_clients/store_collection.py | 36 +- .../clients/resource_clients/task.py | 233 +++---- .../resource_clients/task_collection.py | 92 +-- .../clients/resource_clients/user.py | 10 +- .../clients/resource_clients/webhook.py | 69 ++- .../resource_clients/webhook_collection.py | 76 ++- .../resource_clients/webhook_dispatch.py | 6 +- .../webhook_dispatch_collection.py | 18 +- tests/integration/test_request_queue.py | 16 +- tests/unit/test_utils.py | 8 +- 38 files changed, 1346 insertions(+), 1274 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44e9daa4..ed2a062a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ Install the necessary dependencies: yarn ``` -Start the project in development mode with Hot Module Replacement (HMR): +Start the project in development mode with Hot Module Replacement ```sh yarn start diff --git a/pyproject.toml b/pyproject.toml index 5df5626e..a684bdbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ ruff = "~0.8.0" setuptools = "~75.6.0" # setuptools are used by pytest but not explicitly required [tool.ruff] -line-length = 150 +line-length = 120 [tool.ruff.lint] select = ["ALL"] diff --git a/scripts/check_async_docstrings.py b/scripts/check_async_docstrings.py index 1be2c90e..857d49bb 100755 --- a/scripts/check_async_docstrings.py +++ b/scripts/check_async_docstrings.py @@ -47,7 +47,9 @@ print(f'Missing docstring for "{async_class.name}.{async_method.name}"!') found_issues = True elif expected_docstring != async_docstring: - print(f'Docstring for "{async_class.name}.{async_method.name}" is out of sync with "{sync_class.name}.{sync_method.name}"!') + print( + f'Docstring for "{async_class.name}.{async_method.name}" is out of sync with "{sync_class.name}.{sync_method.name}"!' # noqa: E501 + ) found_issues = True if found_issues: diff --git a/scripts/fix_async_docstrings.py b/scripts/fix_async_docstrings.py index c3f7fc18..e332dd0f 100755 --- a/scripts/fix_async_docstrings.py +++ b/scripts/fix_async_docstrings.py @@ -41,7 +41,8 @@ if async_docstring == correct_async_docstring: continue - # Work around a bug in Red Baron, which indents docstrings too much when you insert them, so we have to un-indent it one level first + # Work around a bug in Red Baron, which indents docstrings too much when you insert them, + # so we have to un-indent it one level first. correct_async_docstring = re.sub('^ ', '', correct_async_docstring, flags=re.MULTILINE) if not isinstance(async_docstring, str): diff --git a/src/apify_client/_errors.py b/src/apify_client/_errors.py index e6d1fce5..8647e871 100644 --- a/src/apify_client/_errors.py +++ b/src/apify_client/_errors.py @@ -11,19 +11,18 @@ class ApifyClientError(Exception): class ApifyApiError(ApifyClientError): """Error specific to requests to the Apify API. - An `ApifyApiError` is thrown for successful HTTP requests that reach the API, - but the API responds with an error response. Typically, those are rate limit - errors and internal errors, which are automatically retried, or validation - errors, which are thrown immediately, because a correction by the user is needed. + An `ApifyApiError` is thrown for successful HTTP requests that reach the API, but the API responds with + an error response. Typically, those are rate limit errors and internal errors, which are automatically retried, + or validation errors, which are thrown immediately, because a correction by the user is needed. """ @ignore_docs def __init__(self, response: httpx.Response, attempt: int) -> None: - """Create the ApifyApiError instance. + """A default constructor. Args: - response (httpx.Response): The response to the failed API call - attempt (int): Which attempt was the request that failed + response: The response to the failed API call. + attempt: Which attempt was the request that failed. """ self.message: str | None = None self.type: str | None = None @@ -53,17 +52,17 @@ def __init__(self, response: httpx.Response, attempt: int) -> None: class InvalidResponseBodyError(ApifyClientError): """Error caused by the response body failing to be parsed. - This error exists for the quite common situation, where only a partial JSON response is received and - an attempt to parse the JSON throws an error. In most cases this can be resolved by retrying the - request. We do that by identifying this error in the HTTPClient. + This error exists for the quite common situation, where only a partial JSON response is received and an attempt + to parse the JSON throws an error. In most cases this can be resolved by retrying the request. We do that by + identifying this error in the HTTPClient. """ @ignore_docs def __init__(self, response: httpx.Response) -> None: - """Create the InvalidResponseBodyError instance. + """A default constructor. Args: - response: The response which failed to be parsed + response: The response which failed to be parsed. """ super().__init__('Response body could not be parsed') diff --git a/src/apify_client/_http_client.py b/src/apify_client/_http_client.py index 78896580..ca4e39c1 100644 --- a/src/apify_client/_http_client.py +++ b/src/apify_client/_http_client.py @@ -170,7 +170,9 @@ def _make_request(stop_retrying: Callable, attempt: int) -> httpx.Response: if response.status_code < 300: # noqa: PLR2004 logger.debug('Request successful', extra={'status_code': response.status_code}) if not stream: - _maybe_parsed_body = self._maybe_parse_response(response) if parse_response else response.content + _maybe_parsed_body = ( + self._maybe_parse_response(response) if parse_response else response.content + ) setattr(response, '_maybe_parsed_body', _maybe_parsed_body) # noqa: B010 return response @@ -242,7 +244,9 @@ async def _make_request(stop_retrying: Callable, attempt: int) -> httpx.Response if response.status_code < 300: # noqa: PLR2004 logger.debug('Request successful', extra={'status_code': response.status_code}) if not stream: - _maybe_parsed_body = self._maybe_parse_response(response) if parse_response else response.content + _maybe_parsed_body = ( + self._maybe_parse_response(response) if parse_response else response.content + ) setattr(response, '_maybe_parsed_body', _maybe_parsed_body) # noqa: B010 return response diff --git a/src/apify_client/client.py b/src/apify_client/client.py index a734dadf..09a04a0d 100644 --- a/src/apify_client/client.py +++ b/src/apify_client/client.py @@ -69,15 +69,15 @@ def __init__( min_delay_between_retries_millis: int | None = 500, timeout_secs: int | None = 360, ) -> None: - """Initialize the Apify API Client. + """A default constructor. Args: - token (str, optional): The Apify API token - api_url (str, optional): The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com - max_retries (int, optional): How many times to retry a failed request at most - min_delay_between_retries_millis (int, optional): How long will the client wait between retrying requests - (increases exponentially from this value) - timeout_secs (int, optional): The socket timeout of the HTTP requests sent to the Apify API + token: The Apify API token. + api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com. + max_retries: How many times to retry a failed request at most. + min_delay_between_retries_millis: How long will the client wait between retrying requests + (increases exponentially from this value). + timeout_secs: The socket timeout of the HTTP requests sent to the Apify API. """ self.token = token api_url = (api_url or DEFAULT_API_URL).rstrip('/') @@ -108,15 +108,15 @@ def __init__( min_delay_between_retries_millis: int | None = 500, timeout_secs: int | None = 360, ) -> None: - """Initialize the ApifyClient. + """A default constructor. Args: - token (str, optional): The Apify API token - api_url (str, optional): The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com - max_retries (int, optional): How many times to retry a failed request at most - min_delay_between_retries_millis (int, optional): How long will the client wait between retrying requests - (increases exponentially from this value) - timeout_secs (int, optional): The socket timeout of the HTTP requests sent to the Apify API + token: The Apify API token. + api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com. + max_retries: How many times to retry a failed request at most. + min_delay_between_retries_millis: How long will the client wait between retrying requests + (increases exponentially from this value). + timeout_secs: The socket timeout of the HTTP requests sent to the Apify API. """ super().__init__( token, @@ -137,7 +137,7 @@ def actor(self, actor_id: str) -> ActorClient: """Retrieve the sub-client for manipulating a single Actor. Args: - actor_id (str): ID of the Actor to be manipulated + actor_id: ID of the Actor to be manipulated. """ return ActorClient(resource_id=actor_id, **self._options()) @@ -149,7 +149,7 @@ def build(self, build_id: str) -> BuildClient: """Retrieve the sub-client for manipulating a single Actor build. Args: - build_id (str): ID of the Actor build to be manipulated + build_id: ID of the Actor build to be manipulated. """ return BuildClient(resource_id=build_id, **self._options()) @@ -161,7 +161,7 @@ def run(self, run_id: str) -> RunClient: """Retrieve the sub-client for manipulating a single Actor run. Args: - run_id (str): ID of the Actor run to be manipulated + run_id: ID of the Actor run to be manipulated. """ return RunClient(resource_id=run_id, **self._options()) @@ -173,7 +173,7 @@ def dataset(self, dataset_id: str) -> DatasetClient: """Retrieve the sub-client for manipulating a single dataset. Args: - dataset_id (str): ID of the dataset to be manipulated + dataset_id: ID of the dataset to be manipulated. """ return DatasetClient(resource_id=dataset_id, **self._options()) @@ -185,7 +185,7 @@ def key_value_store(self, key_value_store_id: str) -> KeyValueStoreClient: """Retrieve the sub-client for manipulating a single key-value store. Args: - key_value_store_id (str): ID of the key-value store to be manipulated + key_value_store_id: ID of the key-value store to be manipulated. """ return KeyValueStoreClient(resource_id=key_value_store_id, **self._options()) @@ -197,8 +197,8 @@ def request_queue(self, request_queue_id: str, *, client_key: str | None = None) """Retrieve the sub-client for manipulating a single request queue. Args: - request_queue_id (str): ID of the request queue to be manipulated - client_key (str): A unique identifier of the client accessing the request queue + request_queue_id: ID of the request queue to be manipulated. + client_key: A unique identifier of the client accessing the request queue. """ return RequestQueueClient(resource_id=request_queue_id, client_key=client_key, **self._options()) @@ -210,7 +210,7 @@ def webhook(self, webhook_id: str) -> WebhookClient: """Retrieve the sub-client for manipulating a single webhook. Args: - webhook_id (str): ID of the webhook to be manipulated + webhook_id: ID of the webhook to be manipulated. """ return WebhookClient(resource_id=webhook_id, **self._options()) @@ -222,7 +222,7 @@ def webhook_dispatch(self, webhook_dispatch_id: str) -> WebhookDispatchClient: """Retrieve the sub-client for accessing a single webhook dispatch. Args: - webhook_dispatch_id (str): ID of the webhook dispatch to access + webhook_dispatch_id: ID of the webhook dispatch to access. """ return WebhookDispatchClient(resource_id=webhook_dispatch_id, **self._options()) @@ -234,7 +234,7 @@ def schedule(self, schedule_id: str) -> ScheduleClient: """Retrieve the sub-client for manipulating a single schedule. Args: - schedule_id (str): ID of the schedule to be manipulated + schedule_id: ID of the schedule to be manipulated. """ return ScheduleClient(resource_id=schedule_id, **self._options()) @@ -246,7 +246,7 @@ def log(self, build_or_run_id: str) -> LogClient: """Retrieve the sub-client for retrieving logs. Args: - build_or_run_id (str): ID of the Actor build or run for which to access the log + build_or_run_id: ID of the Actor build or run for which to access the log. """ return LogClient(resource_id=build_or_run_id, **self._options()) @@ -254,7 +254,7 @@ def task(self, task_id: str) -> TaskClient: """Retrieve the sub-client for manipulating a single task. Args: - task_id (str): ID of the task to be manipulated + task_id: ID of the task to be manipulated. """ return TaskClient(resource_id=task_id, **self._options()) @@ -266,7 +266,7 @@ def user(self, user_id: str | None = None) -> UserClient: """Retrieve the sub-client for querying users. Args: - user_id (str, optional): ID of user to be queried. If None, queries the user belonging to the token supplied to the client + user_id: ID of user to be queried. If None, queries the user belonging to the token supplied to the client. """ return UserClient(resource_id=user_id, **self._options()) @@ -289,15 +289,15 @@ def __init__( min_delay_between_retries_millis: int | None = 500, timeout_secs: int | None = 360, ) -> None: - """Initialize the ApifyClientAsync. + """A default constructor. Args: - token (str, optional): The Apify API token - api_url (str, optional): The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com - max_retries (int, optional): How many times to retry a failed request at most - min_delay_between_retries_millis (int, optional): How long will the client wait between retrying requests - (increases exponentially from this value) - timeout_secs (int, optional): The socket timeout of the HTTP requests sent to the Apify API + token: The Apify API token. + api_url: The URL of the Apify API server to which to connect to. Defaults to https://api.apify.com. + max_retries: How many times to retry a failed request at most. + min_delay_between_retries_millis: How long will the client wait between retrying requests + (increases exponentially from this value). + timeout_secs: The socket timeout of the HTTP requests sent to the Apify API. """ super().__init__( token, @@ -318,7 +318,7 @@ def actor(self, actor_id: str) -> ActorClientAsync: """Retrieve the sub-client for manipulating a single Actor. Args: - actor_id (str): ID of the Actor to be manipulated + actor_id: ID of the Actor to be manipulated. """ return ActorClientAsync(resource_id=actor_id, **self._options()) @@ -330,7 +330,7 @@ def build(self, build_id: str) -> BuildClientAsync: """Retrieve the sub-client for manipulating a single Actor build. Args: - build_id (str): ID of the Actor build to be manipulated + build_id: ID of the Actor build to be manipulated. """ return BuildClientAsync(resource_id=build_id, **self._options()) @@ -342,7 +342,7 @@ def run(self, run_id: str) -> RunClientAsync: """Retrieve the sub-client for manipulating a single Actor run. Args: - run_id (str): ID of the Actor run to be manipulated + run_id: ID of the Actor run to be manipulated. """ return RunClientAsync(resource_id=run_id, **self._options()) @@ -354,7 +354,7 @@ def dataset(self, dataset_id: str) -> DatasetClientAsync: """Retrieve the sub-client for manipulating a single dataset. Args: - dataset_id (str): ID of the dataset to be manipulated + dataset_id: ID of the dataset to be manipulated. """ return DatasetClientAsync(resource_id=dataset_id, **self._options()) @@ -366,7 +366,7 @@ def key_value_store(self, key_value_store_id: str) -> KeyValueStoreClientAsync: """Retrieve the sub-client for manipulating a single key-value store. Args: - key_value_store_id (str): ID of the key-value store to be manipulated + key_value_store_id: ID of the key-value store to be manipulated. """ return KeyValueStoreClientAsync(resource_id=key_value_store_id, **self._options()) @@ -378,8 +378,8 @@ def request_queue(self, request_queue_id: str, *, client_key: str | None = None) """Retrieve the sub-client for manipulating a single request queue. Args: - request_queue_id (str): ID of the request queue to be manipulated - client_key (str): A unique identifier of the client accessing the request queue + request_queue_id: ID of the request queue to be manipulated. + client_key: A unique identifier of the client accessing the request queue. """ return RequestQueueClientAsync(resource_id=request_queue_id, client_key=client_key, **self._options()) @@ -391,7 +391,7 @@ def webhook(self, webhook_id: str) -> WebhookClientAsync: """Retrieve the sub-client for manipulating a single webhook. Args: - webhook_id (str): ID of the webhook to be manipulated + webhook_id: ID of the webhook to be manipulated. """ return WebhookClientAsync(resource_id=webhook_id, **self._options()) @@ -403,7 +403,7 @@ def webhook_dispatch(self, webhook_dispatch_id: str) -> WebhookDispatchClientAsy """Retrieve the sub-client for accessing a single webhook dispatch. Args: - webhook_dispatch_id (str): ID of the webhook dispatch to access + webhook_dispatch_id: ID of the webhook dispatch to access. """ return WebhookDispatchClientAsync(resource_id=webhook_dispatch_id, **self._options()) @@ -415,7 +415,7 @@ def schedule(self, schedule_id: str) -> ScheduleClientAsync: """Retrieve the sub-client for manipulating a single schedule. Args: - schedule_id (str): ID of the schedule to be manipulated + schedule_id: ID of the schedule to be manipulated. """ return ScheduleClientAsync(resource_id=schedule_id, **self._options()) @@ -427,7 +427,7 @@ def log(self, build_or_run_id: str) -> LogClientAsync: """Retrieve the sub-client for retrieving logs. Args: - build_or_run_id (str): ID of the Actor build or run for which to access the log + build_or_run_id: ID of the Actor build or run for which to access the log. """ return LogClientAsync(resource_id=build_or_run_id, **self._options()) @@ -435,7 +435,7 @@ def task(self, task_id: str) -> TaskClientAsync: """Retrieve the sub-client for manipulating a single task. Args: - task_id (str): ID of the task to be manipulated + task_id: ID of the task to be manipulated. """ return TaskClientAsync(resource_id=task_id, **self._options()) @@ -447,7 +447,7 @@ def user(self, user_id: str | None = None) -> UserClientAsync: """Retrieve the sub-client for querying users. Args: - user_id (str, optional): ID of user to be queried. If None, queries the user belonging to the token supplied to the client + user_id: ID of user to be queried. If None, queries the user belonging to the token supplied to the client. """ return UserClientAsync(resource_id=user_id, **self._options()) diff --git a/src/apify_client/clients/base/actor_job_base_client.py b/src/apify_client/clients/base/actor_job_base_client.py index 68718529..b65a38f8 100644 --- a/src/apify_client/clients/base/actor_job_base_client.py +++ b/src/apify_client/clients/base/actor_job_base_client.py @@ -42,7 +42,9 @@ def _wait_for_finish(self, wait_secs: int | None = None) -> dict | None: job = parse_date_fields(pluck_data(response.json())) seconds_elapsed = math.floor((datetime.now(timezone.utc) - started_at).total_seconds()) - if ActorJobStatus(job['status']).is_terminal or (wait_secs is not None and seconds_elapsed >= wait_secs): + if ActorJobStatus(job['status']).is_terminal or ( + wait_secs is not None and seconds_elapsed >= wait_secs + ): should_repeat = False if not should_repeat: @@ -52,8 +54,8 @@ def _wait_for_finish(self, wait_secs: int | None = None) -> dict | None: except ApifyApiError as exc: catch_not_found_or_throw(exc) - # If there are still not found errors after DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC, we give up and return None - # In such case, the requested record probably really doesn't exist. + # If there are still not found errors after DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC, we give up + # and return None. In such case, the requested record probably really doesn't exist. if seconds_elapsed > DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC: return None @@ -95,7 +97,9 @@ async def _wait_for_finish(self, wait_secs: int | None = None) -> dict | None: job = parse_date_fields(pluck_data(response.json())) seconds_elapsed = math.floor((datetime.now(timezone.utc) - started_at).total_seconds()) - if ActorJobStatus(job['status']).is_terminal or (wait_secs is not None and seconds_elapsed >= wait_secs): + if ActorJobStatus(job['status']).is_terminal or ( + wait_secs is not None and seconds_elapsed >= wait_secs + ): should_repeat = False if not should_repeat: @@ -105,8 +109,8 @@ async def _wait_for_finish(self, wait_secs: int | None = None) -> dict | None: except ApifyApiError as exc: catch_not_found_or_throw(exc) - # If there are still not found errors after DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC, we give up and return None - # In such case, the requested record probably really doesn't exist. + # If there are still not found errors after DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC, we give up + # and return None. In such case, the requested record probably really doesn't exist. if seconds_elapsed > DEFAULT_WAIT_WHEN_JOB_NOT_EXIST_SEC: return None diff --git a/src/apify_client/clients/base/base_client.py b/src/apify_client/clients/base/base_client.py index 04957b30..e4cb4bad 100644 --- a/src/apify_client/clients/base/base_client.py +++ b/src/apify_client/clients/base/base_client.py @@ -63,15 +63,15 @@ def __init__( resource_path: str, params: dict | None = None, ) -> None: - """Initialize the sub-client. + """A default constructor. Args: - base_url (str): Base URL of the API server - root_client (ApifyClient): The ApifyClient instance under which this resource client exists - http_client (HTTPClient): The HTTPClient instance to be used in this client - resource_id (str): ID of the manipulated resource, in case of a single-resource client - resource_path (str): Path to the resource's endpoint on the API server - params (dict): Parameters to include in all requests from this client + base_url: Base URL of the API server. + root_client: The ApifyClient instance under which this resource client exists. + http_client: The HTTPClient instance to be used in this client. + resource_id: ID of the manipulated resource, in case of a single-resource client. + resource_path: Path to the resource's endpoint on the API server. + params: Parameters to include in all requests from this client. """ if resource_path.endswith('/'): raise ValueError('resource_path must not end with "/"') @@ -106,15 +106,15 @@ def __init__( resource_path: str, params: dict | None = None, ) -> None: - """Initialize the sub-client. + """A default constructor. Args: - base_url (str): Base URL of the API server - root_client (ApifyClientAsync): The ApifyClientAsync instance under which this resource client exists - http_client (HTTPClientAsync): The HTTPClientAsync instance to be used in this client - resource_id (str): ID of the manipulated resource, in case of a single-resource client - resource_path (str): Path to the resource's endpoint on the API server - params (dict): Parameters to include in all requests from this client + base_url: Base URL of the API server. + root_client: The ApifyClientAsync instance under which this resource client exists. + http_client: The HTTPClientAsync instance to be used in this client. + resource_id: ID of the manipulated resource, in case of a single-resource client. + resource_path: Path to the resource's endpoint on the API server. + params: Parameters to include in all requests from this client. """ if resource_path.endswith('/'): raise ValueError('resource_path must not end with "/"') diff --git a/src/apify_client/clients/resource_clients/actor.py b/src/apify_client/clients/resource_clients/actor.py index 0cce4f6f..0c89ac59 100644 --- a/src/apify_client/clients/resource_clients/actor.py +++ b/src/apify_client/clients/resource_clients/actor.py @@ -12,11 +12,17 @@ from apify_client._utils import encode_key_value_store_record_value, encode_webhook_list_to_base64, pluck_data from apify_client.clients.base import ResourceClient, ResourceClientAsync from apify_client.clients.resource_clients.actor_version import ActorVersionClient, ActorVersionClientAsync -from apify_client.clients.resource_clients.actor_version_collection import ActorVersionCollectionClient, ActorVersionCollectionClientAsync +from apify_client.clients.resource_clients.actor_version_collection import ( + ActorVersionCollectionClient, + ActorVersionCollectionClientAsync, +) from apify_client.clients.resource_clients.build_collection import BuildCollectionClient, BuildCollectionClientAsync from apify_client.clients.resource_clients.run import RunClient, RunClientAsync from apify_client.clients.resource_clients.run_collection import RunCollectionClient, RunCollectionClientAsync -from apify_client.clients.resource_clients.webhook_collection import WebhookCollectionClient, WebhookCollectionClientAsync +from apify_client.clients.resource_clients.webhook_collection import ( + WebhookCollectionClient, + WebhookCollectionClientAsync, +) if TYPE_CHECKING: from apify_shared.consts import ActorJobStatus, MetaOrigin @@ -87,7 +93,6 @@ class ActorClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorClient.""" resource_path = kwargs.pop('resource_path', 'acts') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -97,7 +102,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actors/actor-object/get-actor Returns: - dict, optional: The retrieved Actor + The retrieved Actor. """ return self._get() @@ -133,34 +138,37 @@ def update( https://docs.apify.com/api/v2#/reference/actors/actor-object/update-actor Args: - name (str, optional): The name of the Actor - title (str, optional): The title of the Actor (human-readable) - description (str, optional): The description for the Actor - seo_title (str, optional): The title of the Actor optimized for search engines - seo_description (str, optional): The description of the Actor optimized for search engines - versions (list of dict, optional): The list of Actor versions - restart_on_error (bool, optional): If true, the main Actor run process will be restarted whenever it exits with a non-zero status code. - is_public (bool, optional): Whether the Actor is public. - is_deprecated (bool, optional): Whether the Actor is deprecated. - is_anonymously_runnable (bool, optional): Whether the Actor is anonymously runnable. - categories (list of str, optional): The categories to which the Actor belongs to. - default_run_build (str, optional): Tag or number of the build that you want to run by default. - default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor, - if the Actor is charged per result. - default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this Actor, in megabytes. - default_run_timeout_secs (int, optional): Default timeout for the runs of this Actor in seconds. - example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this Actor. - example_run_input_content_type (str, optional): The content type of the example run input. - actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + name: The name of the Actor. + title: The title of the Actor (human-readable). + description: The description for the Actor. + seo_title: The title of the Actor optimized for search engines. + seo_description: The description of the Actor optimized for search engines. + versions: The list of Actor versions. + restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + a non-zero status code. + is_public: Whether the Actor is public. + is_deprecated: Whether the Actor is deprecated. + is_anonymously_runnable: Whether the Actor is anonymously runnable. + categories: The categories to which the Actor belongs to. + default_run_build: Tag or number of the build that you want to run by default. + default_run_max_items: Default limit of the number of results that will be returned + by runs of this Actor, if the Actor is charged per result. + default_run_memory_mbytes: Default amount of memory allocated for the runs of this Actor, in megabytes. + default_run_timeout_secs: Default timeout for the runs of this Actor in seconds. + example_run_input_body: Input to be prefilled as default input to new users of this Actor. + example_run_input_content_type: The content type of the example run input. + actor_standby_is_enabled: Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The updated Actor + The updated Actor. """ actor_representation = get_actor_representation( name=name, @@ -214,29 +222,28 @@ def start( https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor Args: - run_input (Any, optional): The input to pass to the Actor run. - content_type (str, optional): The content type of the input. - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the default run configuration for the Actor (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the default run configuration for the Actor. - timeout_secs (int, optional): Optional timeout for the run, in seconds. - By default, the run uses timeout specified in the default run configuration for the Actor. - wait_for_finish (int, optional): The maximum number of seconds the server waits for the run to finish. - By default, it is 0, the maximum value is 60. - webhooks (list of dict, optional): Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) - associated with the Actor run which can be used to receive a notification, - e.g. when the Actor finished or failed. - If you already have a webhook set up for the Actor or task, you do not have to add it again here. - Each webhook is represented by a dictionary containing these items: - * ``event_types``: list of ``WebhookEventType`` values which trigger the webhook - * ``request_url``: URL to which to send the webhook HTTP request - * ``payload_template`` (optional): Optional template for the request payload + run_input: The input to pass to the Actor run. + content_type: The content type of the input. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the default run configuration for the Actor (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged + per result, you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit + specified in the default run configuration for the Actor. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the default run configuration for the Actor. + wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default, + it is 0, the maximum value is 60. + webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with + the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed. + If you already have a webhook set up for the Actor or task, you do not have to add it again here. + Each webhook is represented by a dictionary containing these items: + * `event_types`: List of `WebhookEventType` values which trigger the webhook. + * `request_url`: URL to which to send the webhook HTTP request. + * `payload_template`: Optional template for the request payload. Returns: - dict: The run object + The run object. """ run_input, content_type = encode_key_value_store_record_value(run_input, content_type) @@ -278,23 +285,24 @@ def call( https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor Args: - run_input (Any, optional): The input to pass to the Actor run. - content_type (str, optional): The content type of the input. - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the default run configuration for the Actor (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the default run configuration for the Actor. - timeout_secs (int, optional): Optional timeout for the run, in seconds. - By default, the run uses timeout specified in the default run configuration for the Actor. - webhooks (list, optional): Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, - which can be used to receive a notification, e.g. when the Actor finished or failed. - If you already have a webhook set up for the Actor, you do not have to add it again here. - wait_secs (int, optional): The maximum number of seconds the server waits for the run to finish. If not provided, waits indefinitely. + run_input: The input to pass to the Actor run. + content_type: The content type of the input. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the default run configuration for the Actor (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged + per result, you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit + specified in the default run configuration for the Actor. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the default run configuration for the Actor. + webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can + be used to receive a notification, e.g. when the Actor finished or failed. If you already have + a webhook set up for the Actor, you do not have to add it again here. + wait_secs: The maximum number of seconds the server waits for the run to finish. If not provided, + waits indefinitely. Returns: - dict: The run object + The run object. """ started_run = self.start( run_input=run_input, @@ -322,19 +330,19 @@ def build( https://docs.apify.com/api/v2#/reference/actors/build-collection/build-actor Args: - version_number (str): Actor version number to be built. - beta_packages (bool, optional): If True, then the Actor is built with beta versions of Apify NPM packages. - By default, the build uses latest stable packages. - tag (str, optional): Tag to be applied to the build on success. By default, the tag is taken from the Actor version's buildTag property. - use_cache (bool, optional): If true, the Actor's Docker container will be rebuilt using layer cache - (https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache). - This is to enable quick rebuild during development. - By default, the cache is not used. - wait_for_finish (int, optional): The maximum number of seconds the server waits for the build to finish before returning. - By default it is 0, the maximum value is 60. + version_number: Actor version number to be built. + beta_packages: If True, then the Actor is built with beta versions of Apify NPM packages. By default, + the build uses latest stable packages. + tag: Tag to be applied to the build on success. By default, the tag is taken from the Actor version's + build tag property. + use_cache: If true, the Actor's Docker container will be rebuilt using layer cache + (https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache). + This is to enable quick rebuild during development. By default, the cache is not used. + wait_for_finish: The maximum number of seconds the server waits for the build to finish before returning. + By default it is 0, the maximum value is 60. Returns: - dict: The build object + The build object. """ request_params = self._params( version=version_number, @@ -371,11 +379,11 @@ def last_run( Last run is retrieved based on the start time of the runs. Args: - status (ActorJobStatus, optional): Consider only runs with this status. - origin (MetaOrigin, optional): Consider only runs started with this origin. + status: Consider only runs with this status. + origin: Consider only runs started with this origin. Returns: - RunClient: The resource client for the last run of this Actor. + The resource client for the last run of this Actor. """ return RunClient( **self._sub_resource_init_options( @@ -396,10 +404,10 @@ def version(self, version_number: str) -> ActorVersionClient: """Retrieve the client for the specified version of this Actor. Args: - version_number (str): The version number for which to retrieve the resource client. + version_number: The version number for which to retrieve the resource client. Returns: - ActorVersionClient: The resource client for the specified Actor version. + The resource client for the specified Actor version. """ return ActorVersionClient(**self._sub_resource_init_options(resource_id=version_number)) @@ -413,7 +421,6 @@ class ActorClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorClientAsync.""" resource_path = kwargs.pop('resource_path', 'acts') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -423,7 +430,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actors/actor-object/get-actor Returns: - dict, optional: The retrieved Actor + The retrieved Actor. """ return await self._get() @@ -459,34 +466,37 @@ async def update( https://docs.apify.com/api/v2#/reference/actors/actor-object/update-actor Args: - name (str, optional): The name of the Actor - title (str, optional): The title of the Actor (human-readable) - description (str, optional): The description for the Actor - seo_title (str, optional): The title of the Actor optimized for search engines - seo_description (str, optional): The description of the Actor optimized for search engines - versions (list of dict, optional): The list of Actor versions - restart_on_error (bool, optional): If true, the main Actor run process will be restarted whenever it exits with a non-zero status code. - is_public (bool, optional): Whether the Actor is public. - is_deprecated (bool, optional): Whether the Actor is deprecated. - is_anonymously_runnable (bool, optional): Whether the Actor is anonymously runnable. - categories (list of str, optional): The categories to which the Actor belongs to. - default_run_build (str, optional): Tag or number of the build that you want to run by default. - default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor, - if the Actor is charged per result. - default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this Actor, in megabytes. - default_run_timeout_secs (int, optional): Default timeout for the runs of this Actor in seconds. - example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this Actor. - example_run_input_content_type (str, optional): The content type of the example run input. - actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + name: The name of the Actor. + title: The title of the Actor (human-readable). + description: The description for the Actor. + seo_title: The title of the Actor optimized for search engines. + seo_description: The description of the Actor optimized for search engines. + versions: The list of Actor versions. + restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + a non-zero status code. + is_public: Whether the Actor is public. + is_deprecated: Whether the Actor is deprecated. + is_anonymously_runnable: Whether the Actor is anonymously runnable. + categories: The categories to which the Actor belongs to. + default_run_build: Tag or number of the build that you want to run by default. + default_run_max_items: Default limit of the number of results that will be returned + by runs of this Actor, if the Actor is charged per result. + default_run_memory_mbytes: Default amount of memory allocated for the runs of this Actor, in megabytes. + default_run_timeout_secs: Default timeout for the runs of this Actor in seconds. + example_run_input_body: Input to be prefilled as default input to new users of this Actor. + example_run_input_content_type: The content type of the example run input. + actor_standby_is_enabled: Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The updated Actor + The updated Actor. """ actor_representation = get_actor_representation( name=name, @@ -540,29 +550,28 @@ async def start( https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor Args: - run_input (Any, optional): The input to pass to the Actor run. - content_type (str, optional): The content type of the input. - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the default run configuration for the Actor (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the default run configuration for the Actor. - timeout_secs (int, optional): Optional timeout for the run, in seconds. - By default, the run uses timeout specified in the default run configuration for the Actor. - wait_for_finish (int, optional): The maximum number of seconds the server waits for the run to finish. - By default, it is 0, the maximum value is 60. - webhooks (list of dict, optional): Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) - associated with the Actor run which can be used to receive a notification, - e.g. when the Actor finished or failed. - If you already have a webhook set up for the Actor or task, you do not have to add it again here. - Each webhook is represented by a dictionary containing these items: - * ``event_types``: list of ``WebhookEventType`` values which trigger the webhook - * ``request_url``: URL to which to send the webhook HTTP request - * ``payload_template`` (optional): Optional template for the request payload + run_input: The input to pass to the Actor run. + content_type: The content type of the input. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the default run configuration for the Actor (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged + per result, you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit + specified in the default run configuration for the Actor. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the default run configuration for the Actor. + wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default, + it is 0, the maximum value is 60. + webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with + the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed. + If you already have a webhook set up for the Actor or task, you do not have to add it again here. + Each webhook is represented by a dictionary containing these items: + * `event_types`: List of `WebhookEventType` values which trigger the webhook. + * `request_url`: URL to which to send the webhook HTTP request. + * `payload_template`: Optional template for the request payload. Returns: - dict: The run object + The run object. """ run_input, content_type = encode_key_value_store_record_value(run_input, content_type) @@ -604,23 +613,24 @@ async def call( https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor Args: - run_input (Any, optional): The input to pass to the Actor run. - content_type (str, optional): The content type of the input. - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the default run configuration for the Actor (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the default run configuration for the Actor. - timeout_secs (int, optional): Optional timeout for the run, in seconds. - By default, the run uses timeout specified in the default run configuration for the Actor. - webhooks (list, optional): Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, - which can be used to receive a notification, e.g. when the Actor finished or failed. - If you already have a webhook set up for the Actor, you do not have to add it again here. - wait_secs (int, optional): The maximum number of seconds the server waits for the run to finish. If not provided, waits indefinitely. + run_input: The input to pass to the Actor run. + content_type: The content type of the input. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the default run configuration for the Actor (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged + per result, you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit + specified in the default run configuration for the Actor. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the default run configuration for the Actor. + webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can + be used to receive a notification, e.g. when the Actor finished or failed. If you already have + a webhook set up for the Actor, you do not have to add it again here. + wait_secs: The maximum number of seconds the server waits for the run to finish. If not provided, + waits indefinitely. Returns: - dict: The run object + The run object. """ started_run = await self.start( run_input=run_input, @@ -648,19 +658,19 @@ async def build( https://docs.apify.com/api/v2#/reference/actors/build-collection/build-actor Args: - version_number (str): Actor version number to be built. - beta_packages (bool, optional): If True, then the Actor is built with beta versions of Apify NPM packages. - By default, the build uses latest stable packages. - tag (str, optional): Tag to be applied to the build on success. By default, the tag is taken from the Actor version's buildTag property. - use_cache (bool, optional): If true, the Actor's Docker container will be rebuilt using layer cache - (https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache). - This is to enable quick rebuild during development. - By default, the cache is not used. - wait_for_finish (int, optional): The maximum number of seconds the server waits for the build to finish before returning. - By default it is 0, the maximum value is 60. + version_number: Actor version number to be built. + beta_packages: If True, then the Actor is built with beta versions of Apify NPM packages. By default, + the build uses latest stable packages. + tag: Tag to be applied to the build on success. By default, the tag is taken from the Actor version's + build tag property. + use_cache: If true, the Actor's Docker container will be rebuilt using layer cache + (https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache). + This is to enable quick rebuild during development. By default, the cache is not used. + wait_for_finish: The maximum number of seconds the server waits for the build to finish before returning. + By default it is 0, the maximum value is 60. Returns: - dict: The build object + The build object. """ request_params = self._params( version=version_number, @@ -686,17 +696,22 @@ def runs(self) -> RunCollectionClientAsync: """Retrieve a client for the runs of this Actor.""" return RunCollectionClientAsync(**self._sub_resource_init_options(resource_path='runs')) - def last_run(self, *, status: ActorJobStatus | None = None, origin: MetaOrigin | None = None) -> RunClientAsync: + def last_run( + self, + *, + status: ActorJobStatus | None = None, + origin: MetaOrigin | None = None, + ) -> RunClientAsync: """Retrieve the client for the last run of this Actor. Last run is retrieved based on the start time of the runs. Args: - status (ActorJobStatus, optional): Consider only runs with this status. - origin (MetaOrigin, optional): Consider only runs started with this origin. + status: Consider only runs with this status. + origin: Consider only runs started with this origin. Returns: - RunClientAsync: The resource client for the last run of this Actor. + The resource client for the last run of this Actor. """ return RunClientAsync( **self._sub_resource_init_options( @@ -717,10 +732,10 @@ def version(self, version_number: str) -> ActorVersionClientAsync: """Retrieve the client for the specified version of this Actor. Args: - version_number (str): The version number for which to retrieve the resource client. + version_number: The version number for which to retrieve the resource client. Returns: - ActorVersionClientAsync: The resource client for the specified Actor version. + The resource client for the specified Actor version. """ return ActorVersionClientAsync(**self._sub_resource_init_options(resource_id=version_number)) diff --git a/src/apify_client/clients/resource_clients/actor_collection.py b/src/apify_client/clients/resource_clients/actor_collection.py index 008cabf8..7fc2559d 100644 --- a/src/apify_client/clients/resource_clients/actor_collection.py +++ b/src/apify_client/clients/resource_clients/actor_collection.py @@ -16,7 +16,6 @@ class ActorCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorCollectionClient.""" resource_path = kwargs.pop('resource_path', 'acts') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -33,13 +32,13 @@ def list( https://docs.apify.com/api/v2#/reference/actors/actor-collection/get-list-of-actors Args: - my (bool, optional): If True, will return only Actors which the user has created themselves. - limit (int, optional): How many Actors to list - offset (int, optional): What Actor to include as first when retrieving the list - desc (bool, optional): Whether to sort the Actors in descending order based on their creation date + my: If True, will return only Actors which the user has created themselves. + limit: How many Actors to list. + offset: What Actor to include as first when retrieving the list. + desc: Whether to sort the Actors in descending order based on their creation date. Returns: - ListPage: The list of available Actors matching the specified filters. + The list of available Actors matching the specified filters. """ return self._list(my=my, limit=limit, offset=offset, desc=desc) @@ -75,34 +74,37 @@ def create( https://docs.apify.com/api/v2#/reference/actors/actor-collection/create-actor Args: - name (str): The name of the Actor - title (str, optional): The title of the Actor (human-readable) - description (str, optional): The description for the Actor - seo_title (str, optional): The title of the Actor optimized for search engines - seo_description (str, optional): The description of the Actor optimized for search engines - versions (list of dict, optional): The list of Actor versions - restart_on_error (bool, optional): If true, the main Actor run process will be restarted whenever it exits with a non-zero status code. - is_public (bool, optional): Whether the Actor is public. - is_deprecated (bool, optional): Whether the Actor is deprecated. - is_anonymously_runnable (bool, optional): Whether the Actor is anonymously runnable. - categories (list of str, optional): The categories to which the Actor belongs to. - default_run_build (str, optional): Tag or number of the build that you want to run by default. - default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor, - if the Actor is charged per result. - default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this Actor, in megabytes. - default_run_timeout_secs (int, optional): Default timeout for the runs of this Actor in seconds. - example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this Actor. - example_run_input_content_type (str, optional): The content type of the example run input. - actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + name: The name of the Actor. + title: The title of the Actor (human-readable). + description: The description for the Actor. + seo_title: The title of the Actor optimized for search engines. + seo_description: The description of the Actor optimized for search engines. + versions: The list of Actor versions. + restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + a non-zero status code. + is_public: Whether the Actor is public. + is_deprecated: Whether the Actor is deprecated. + is_anonymously_runnable: Whether the Actor is anonymously runnable. + categories: The categories to which the Actor belongs to. + default_run_build: Tag or number of the build that you want to run by default. + default_run_max_items: Default limit of the number of results that will be returned by runs + of this Actor, if the Actor is charged per result. + default_run_memory_mbytes: Default amount of memory allocated for the runs of this Actor, in megabytes. + default_run_timeout_secs: Default timeout for the runs of this Actor in seconds. + example_run_input_body: Input to be prefilled as default input to new users of this Actor. + example_run_input_content_type: The content type of the example run input. + actor_standby_is_enabled: Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The created Actor. + The created Actor. """ actor_representation = get_actor_representation( name=name, @@ -138,7 +140,6 @@ class ActorCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'acts') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -155,13 +156,13 @@ async def list( https://docs.apify.com/api/v2#/reference/actors/actor-collection/get-list-of-actors Args: - my (bool, optional): If True, will return only Actors which the user has created themselves. - limit (int, optional): How many Actors to list - offset (int, optional): What Actor to include as first when retrieving the list - desc (bool, optional): Whether to sort the Actors in descending order based on their creation date + my: If True, will return only Actors which the user has created themselves. + limit: How many Actors to list. + offset: What Actor to include as first when retrieving the list. + desc: Whether to sort the Actors in descending order based on their creation date. Returns: - ListPage: The list of available Actors matching the specified filters. + The list of available Actors matching the specified filters. """ return await self._list(my=my, limit=limit, offset=offset, desc=desc) @@ -197,34 +198,37 @@ async def create( https://docs.apify.com/api/v2#/reference/actors/actor-collection/create-actor Args: - name (str): The name of the Actor - title (str, optional): The title of the Actor (human-readable) - description (str, optional): The description for the Actor - seo_title (str, optional): The title of the Actor optimized for search engines - seo_description (str, optional): The description of the Actor optimized for search engines - versions (list of dict, optional): The list of Actor versions - restart_on_error (bool, optional): If true, the main Actor run process will be restarted whenever it exits with a non-zero status code. - is_public (bool, optional): Whether the Actor is public. - is_deprecated (bool, optional): Whether the Actor is deprecated. - is_anonymously_runnable (bool, optional): Whether the Actor is anonymously runnable. - categories (list of str, optional): The categories to which the Actor belongs to. - default_run_build (str, optional): Tag or number of the build that you want to run by default. - default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor, - if the Actor is charged per result. - default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this Actor, in megabytes. - default_run_timeout_secs (int, optional): Default timeout for the runs of this Actor in seconds. - example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this Actor. - example_run_input_content_type (str, optional): The content type of the example run input. - actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + name: The name of the Actor. + title: The title of the Actor (human-readable). + description: The description for the Actor. + seo_title: The title of the Actor optimized for search engines. + seo_description: The description of the Actor optimized for search engines. + versions: The list of Actor versions. + restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + a non-zero status code. + is_public: Whether the Actor is public. + is_deprecated: Whether the Actor is deprecated. + is_anonymously_runnable: Whether the Actor is anonymously runnable. + categories: The categories to which the Actor belongs to. + default_run_build: Tag or number of the build that you want to run by default. + default_run_max_items: Default limit of the number of results that will be returned by runs + of this Actor, if the Actor is charged per result. + default_run_memory_mbytes: Default amount of memory allocated for the runs of this Actor, in megabytes. + default_run_timeout_secs: Default timeout for the runs of this Actor in seconds. + example_run_input_body: Input to be prefilled as default input to new users of this Actor. + example_run_input_content_type: The content type of the example run input. + actor_standby_is_enabled: Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The created Actor. + The created Actor. """ actor_representation = get_actor_representation( name=name, diff --git a/src/apify_client/clients/resource_clients/actor_env_var.py b/src/apify_client/clients/resource_clients/actor_env_var.py index 34e6ca3b..c2b2676b 100644 --- a/src/apify_client/clients/resource_clients/actor_env_var.py +++ b/src/apify_client/clients/resource_clients/actor_env_var.py @@ -26,7 +26,6 @@ class ActorEnvVarClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorEnvVarClient.""" resource_path = kwargs.pop('resource_path', 'env-vars') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -36,7 +35,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/get-environment-variable Returns: - dict, optional: The retrieved Actor environment variable data + The retrieved Actor environment variable data. """ return self._get() @@ -52,12 +51,12 @@ def update( https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/update-environment-variable Args: - is_secret (bool, optional): Whether the environment variable is secret or not - name (str): The name of the environment variable - value (str): The value of the environment variable + is_secret: Whether the environment variable is secret or not. + name: The name of the environment variable. + value: The value of the environment variable. Returns: - dict: The updated Actor environment variable + The updated Actor environment variable. """ actor_env_var_representation = get_actor_env_var_representation( is_secret=is_secret, @@ -80,7 +79,6 @@ class ActorEnvVarClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorEnvVarClientAsync.""" resource_path = kwargs.pop('resource_path', 'env-vars') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -90,7 +88,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/get-environment-variable Returns: - dict, optional: The retrieved Actor environment variable data + The retrieved Actor environment variable data. """ return await self._get() @@ -106,12 +104,12 @@ async def update( https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/update-environment-variable Args: - is_secret (bool, optional): Whether the environment variable is secret or not - name (str): The name of the environment variable - value (str): The value of the environment variable + is_secret: Whether the environment variable is secret or not. + name: The name of the environment variable. + value: The value of the environment variable. Returns: - dict: The updated Actor environment variable + The updated Actor environment variable. """ actor_env_var_representation = get_actor_env_var_representation( is_secret=is_secret, 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 9b8ae55b..e6ffb7a8 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 @@ -16,7 +16,6 @@ class ActorEnvVarCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorEnvVarCollectionClient with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'env-vars') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -26,7 +25,7 @@ def list(self) -> ListPage[dict]: https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/get-list-of-environment-variables Returns: - ListPage: The list of available actor environment variables. + The list of available actor environment variables. """ return self._list() @@ -42,12 +41,12 @@ def create( https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/create-environment-variable Args: - is_secret (bool, optional): Whether the environment variable is secret or not - name (str): The name of the environment variable - value (str): The value of the environment variable + is_secret: Whether the environment variable is secret or not. + name: The name of the environment variable. + value: The value of the environment variable. Returns: - dict: The created actor environment variable + The created actor environment variable. """ actor_env_var_representation = get_actor_env_var_representation( is_secret=is_secret, @@ -63,7 +62,6 @@ class ActorEnvVarCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorEnvVarCollectionClientAsync with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'env-vars') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -73,7 +71,7 @@ async def list(self) -> ListPage[dict]: https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/get-list-of-environment-variables Returns: - ListPage: The list of available actor environment variables. + The list of available actor environment variables. """ return await self._list() @@ -89,12 +87,12 @@ async def create( https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/create-environment-variable Args: - is_secret (bool, optional): Whether the environment variable is secret or not - name (str): The name of the environment variable - value (str): The value of the environment variable + is_secret: Whether the environment variable is secret or not. + name: The name of the environment variable. + value: The value of the environment variable. Returns: - dict: The created actor environment variable + The created actor environment variable. """ actor_env_var_representation = get_actor_env_var_representation( is_secret=is_secret, diff --git a/src/apify_client/clients/resource_clients/actor_version.py b/src/apify_client/clients/resource_clients/actor_version.py index 286db68b..db48c041 100644 --- a/src/apify_client/clients/resource_clients/actor_version.py +++ b/src/apify_client/clients/resource_clients/actor_version.py @@ -6,7 +6,10 @@ from apify_client.clients.base import ResourceClient, ResourceClientAsync from apify_client.clients.resource_clients.actor_env_var import ActorEnvVarClient, ActorEnvVarClientAsync -from apify_client.clients.resource_clients.actor_env_var_collection import ActorEnvVarCollectionClient, ActorEnvVarCollectionClientAsync +from apify_client.clients.resource_clients.actor_env_var_collection import ( + ActorEnvVarCollectionClient, + ActorEnvVarCollectionClientAsync, +) if TYPE_CHECKING: from apify_shared.consts import ActorSourceType @@ -42,7 +45,6 @@ class ActorVersionClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorVersionClient.""" resource_path = kwargs.pop('resource_path', 'versions') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -52,7 +54,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actors/version-object/get-version Returns: - dict, optional: The retrieved Actor version data + The retrieved Actor version data. """ return self._get() @@ -73,23 +75,23 @@ def update( https://docs.apify.com/api/v2#/reference/actors/version-object/update-version Args: - build_tag (str, optional): Tag that is automatically set to the latest successful build of the current version. - env_vars (list of dict, optional): Environment variables that will be available to the Actor run process, - and optionally also to the build process. See the API docs for their exact structure. - apply_env_vars_to_build (bool, optional): Whether the environment variables specified for the Actor run - will also be set to the Actor build process. - source_type (ActorSourceType, optional): What source type is the Actor version using. - source_files (list of dict, optional): Source code comprised of multiple files, each an item of the array. - Required when ``source_type`` is ``ActorSourceType.SOURCE_FILES``. See the API docs for the exact structure. - git_repo_url (str, optional): The URL of a Git repository from which the source code will be cloned. - Required when ``source_type`` is ``ActorSourceType.GIT_REPO``. - tarball_url (str, optional): The URL of a tarball or a zip archive from which the source code will be downloaded. - Required when ``source_type`` is ``ActorSourceType.TARBALL``. - github_gist_url (str, optional): The URL of a GitHub Gist from which the source will be downloaded. - Required when ``source_type`` is ``ActorSourceType.GITHUB_GIST``. + build_tag: Tag that is automatically set to the latest successful build of the current version. + env_vars: Environment variables that will be available to the Actor run process, and optionally + also to the build process. See the API docs for their exact structure. + apply_env_vars_to_build: Whether the environment variables specified for the Actor run will also + be set to the Actor build process. + source_type: What source type is the Actor version using. + source_files: Source code comprised of multiple files, each an item of the array. Required when + `source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure. + git_repo_url: The URL of a Git repository from which the source code will be cloned. + Required when `source_type` is `ActorSourceType.GIT_REPO`. + tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded. + Required when `source_type` is `ActorSourceType.TARBALL`. + github_gist_url: The URL of a GitHub Gist from which the source will be downloaded. + Required when `source_type` is `ActorSourceType.GITHUB_GIST`. Returns: - dict: The updated Actor version + The updated Actor version. """ actor_version_representation = _get_actor_version_representation( build_tag=build_tag, @@ -119,10 +121,10 @@ def env_var(self, env_var_name: str) -> ActorEnvVarClient: """Retrieve the client for the specified environment variable of this Actor version. Args: - env_var_name (str): The name of the environment variable for which to retrieve the resource client. + env_var_name: The name of the environment variable for which to retrieve the resource client. Returns: - ActorEnvVarClient: The resource client for the specified Actor environment variable. + The resource client for the specified Actor environment variable. """ return ActorEnvVarClient(**self._sub_resource_init_options(resource_id=env_var_name)) @@ -132,7 +134,6 @@ class ActorVersionClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorVersionClientAsync.""" resource_path = kwargs.pop('resource_path', 'versions') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -142,7 +143,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actors/version-object/get-version Returns: - dict, optional: The retrieved Actor version data + The retrieved Actor version data. """ return await self._get() @@ -163,23 +164,23 @@ async def update( https://docs.apify.com/api/v2#/reference/actors/version-object/update-version Args: - build_tag (str, optional): Tag that is automatically set to the latest successful build of the current version. - env_vars (list of dict, optional): Environment variables that will be available to the Actor run process, - and optionally also to the build process. See the API docs for their exact structure. - apply_env_vars_to_build (bool, optional): Whether the environment variables specified for the Actor run - will also be set to the Actor build process. - source_type (ActorSourceType, optional): What source type is the Actor version using. - source_files (list of dict, optional): Source code comprised of multiple files, each an item of the array. - Required when ``source_type`` is ``ActorSourceType.SOURCE_FILES``. See the API docs for the exact structure. - git_repo_url (str, optional): The URL of a Git repository from which the source code will be cloned. - Required when ``source_type`` is ``ActorSourceType.GIT_REPO``. - tarball_url (str, optional): The URL of a tarball or a zip archive from which the source code will be downloaded. - Required when ``source_type`` is ``ActorSourceType.TARBALL``. - github_gist_url (str, optional): The URL of a GitHub Gist from which the source will be downloaded. - Required when ``source_type`` is ``ActorSourceType.GITHUB_GIST``. + build_tag: Tag that is automatically set to the latest successful build of the current version. + env_vars: Environment variables that will be available to the Actor run process, and optionally + also to the build process. See the API docs for their exact structure. + apply_env_vars_to_build: Whether the environment variables specified for the Actor run will also + be set to the Actor build process. + source_type: What source type is the Actor version using. + source_files: Source code comprised of multiple files, each an item of the array. Required when + `source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure. + git_repo_url: The URL of a Git repository from which the source code will be cloned. + Required when `source_type` is `ActorSourceType.GIT_REPO`. + tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded. + Required when `source_type` is `ActorSourceType.TARBALL`. + github_gist_url: The URL of a GitHub Gist from which the source will be downloaded. + Required when `source_type` is `ActorSourceType.GITHUB_GIST`. Returns: - dict: The updated Actor version + The updated Actor version. """ actor_version_representation = _get_actor_version_representation( build_tag=build_tag, @@ -209,9 +210,9 @@ def env_var(self, env_var_name: str) -> ActorEnvVarClientAsync: """Retrieve the client for the specified environment variable of this Actor version. Args: - env_var_name (str): The name of the environment variable for which to retrieve the resource client. + env_var_name: The name of the environment variable for which to retrieve the resource client. Returns: - ActorEnvVarClientAsync: The resource client for the specified Actor environment variable. + The resource client for the specified Actor environment variable. """ return ActorEnvVarClientAsync(**self._sub_resource_init_options(resource_id=env_var_name)) 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 5ef047be..fa582957 100644 --- a/src/apify_client/clients/resource_clients/actor_version_collection.py +++ b/src/apify_client/clients/resource_clients/actor_version_collection.py @@ -17,7 +17,6 @@ class ActorVersionCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorVersionCollectionClient with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'versions') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -27,7 +26,7 @@ def list(self) -> ListPage[dict]: https://docs.apify.com/api/v2#/reference/actors/version-collection/get-list-of-versions Returns: - ListPage: The list of available Actor versions. + The list of available Actor versions. """ return self._list() @@ -49,24 +48,24 @@ def create( https://docs.apify.com/api/v2#/reference/actors/version-collection/create-version Args: - version_number (str): Major and minor version of the Actor (e.g. ``1.0``) - build_tag (str, optional): Tag that is automatically set to the latest successful build of the current version. - env_vars (list of dict, optional): Environment variables that will be available to the Actor run process, - and optionally also to the build process. See the API docs for their exact structure. - apply_env_vars_to_build (bool, optional): Whether the environment variables specified for the Actor run - will also be set to the Actor build process. - source_type (ActorSourceType): What source type is the Actor version using. - source_files (list of dict, optional): Source code comprised of multiple files, each an item of the array. - Required when ``source_type`` is ``ActorSourceType.SOURCE_FILES``. See the API docs for the exact structure. - git_repo_url (str, optional): The URL of a Git repository from which the source code will be cloned. - Required when ``source_type`` is ``ActorSourceType.GIT_REPO``. - tarball_url (str, optional): The URL of a tarball or a zip archive from which the source code will be downloaded. - Required when ``source_type`` is ``ActorSourceType.TARBALL``. - github_gist_url (str, optional): The URL of a GitHub Gist from which the source will be downloaded. - Required when ``source_type`` is ``ActorSourceType.GITHUB_GIST``. + version_number: Major and minor version of the Actor (e.g. `1.0`). + build_tag: Tag that is automatically set to the latest successful build of the current version. + env_vars: Environment variables that will be available to the Actor run process, and optionally + also to the build process. See the API docs for their exact structure. + apply_env_vars_to_build: Whether the environment variables specified for the Actor run will also + be set to the Actor build process. + source_type: What source type is the Actor version using. + source_files: Source code comprised of multiple files, each an item of the array. Required + when `source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure. + git_repo_url: The URL of a Git repository from which the source code will be cloned. + Required when `source_type` is `ActorSourceType.GIT_REPO`. + tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded. + Required when `source_type` is `ActorSourceType.TARBALL`. + github_gist_url: The URL of a GitHub Gist from which the source will be downloaded. + Required when `source_type` is `ActorSourceType.GITHUB_GIST`. Returns: - dict: The created Actor version + The created Actor version. """ actor_version_representation = _get_actor_version_representation( version_number=version_number, @@ -88,7 +87,6 @@ class ActorVersionCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ActorVersionCollectionClientAsync with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'versions') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -98,7 +96,7 @@ async def list(self) -> ListPage[dict]: https://docs.apify.com/api/v2#/reference/actors/version-collection/get-list-of-versions Returns: - ListPage: The list of available Actor versions. + The list of available Actor versions. """ return await self._list() @@ -120,24 +118,24 @@ async def create( https://docs.apify.com/api/v2#/reference/actors/version-collection/create-version Args: - version_number (str): Major and minor version of the Actor (e.g. ``1.0``) - build_tag (str, optional): Tag that is automatically set to the latest successful build of the current version. - env_vars (list of dict, optional): Environment variables that will be available to the Actor run process, - and optionally also to the build process. See the API docs for their exact structure. - apply_env_vars_to_build (bool, optional): Whether the environment variables specified for the Actor run - will also be set to the Actor build process. - source_type (ActorSourceType): What source type is the Actor version using. - source_files (list of dict, optional): Source code comprised of multiple files, each an item of the array. - Required when ``source_type`` is ``ActorSourceType.SOURCE_FILES``. See the API docs for the exact structure. - git_repo_url (str, optional): The URL of a Git repository from which the source code will be cloned. - Required when ``source_type`` is ``ActorSourceType.GIT_REPO``. - tarball_url (str, optional): The URL of a tarball or a zip archive from which the source code will be downloaded. - Required when ``source_type`` is ``ActorSourceType.TARBALL``. - github_gist_url (str, optional): The URL of a GitHub Gist from which the source will be downloaded. - Required when ``source_type`` is ``ActorSourceType.GITHUB_GIST``. + version_number: Major and minor version of the Actor (e.g. `1.0`). + build_tag: Tag that is automatically set to the latest successful build of the current version. + env_vars: Environment variables that will be available to the Actor run process, and optionally + also to the build process. See the API docs for their exact structure. + apply_env_vars_to_build: Whether the environment variables specified for the Actor run will also + be set to the Actor build process. + source_type: What source type is the Actor version using. + source_files: Source code comprised of multiple files, each an item of the array. Required + when `source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure. + git_repo_url: The URL of a Git repository from which the source code will be cloned. + Required when `source_type` is `ActorSourceType.GIT_REPO`. + tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded. + Required when `source_type` is `ActorSourceType.TARBALL`. + github_gist_url: The URL of a GitHub Gist from which the source will be downloaded. + Required when `source_type` is `ActorSourceType.GITHUB_GIST`. Returns: - dict: The created Actor version + The created Actor version. """ actor_version_representation = _get_actor_version_representation( version_number=version_number, diff --git a/src/apify_client/clients/resource_clients/build.py b/src/apify_client/clients/resource_clients/build.py index 38fd5ae4..41d7ac51 100644 --- a/src/apify_client/clients/resource_clients/build.py +++ b/src/apify_client/clients/resource_clients/build.py @@ -13,7 +13,6 @@ class BuildClient(ActorJobBaseClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the BuildClient.""" resource_path = kwargs.pop('resource_path', 'actor-builds') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -23,7 +22,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-builds/build-object/get-build Returns: - dict, optional: The retrieved Actor build data + The retrieved Actor build data. """ return self._get() @@ -40,7 +39,7 @@ def abort(self) -> dict: https://docs.apify.com/api/v2#/reference/actor-builds/abort-build/abort-build Returns: - dict: The data of the aborted Actor build + The data of the aborted Actor build. """ return self._abort() @@ -48,11 +47,11 @@ def wait_for_finish(self, *, wait_secs: int | None = None) -> dict | None: """Wait synchronously until the build finishes or the server times out. Args: - wait_secs (int, optional): how long does the client wait for build to finish. None for indefinite. + wait_secs: How long does the client wait for build to finish. None for indefinite. Returns: - dict, optional: The Actor build data. If the status on the object is not one of the terminal statuses - (SUCEEDED, FAILED, TIMED_OUT, ABORTED), then the build has not yet finished. + The Actor build data. If the status on the object is not one of the terminal statuses (SUCEEDED, FAILED, + TIMED_OUT, ABORTED), then the build has not yet finished. """ return self._wait_for_finish(wait_secs=wait_secs) @@ -62,7 +61,7 @@ def log(self) -> LogClient: https://docs.apify.com/api/v2/#/reference/actor-builds/build-log/get-log Returns: - LogClient: A client allowing access to the log of this Actor build. + A client allowing access to the log of this Actor build. """ return LogClient( **self._sub_resource_init_options(resource_path='log'), @@ -74,7 +73,6 @@ class BuildClientAsync(ActorJobBaseClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the BuildClientAsync.""" resource_path = kwargs.pop('resource_path', 'actor-builds') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -84,7 +82,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-builds/build-object/get-build Returns: - dict, optional: The retrieved Actor build data + The retrieved Actor build data. """ return await self._get() @@ -94,7 +92,7 @@ async def abort(self) -> dict: https://docs.apify.com/api/v2#/reference/actor-builds/abort-build/abort-build Returns: - dict: The data of the aborted Actor build + The data of the aborted Actor build. """ return await self._abort() @@ -109,11 +107,11 @@ async def wait_for_finish(self, *, wait_secs: int | None = None) -> dict | None: """Wait synchronously until the build finishes or the server times out. Args: - wait_secs (int, optional): how long does the client wait for build to finish. None for indefinite. + wait_secs: How long does the client wait for build to finish. None for indefinite. Returns: - dict, optional: The Actor build data. If the status on the object is not one of the terminal statuses - (SUCEEDED, FAILED, TIMED_OUT, ABORTED), then the build has not yet finished. + The Actor build data. If the status on the object is not one of the terminal statuses (SUCEEDED, FAILED, + TIMED_OUT, ABORTED), then the build has not yet finished. """ return await self._wait_for_finish(wait_secs=wait_secs) @@ -123,7 +121,7 @@ def log(self) -> LogClientAsync: https://docs.apify.com/api/v2/#/reference/actor-builds/build-log/get-log Returns: - LogClientAsync: A client allowing access to the log of this Actor build. + A client allowing access to the log of this Actor build. """ return LogClientAsync( **self._sub_resource_init_options(resource_path='log'), diff --git a/src/apify_client/clients/resource_clients/build_collection.py b/src/apify_client/clients/resource_clients/build_collection.py index fd78ceb5..bf42af26 100644 --- a/src/apify_client/clients/resource_clients/build_collection.py +++ b/src/apify_client/clients/resource_clients/build_collection.py @@ -15,7 +15,6 @@ class BuildCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the BuildCollectionClient.""" resource_path = kwargs.pop('resource_path', 'actor-builds') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -26,18 +25,21 @@ def list( offset: int | None = None, desc: bool | None = None, ) -> ListPage[dict]: - """List all Actor builds (either of a single Actor, or all user's Actors, depending on where this client was initialized from). + """List all Actor builds. + + List all Actor builds, either of a single Actor, or all user's Actors, depending on where this client + was initialized from. https://docs.apify.com/api/v2#/reference/actors/build-collection/get-list-of-builds https://docs.apify.com/api/v2#/reference/actor-builds/build-collection/get-user-builds-list Args: - limit (int, optional): How many builds to retrieve - offset (int, optional): What build to include as first when retrieving the list - desc (bool, optional): Whether to sort the builds in descending order based on their start date + limit: How many builds to retrieve. + offset: What build to include as first when retrieving the list. + desc: Whether to sort the builds in descending order based on their start date. Returns: - ListPage: The retrieved Actor builds + The retrieved Actor builds. """ return self._list(limit=limit, offset=offset, desc=desc) @@ -47,7 +49,6 @@ class BuildCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the BuildCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'actor-builds') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -58,17 +59,20 @@ async def list( offset: int | None = None, desc: bool | None = None, ) -> ListPage[dict]: - """List all Actor builds (either of a single Actor, or all user's Actors, depending on where this client was initialized from). + """List all Actor builds. + + List all Actor builds, either of a single Actor, or all user's Actors, depending on where this client + was initialized from. https://docs.apify.com/api/v2#/reference/actors/build-collection/get-list-of-builds https://docs.apify.com/api/v2#/reference/actor-builds/build-collection/get-user-builds-list Args: - limit (int, optional): How many builds to retrieve - offset (int, optional): What build to include as first when retrieving the list - desc (bool, optional): Whether to sort the builds in descending order based on their start date + limit: How many builds to retrieve. + offset: What build to include as first when retrieving the list. + desc: Whether to sort the builds in descending order based on their start date. Returns: - ListPage: The retrieved Actor builds + The retrieved Actor builds. """ return await self._list(limit=limit, offset=offset, desc=desc) diff --git a/src/apify_client/clients/resource_clients/dataset.py b/src/apify_client/clients/resource_clients/dataset.py index 3a41d32c..b54d0423 100644 --- a/src/apify_client/clients/resource_clients/dataset.py +++ b/src/apify_client/clients/resource_clients/dataset.py @@ -21,7 +21,6 @@ class DatasetClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the DatasetClient.""" resource_path = kwargs.pop('resource_path', 'datasets') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -31,7 +30,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/datasets/dataset/get-dataset Returns: - dict, optional: The retrieved dataset, or None, if it does not exist + The retrieved dataset, or None, if it does not exist. """ return self._get() @@ -41,14 +40,12 @@ def update(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/datasets/dataset/update-dataset Args: - name (str, optional): The new name for the dataset + name: The new name for the dataset. Returns: - dict: The updated dataset + The updated dataset. """ - updated_fields = { - 'name': name, - } + updated_fields = {'name': name} return self._update(filter_out_none_values_recursively(updated_fields)) @@ -81,32 +78,34 @@ def list_items( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. - You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - flatten (list of str, optional): A list of fields that should be flattened - view (str, optional): Name of the dataset view to be used + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + fields: A list of fields which should be picked from the items, only these fields will remain + in the resulting record objects. Note that the fields in the outputted items are sorted the same + way as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + flatten: A list of fields that should be flattened. + view: Name of the dataset view to be used. Returns: - ListPage: A page of the list of dataset items according to the specified filters. + A page of the list of dataset items according to the specified filters. """ request_params = self._params( offset=offset, @@ -135,8 +134,12 @@ def list_items( 'items': data, 'total': int(response.headers['x-apify-pagination-total']), 'offset': int(response.headers['x-apify-pagination-offset']), - 'count': len(data), # because x-apify-pagination-count returns invalid values when hidden/empty items are skipped - 'limit': int(response.headers['x-apify-pagination-limit']), # API returns 999999999999 when no limit is used + 'count': len( + data + ), # because x-apify-pagination-count returns invalid values when hidden/empty items are skipped + 'limit': int( + response.headers['x-apify-pagination-limit'] + ), # API returns 999999999999 when no limit is used 'desc': bool(response.headers['x-apify-pagination-desc']), } ) @@ -161,30 +164,32 @@ def iterate_items( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. - You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + fields: A list of fields which should be picked from the items, only these fields will remain in + the resulting record objects. Note that the fields in the outputted items are sorted the same way + as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. Yields: - dict: An item from the dataset + An item from the dataset. """ cache_size = 1000 @@ -245,46 +250,50 @@ def download_items( ) -> bytes: """Get the items in the dataset as raw bytes. - Deprecated: this function is a deprecated alias of `get_items_as_bytes`. It will be removed in a future version. + Deprecated: this function is a deprecated alias of `get_items_as_bytes`. It will be removed in + a future version. https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - item_format (str): Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. The default value is json. - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - bom (bool, optional): All text responses are encoded in UTF-8 encoding. - By default, csv files are prefixed with the UTF-8 Byte Order Mark (BOM), - while json, jsonl, xml, html and rss files are not. If you want to override this default behavior, - specify bom=True query parameter to include the BOM or bom=False to skip it. - delimiter (str, optional): A delimiter character for CSV files. The default delimiter is a simple comma (,). - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. - You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_header_row (bool, optional): If True, then header row in the csv format is skipped. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - xml_root (str, optional): Overrides default root element name of xml output. By default the root element is items. - xml_row (str, optional): Overrides default element name that wraps each page or page function result object in xml output. + item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. + The default value is json. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + bom: All text responses are encoded in UTF-8 encoding. By default, csv files are prefixed with + the UTF-8 Byte Order Mark (BOM), while json, jsonl, xml, html and rss files are not. If you want + to override this default behavior, specify bom=True query parameter to include the BOM or bom=False + to skip it. + delimiter: A delimiter character for CSV files. The default delimiter is a simple comma (,). + fields: A list of fields which should be picked from the items, only these fields will remain in + the resulting record objects. Note that the fields in the outputted items are sorted the same way + as they are specified in the fields parameter. You can use this feature to effectively fix the + output format. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_header_row: If True, then header row in the csv format is skipped. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + xml_root: Overrides default root element name of xml output. By default the root element is items. + xml_row: Overrides default element name that wraps each page or page function result object in xml output. By default the element name is item. - flatten (list of str, optional): A list of fields that should be flattened + flatten: A list of fields that should be flattened. Returns: - bytes: The dataset items as raw bytes + The dataset items as raw bytes. """ warnings.warn( '`DatasetClient.download_items()` is deprecated, use `DatasetClient.get_items_as_bytes()` instead.', @@ -338,41 +347,45 @@ def get_items_as_bytes( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - item_format (str): Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. The default value is json. - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - bom (bool, optional): All text responses are encoded in UTF-8 encoding. - By default, csv files are prefixed with the UTF-8 Byte Order Mark (BOM), - while json, jsonl, xml, html and rss files are not. If you want to override this default behavior, - specify bom=True query parameter to include the BOM or bom=False to skip it. - delimiter (str, optional): A delimiter character for CSV files. The default delimiter is a simple comma (,). - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. + item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. + The default value is json. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + bom: All text responses are encoded in UTF-8 encoding. By default, csv files are prefixed with + the UTF-8 Byte Order Mark (BOM), while json, jsonl, xml, html and rss files are not. If you want + to override this default behavior, specify bom=True query parameter to include the BOM or bom=False + to skip it. + delimiter: A delimiter character for CSV files. The default delimiter is a simple comma (,). + fields: A list of fields which should be picked from the items, only these fields will remain + in the resulting record objects. Note that the fields in the outputted items are sorted the same + way as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_header_row (bool, optional): If True, then header row in the csv format is skipped. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - xml_root (str, optional): Overrides default root element name of xml output. By default the root element is items. - xml_row (str, optional): Overrides default element name that wraps each page or page function result object in xml output. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_header_row: If True, then header row in the csv format is skipped. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + xml_root: Overrides default root element name of xml output. By default the root element is items. + xml_row: Overrides default element name that wraps each page or page function result object in xml output. By default the element name is item. - flatten (list of str, optional): A list of fields that should be flattened + flatten: A list of fields that should be flattened. Returns: - bytes: The dataset items as raw bytes + The dataset items as raw bytes. """ request_params = self._params( format=item_format, @@ -429,40 +442,44 @@ def stream_items( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - item_format (str): Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. The default value is json. - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - bom (bool, optional): All text responses are encoded in UTF-8 encoding. - By default, csv files are prefixed with the UTF-8 Byte Order Mark (BOM), - while json, jsonl, xml, html and rss files are not. If you want to override this default behavior, - specify bom=True query parameter to include the BOM or bom=False to skip it. - delimiter (str, optional): A delimiter character for CSV files. The default delimiter is a simple comma (,). - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. + item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. + The default value is json. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + bom: All text responses are encoded in UTF-8 encoding. By default, csv files are prefixed with + the UTF-8 Byte Order Mark (BOM), while json, jsonl, xml, html and rss files are not. If you want + to override this default behavior, specify bom=True query parameter to include the BOM or bom=False + to skip it. + delimiter: A delimiter character for CSV files. The default delimiter is a simple comma (,). + fields: A list of fields which should be picked from the items, only these fields will remain + in the resulting record objects. Note that the fields in the outputted items are sorted the same + way as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_header_row (bool, optional): If True, then header row in the csv format is skipped. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - xml_root (str, optional): Overrides default root element name of xml output. By default the root element is items. - xml_row (str, optional): Overrides default element name that wraps each page or page function result object in xml output. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_header_row: If True, then header row in the csv format is skipped. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + xml_root: Overrides default root element name of xml output. By default the root element is items. + xml_row: Overrides default element name that wraps each page or page function result object in xml output. By default the element name is item. Returns: - httpx.Response: The dataset items as a context-managed streaming Response + The dataset items as a context-managed streaming `Response`. """ response = None try: @@ -502,7 +519,8 @@ def push_items(self, items: JSONSerializable) -> None: https://docs.apify.com/api/v2#/reference/datasets/item-collection/put-items Args: - items: The items which to push in the dataset. Either a stringified JSON, a dictionary, or a list of strings or dictionaries. + items: The items which to push in the dataset. Either a stringified JSON, a dictionary, or a list + of strings or dictionaries. """ data = None json = None @@ -527,7 +545,6 @@ class DatasetClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the DatasetClientAsync.""" resource_path = kwargs.pop('resource_path', 'datasets') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -537,7 +554,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/datasets/dataset/get-dataset Returns: - dict, optional: The retrieved dataset, or None, if it does not exist + The retrieved dataset, or None, if it does not exist. """ return await self._get() @@ -547,14 +564,12 @@ async def update(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/datasets/dataset/update-dataset Args: - name (str, optional): The new name for the dataset + name: The new name for the dataset. Returns: - dict: The updated dataset + The updated dataset. """ - updated_fields = { - 'name': name, - } + updated_fields = {'name': name} return await self._update(filter_out_none_values_recursively(updated_fields)) @@ -587,32 +602,34 @@ async def list_items( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. - You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - flatten (list of str, optional): A list of fields that should be flattened - view (str, optional): Name of the dataset view to be used + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + fields: A list of fields which should be picked from the items, only these fields will remain + in the resulting record objects. Note that the fields in the outputted items are sorted the same + way as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + flatten: A list of fields that should be flattened. + view: Name of the dataset view to be used. Returns: - ListPage: A page of the list of dataset items according to the specified filters. + A page of the list of dataset items according to the specified filters. """ request_params = self._params( offset=offset, @@ -641,8 +658,12 @@ async def list_items( 'items': data, 'total': int(response.headers['x-apify-pagination-total']), 'offset': int(response.headers['x-apify-pagination-offset']), - 'count': len(data), # because x-apify-pagination-count returns invalid values when hidden/empty items are skipped - 'limit': int(response.headers['x-apify-pagination-limit']), # API returns 999999999999 when no limit is used + 'count': len( + data + ), # because x-apify-pagination-count returns invalid values when hidden/empty items are skipped + 'limit': int( + response.headers['x-apify-pagination-limit'] + ), # API returns 999999999999 when no limit is used 'desc': bool(response.headers['x-apify-pagination-desc']), } ) @@ -667,30 +688,32 @@ async def iterate_items( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. - You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + fields: A list of fields which should be picked from the items, only these fields will remain in + the resulting record objects. Note that the fields in the outputted items are sorted the same way + as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. Yields: - dict: An item from the dataset + An item from the dataset. """ cache_size = 1000 @@ -755,41 +778,45 @@ async def get_items_as_bytes( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - item_format (str): Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. The default value is json. - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - bom (bool, optional): All text responses are encoded in UTF-8 encoding. - By default, csv files are prefixed with the UTF-8 Byte Order Mark (BOM), - while json, jsonl, xml, html and rss files are not. If you want to override this default behavior, - specify bom=True query parameter to include the BOM or bom=False to skip it. - delimiter (str, optional): A delimiter character for CSV files. The default delimiter is a simple comma (,). - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. + item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. + The default value is json. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + bom: All text responses are encoded in UTF-8 encoding. By default, csv files are prefixed with + the UTF-8 Byte Order Mark (BOM), while json, jsonl, xml, html and rss files are not. If you want + to override this default behavior, specify bom=True query parameter to include the BOM or bom=False + to skip it. + delimiter: A delimiter character for CSV files. The default delimiter is a simple comma (,). + fields: A list of fields which should be picked from the items, only these fields will remain + in the resulting record objects. Note that the fields in the outputted items are sorted the same + way as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_header_row (bool, optional): If True, then header row in the csv format is skipped. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - xml_root (str, optional): Overrides default root element name of xml output. By default the root element is items. - xml_row (str, optional): Overrides default element name that wraps each page or page function result object in xml output. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_header_row: If True, then header row in the csv format is skipped. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + xml_root: Overrides default root element name of xml output. By default the root element is items. + xml_row: Overrides default element name that wraps each page or page function result object in xml output. By default the element name is item. - flatten (list of str, optional): A list of fields that should be flattened + flatten: A list of fields that should be flattened. Returns: - bytes: The dataset items as raw bytes + The dataset items as raw bytes. """ request_params = self._params( format=item_format, @@ -846,40 +873,44 @@ async def stream_items( https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items Args: - item_format (str): Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. The default value is json. - offset (int, optional): Number of items that should be skipped at the start. The default value is 0 - limit (int, optional): Maximum number of items to return. By default there is no limit. - desc (bool, optional): By default, results are returned in the same order as they were stored. - To reverse the order, set this parameter to True. - clean (bool, optional): If True, returns only non-empty items and skips hidden fields (i.e. fields starting with the # character). - The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True parameters. - Note that since some objects might be skipped from the output, that the result might contain less items than the limit value. - bom (bool, optional): All text responses are encoded in UTF-8 encoding. - By default, csv files are prefixed with the UTF-8 Byte Order Mark (BOM), - while json, jsonl, xml, html and rss files are not. If you want to override this default behavior, - specify bom=True query parameter to include the BOM or bom=False to skip it. - delimiter (str, optional): A delimiter character for CSV files. The default delimiter is a simple comma (,). - fields (list of str, optional): A list of fields which should be picked from the items, - only these fields will remain in the resulting record objects. - Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter. + item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss. + The default value is json. + offset: Number of items that should be skipped at the start. The default value is 0. + limit: Maximum number of items to return. By default there is no limit. + desc: By default, results are returned in the same order as they were stored. To reverse the order, + set this parameter to True. + clean: If True, returns only non-empty items and skips hidden fields (i.e. fields starting with + the # character). The clean parameter is just a shortcut for skip_hidden=True and skip_empty=True + parameters. Note that since some objects might be skipped from the output, that the result might + contain less items than the limit value. + bom: All text responses are encoded in UTF-8 encoding. By default, csv files are prefixed with + the UTF-8 Byte Order Mark (BOM), while json, jsonl, xml, html and rss files are not. If you want + to override this default behavior, specify bom=True query parameter to include the BOM or bom=False + to skip it. + delimiter: A delimiter character for CSV files. The default delimiter is a simple comma (,). + fields: A list of fields which should be picked from the items, only these fields will remain + in the resulting record objects. Note that the fields in the outputted items are sorted the same + way as they are specified in the fields parameter. You can use this feature to effectively fix + the output format. You can use this feature to effectively fix the output format. - omit (list of str, optional): A list of fields which should be omitted from the items. - unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed. - Each field should be either an array or an object. - If the field is an array then every element of the array will become a separate record and merged with parent object. - If the unwound field is an object then it is merged with the parent object. - If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object, - then the item gets preserved as it is. Note that the unwound items ignore the desc parameter. - skip_empty (bool, optional): If True, then empty items are skipped from the output. - Note that if used, the results might contain less items than the limit value. - skip_header_row (bool, optional): If True, then header row in the csv format is skipped. - skip_hidden (bool, optional): If True, then hidden fields are skipped from the output, i.e. fields starting with the # character. - xml_root (str, optional): Overrides default root element name of xml output. By default the root element is items. - xml_row (str, optional): Overrides default element name that wraps each page or page function result object in xml output. + omit: A list of fields which should be omitted from the items. + unwind: A list of fields which should be unwound, in order which they should be processed. Each field + should be either an array or an object. If the field is an array then every element of the array + will become a separate record and merged with parent object. If the unwound field is an object then + it is merged with the parent object. If the unwound field is missing or its value is neither an array + nor an object and therefore cannot be merged with a parent object, then the item gets preserved + as it is. Note that the unwound items ignore the desc parameter. + skip_empty: If True, then empty items are skipped from the output. Note that if used, the results might + contain less items than the limit value. + skip_header_row: If True, then header row in the csv format is skipped. + skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with + the # character. + xml_root: Overrides default root element name of xml output. By default the root element is items. + xml_row: Overrides default element name that wraps each page or page function result object in xml output. By default the element name is item. Returns: - httpx.Response: The dataset items as a context-managed streaming Response + The dataset items as a context-managed streaming `Response`. """ response = None try: @@ -919,7 +950,8 @@ async def push_items(self, items: JSONSerializable) -> None: https://docs.apify.com/api/v2#/reference/datasets/item-collection/put-items Args: - items: The items which to push in the dataset. Either a stringified JSON, a dictionary, or a list of strings or dictionaries. + items: The items which to push in the dataset. Either a stringified JSON, a dictionary, or a list + of strings or dictionaries. """ data = None json = None diff --git a/src/apify_client/clients/resource_clients/dataset_collection.py b/src/apify_client/clients/resource_clients/dataset_collection.py index c1de6c39..3aa1658f 100644 --- a/src/apify_client/clients/resource_clients/dataset_collection.py +++ b/src/apify_client/clients/resource_clients/dataset_collection.py @@ -15,7 +15,6 @@ class DatasetCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the DatasetCollectionClient with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'datasets') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -32,13 +31,13 @@ def list( https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/get-list-of-datasets Args: - unnamed (bool, optional): Whether to include unnamed datasets in the list - limit (int, optional): How many datasets to retrieve - offset (int, optional): What dataset to include as first when retrieving the list - desc (bool, optional): Whether to sort the datasets in descending order based on their modification date + unnamed: Whether to include unnamed datasets in the list. + limit: How many datasets to retrieve. + offset: What dataset to include as first when retrieving the list. + desc: Whether to sort the datasets in descending order based on their modification date. Returns: - ListPage: The list of available datasets matching the specified filters. + The list of available datasets matching the specified filters. """ return self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc) @@ -48,11 +47,11 @@ def get_or_create(self, *, name: str | None = None, schema: dict | None = None) https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/create-dataset Args: - name (str, optional): The name of the dataset to retrieve or create. - schema (dict, optional): The schema of the dataset + name: The name of the dataset to retrieve or create. + schema: The schema of the dataset. Returns: - dict: The retrieved or newly-created dataset. + The retrieved or newly-created dataset. """ return self._get_or_create(name=name, resource=filter_out_none_values_recursively({'schema': schema})) @@ -62,7 +61,6 @@ class DatasetCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the DatasetCollectionClientAsync with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'datasets') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -79,13 +77,13 @@ async def list( https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/get-list-of-datasets Args: - unnamed (bool, optional): Whether to include unnamed datasets in the list - limit (int, optional): How many datasets to retrieve - offset (int, optional): What dataset to include as first when retrieving the list - desc (bool, optional): Whether to sort the datasets in descending order based on their modification date + unnamed: Whether to include unnamed datasets in the list. + limit: How many datasets to retrieve. + offset: What dataset to include as first when retrieving the list. + desc: Whether to sort the datasets in descending order based on their modification date. Returns: - ListPage: The list of available datasets matching the specified filters. + The list of available datasets matching the specified filters. """ return await self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc) @@ -100,10 +98,10 @@ async def get_or_create( https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/create-dataset Args: - name (str, optional): The name of the dataset to retrieve or create. - schema (dict, optional): The schema of the dataset + name: The name of the dataset to retrieve or create. + schema: The schema of the dataset. Returns: - dict: The retrieved or newly-created dataset. + The retrieved or newly-created dataset. """ return await self._get_or_create(name=name, resource=filter_out_none_values_recursively({'schema': schema})) diff --git a/src/apify_client/clients/resource_clients/key_value_store.py b/src/apify_client/clients/resource_clients/key_value_store.py index f8c7473a..22796882 100644 --- a/src/apify_client/clients/resource_clients/key_value_store.py +++ b/src/apify_client/clients/resource_clients/key_value_store.py @@ -19,7 +19,6 @@ class KeyValueStoreClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the KeyValueStoreClient.""" resource_path = kwargs.pop('resource_path', 'key-value-stores') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -29,7 +28,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/get-store Returns: - dict, optional: The retrieved key-value store, or None if it does not exist + The retrieved key-value store, or None if it does not exist. """ return self._get() @@ -39,10 +38,10 @@ def update(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/update-store Args: - name (str, optional): The new name for key-value store + name: The new name for key-value store. Returns: - dict: The updated key-value store + The updated key-value store. """ updated_fields = { 'name': name, @@ -63,11 +62,11 @@ def list_keys(self, *, limit: int | None = None, exclusive_start_key: str | None https://docs.apify.com/api/v2#/reference/key-value-stores/key-collection/get-list-of-keys Args: - limit (int, optional): Number of keys to be returned. Maximum value is 1000 - exclusive_start_key (str, optional): All keys up to this one (including) are skipped from the result + limit: Number of keys to be returned. Maximum value is 1000. + exclusive_start_key: All keys up to this one (including) are skipped from the result. Returns: - dict: The list of keys in the key-value store matching the given arguments + The list of keys in the key-value store matching the given arguments. """ request_params = self._params(limit=limit, exclusiveStartKey=exclusive_start_key) @@ -85,12 +84,14 @@ def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record Args: - key (str): Key of the record to retrieve - as_bytes (bool, optional): Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes, default False - as_file (bool, optional): Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object, default False + key: Key of the record to retrieve. + as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes, + default False. + as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object, + default False. Returns: - dict, optional: The requested record, or None, if the record does not exist + The requested record, or None, if the record does not exist. """ try: if as_bytes and as_file: @@ -98,7 +99,8 @@ def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) if as_bytes: warnings.warn( - '`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, use `KeyValueStoreClient.get_record_as_bytes()` instead.', + '`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, ' + 'use `KeyValueStoreClient.get_record_as_bytes()` instead.', DeprecationWarning, stacklevel=2, ) @@ -106,7 +108,8 @@ def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) if as_file: warnings.warn( - '`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, use `KeyValueStoreClient.stream_record()` instead.', + '`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, ' + 'use `KeyValueStoreClient.stream_record()` instead.', DeprecationWarning, stacklevel=2, ) @@ -135,10 +138,10 @@ def get_record_as_bytes(self, key: str) -> dict | None: https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record Args: - key (str): Key of the record to retrieve + key: Key of the record to retrieve. Returns: - dict, optional: The requested record, or None, if the record does not exist + The requested record, or None, if the record does not exist. """ try: response = self.http_client.call( @@ -166,10 +169,10 @@ def stream_record(self, key: str) -> Iterator[dict | None]: https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record Args: - key (str): Key of the record to retrieve + key: Key of the record to retrieve. Returns: - dict, optional: The requested record as a context-managed streaming Response, or None, if the record does not exist + The requested record as a context-managed streaming Response, or None, if the record does not exist. """ response = None try: @@ -205,9 +208,9 @@ def set_record( https://docs.apify.com/api/v2#/reference/key-value-stores/record/put-record Args: - key (str): The key of the record to save the value to - value (Any): The value to save into the record - content_type (str, optional): The content type of the saved value + key: The key of the record to save the value to. + value: The value to save into the record. + content_type: The content type of the saved value. """ value, content_type = encode_key_value_store_record_value(value, content_type) @@ -227,7 +230,7 @@ def delete_record(self, key: str) -> None: https://docs.apify.com/api/v2#/reference/key-value-stores/record/delete-record Args: - key (str): The key of the record which to delete + key: The key of the record which to delete. """ self.http_client.call( url=self._url(f'records/{key}'), @@ -241,7 +244,6 @@ class KeyValueStoreClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the KeyValueStoreClientAsync.""" resource_path = kwargs.pop('resource_path', 'key-value-stores') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -251,7 +253,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/get-store Returns: - dict, optional: The retrieved key-value store, or None if it does not exist + The retrieved key-value store, or None if it does not exist. """ return await self._get() @@ -261,10 +263,10 @@ async def update(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/update-store Args: - name (str, optional): The new name for key-value store + name: The new name for key-value store. Returns: - dict: The updated key-value store + The updated key-value store. """ updated_fields = { 'name': name, @@ -285,11 +287,11 @@ async def list_keys(self, *, limit: int | None = None, exclusive_start_key: str https://docs.apify.com/api/v2#/reference/key-value-stores/key-collection/get-list-of-keys Args: - limit (int, optional): Number of keys to be returned. Maximum value is 1000 - exclusive_start_key (str, optional): All keys up to this one (including) are skipped from the result + limit: Number of keys to be returned. Maximum value is 1000. + exclusive_start_key: All keys up to this one (including) are skipped from the result. Returns: - dict: The list of keys in the key-value store matching the given arguments + The list of keys in the key-value store matching the given arguments. """ request_params = self._params(limit=limit, exclusiveStartKey=exclusive_start_key) @@ -307,12 +309,14 @@ async def get_record(self, key: str) -> dict | None: https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record Args: - key (str): Key of the record to retrieve - as_bytes (bool, optional): Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes, default False - as_file (bool, optional): Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object, default False + key: Key of the record to retrieve. + as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes, + default False. + as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object, + default False. Returns: - dict, optional: The requested record, or None, if the record does not exist + The requested record, or None, if the record does not exist. """ try: response = await self.http_client.call( @@ -338,10 +342,10 @@ async def get_record_as_bytes(self, key: str) -> dict | None: https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record Args: - key (str): Key of the record to retrieve + key: Key of the record to retrieve. Returns: - dict, optional: The requested record, or None, if the record does not exist + The requested record, or None, if the record does not exist. """ try: response = await self.http_client.call( @@ -369,10 +373,10 @@ async def stream_record(self, key: str) -> AsyncIterator[dict | None]: https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record Args: - key (str): Key of the record to retrieve + key: Key of the record to retrieve. Returns: - dict, optional: The requested record as a context-managed streaming Response, or None, if the record does not exist + The requested record as a context-managed streaming Response, or None, if the record does not exist. """ response = None try: @@ -408,9 +412,9 @@ async def set_record( https://docs.apify.com/api/v2#/reference/key-value-stores/record/put-record Args: - key (str): The key of the record to save the value to - value (Any): The value to save into the record - content_type (str, optional): The content type of the saved value + key: The key of the record to save the value to. + value: The value to save into the record. + content_type: The content type of the saved value. """ value, content_type = encode_key_value_store_record_value(value, content_type) @@ -430,7 +434,7 @@ async def delete_record(self, key: str) -> None: https://docs.apify.com/api/v2#/reference/key-value-stores/record/delete-record Args: - key (str): The key of the record which to delete + key: The key of the record which to delete. """ await self.http_client.call( url=self._url(f'records/{key}'), 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 29190980..95277682 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 @@ -15,7 +15,6 @@ class KeyValueStoreCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the KeyValueStoreCollectionClient with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'key-value-stores') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -32,13 +31,13 @@ def list( https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/get-list-of-key-value-stores Args: - unnamed (bool, optional): Whether to include unnamed key-value stores in the list - limit (int, optional): How many key-value stores to retrieve - offset (int, optional): What key-value store to include as first when retrieving the list - desc (bool, optional): Whether to sort the key-value stores in descending order based on their modification date + unnamed: Whether to include unnamed key-value stores in the list. + limit: How many key-value stores to retrieve. + offset: What key-value store to include as first when retrieving the list. + desc: Whether to sort the key-value stores in descending order based on their modification date. Returns: - ListPage: The list of available key-value stores matching the specified filters. + The list of available key-value stores matching the specified filters. """ return self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc) @@ -53,11 +52,11 @@ def get_or_create( https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/create-key-value-store Args: - name (str, optional): The name of the key-value store to retrieve or create. - schema (dict, optional): The schema of the key-value store + name: The name of the key-value store to retrieve or create. + schema: The schema of the key-value store. Returns: - dict: The retrieved or newly-created key-value store. + The retrieved or newly-created key-value store. """ return self._get_or_create(name=name, resource=filter_out_none_values_recursively({'schema': schema})) @@ -67,7 +66,6 @@ class KeyValueStoreCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the KeyValueStoreCollectionClientAsync with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'key-value-stores') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -84,13 +82,13 @@ async def list( https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/get-list-of-key-value-stores Args: - unnamed (bool, optional): Whether to include unnamed key-value stores in the list - limit (int, optional): How many key-value stores to retrieve - offset (int, optional): What key-value store to include as first when retrieving the list - desc (bool, optional): Whether to sort the key-value stores in descending order based on their modification date + unnamed: Whether to include unnamed key-value stores in the list. + limit: How many key-value stores to retrieve. + offset: What key-value store to include as first when retrieving the list. + desc: Whether to sort the key-value stores in descending order based on their modification date. Returns: - ListPage: The list of available key-value stores matching the specified filters. + The list of available key-value stores matching the specified filters. """ return await self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc) @@ -105,10 +103,10 @@ async def get_or_create( https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/create-key-value-store Args: - name (str, optional): The name of the key-value store to retrieve or create. - schema (dict, optional): The schema of the key-value store + name: The name of the key-value store to retrieve or create. + schema: The schema of the key-value store. Returns: - dict: The retrieved or newly-created key-value store. + The retrieved or newly-created key-value store. """ return await self._get_or_create(name=name, resource=filter_out_none_values_recursively({'schema': schema})) diff --git a/src/apify_client/clients/resource_clients/log.py b/src/apify_client/clients/resource_clients/log.py index 96034bf2..62883634 100644 --- a/src/apify_client/clients/resource_clients/log.py +++ b/src/apify_client/clients/resource_clients/log.py @@ -20,7 +20,6 @@ class LogClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the LogClient.""" resource_path = kwargs.pop('resource_path', 'logs') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -30,7 +29,7 @@ def get(self) -> str | None: https://docs.apify.com/api/v2#/reference/logs/log/get-log Returns: - str, optional: The retrieved log, or None, if it does not exist. + The retrieved log, or None, if it does not exist. """ try: response = self.http_client.call( @@ -52,7 +51,7 @@ def get_as_bytes(self) -> bytes | None: https://docs.apify.com/api/v2#/reference/logs/log/get-log Returns: - bytes, optional: The retrieved log as raw bytes, or None, if it does not exist. + The retrieved log as raw bytes, or None, if it does not exist. """ try: response = self.http_client.call( @@ -76,7 +75,7 @@ def stream(self) -> Iterator[httpx.Response | None]: https://docs.apify.com/api/v2#/reference/logs/log/get-log Returns: - httpx.Response, optional: The retrieved log as a context-managed streaming Response, or None, if it does not exist. + The retrieved log as a context-managed streaming `Response`, or None, if it does not exist. """ response = None try: @@ -102,7 +101,6 @@ class LogClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the LogClientAsync.""" resource_path = kwargs.pop('resource_path', 'logs') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -112,7 +110,7 @@ async def get(self) -> str | None: https://docs.apify.com/api/v2#/reference/logs/log/get-log Returns: - str, optional: The retrieved log, or None, if it does not exist. + The retrieved log, or None, if it does not exist. """ try: response = await self.http_client.call( @@ -134,7 +132,7 @@ async def get_as_bytes(self) -> bytes | None: https://docs.apify.com/api/v2#/reference/logs/log/get-log Returns: - bytes, optional: The retrieved log as raw bytes, or None, if it does not exist. + The retrieved log as raw bytes, or None, if it does not exist. """ try: response = await self.http_client.call( @@ -158,7 +156,7 @@ async def stream(self) -> AsyncIterator[httpx.Response | None]: https://docs.apify.com/api/v2#/reference/logs/log/get-log Returns: - httpx.Response, optional: The retrieved log as a context-managed streaming Response, or None, if it does not exist. + The retrieved log as a context-managed streaming `Response`, or None, if it does not exist. """ response = None try: diff --git a/src/apify_client/clients/resource_clients/request_queue.py b/src/apify_client/clients/resource_clients/request_queue.py index 98311cf4..38fdc3b9 100644 --- a/src/apify_client/clients/resource_clients/request_queue.py +++ b/src/apify_client/clients/resource_clients/request_queue.py @@ -61,10 +61,10 @@ def __init__( # noqa: D417 client_key: str | None = None, **kwargs: Any, ) -> None: - """Initialize the RequestQueueClient. + """A default constructor. Args: - client_key (str, optional): A unique identifier of the client accessing the request queue + client_key: A unique identifier of the client accessing the request queue. """ resource_path = kwargs.pop('resource_path', 'request-queues') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -76,7 +76,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/request-queues/queue/get-request-queue Returns: - dict, optional: The retrieved request queue, or None, if it does not exist + The retrieved request queue, or None, if it does not exist. """ return self._get() @@ -86,10 +86,10 @@ def update(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/queue/update-request-queue Args: - name (str, optional): The new name for the request queue + name: The new name for the request queue. Returns: - dict: The updated request queue + The updated request queue. """ updated_fields = { 'name': name, @@ -110,10 +110,10 @@ def list_head(self, *, limit: int | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/queue-head/get-head Args: - limit (int, optional): How many requests to retrieve + limit: How many requests to retrieve. Returns: - dict: The desired number of requests from the beginning of the queue. + The desired number of requests from the beginning of the queue. """ request_params = self._params(limit=limit, clientKey=self.client_key) @@ -131,12 +131,11 @@ def list_and_lock_head(self, *, lock_secs: int, limit: int | None = None) -> dic https://docs.apify.com/api/v2#/reference/request-queues/queue-head-with-locks/get-head-and-lock Args: - lock_secs (int): How long the requests will be locked for, in seconds - limit (int, optional): How many requests to retrieve - + lock_secs: How long the requests will be locked for, in seconds. + limit: How many requests to retrieve. Returns: - dict: The desired number of locked requests from the beginning of the queue. + The desired number of locked requests from the beginning of the queue. """ request_params = self._params(lockSecs=lock_secs, limit=limit, clientKey=self.client_key) @@ -154,11 +153,11 @@ def add_request(self, request: dict, *, forefront: bool | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/request-collection/add-request Args: - request (dict): The request to add to the queue - forefront (bool, optional): Whether to add the request to the head or the end of the queue + request: The request to add to the queue. + forefront: Whether to add the request to the head or the end of the queue. Returns: - dict: The added request. + The added request. """ request_params = self._params(forefront=forefront, clientKey=self.client_key) @@ -177,10 +176,10 @@ def get_request(self, request_id: str) -> dict | None: https://docs.apify.com/api/v2#/reference/request-queues/request/get-request Args: - request_id (str): ID of the request to retrieve + request_id: ID of the request to retrieve. Returns: - dict, optional: The retrieved request, or None, if it did not exist. + The retrieved request, or None, if it did not exist. """ try: response = self.http_client.call( @@ -201,11 +200,11 @@ def update_request(self, request: dict, *, forefront: bool | None = None) -> dic https://docs.apify.com/api/v2#/reference/request-queues/request/update-request Args: - request (dict): The updated request - forefront (bool, optional): Whether to put the updated request in the beginning or the end of the queue + request: The updated request. + forefront: Whether to put the updated request in the beginning or the end of the queue. Returns: - dict: The updated request + The updated request. """ request_id = request['id'] @@ -226,7 +225,7 @@ def delete_request(self, request_id: str) -> None: https://docs.apify.com/api/v2#/reference/request-queues/request/delete-request Args: - request_id (str): ID of the request to delete. + request_id: ID of the request to delete. """ request_params = self._params( clientKey=self.client_key, @@ -250,9 +249,9 @@ def prolong_request_lock( https://docs.apify.com/api/v2#/reference/request-queues/request-lock/prolong-request-lock Args: - request_id (str): ID of the request to prolong the lock - forefront (bool, optional): Whether to put the request in the beginning or the end of the queue after lock expires - lock_secs (int): By how much to prolong the lock, in seconds + request_id: ID of the request to prolong the lock. + forefront: Whether to put the request in the beginning or the end of the queue after lock expires. + lock_secs: By how much to prolong the lock, in seconds. """ request_params = self._params(clientKey=self.client_key, forefront=forefront, lockSecs=lock_secs) @@ -270,8 +269,8 @@ def delete_request_lock(self, request_id: str, *, forefront: bool | None = None) https://docs.apify.com/api/v2#/reference/request-queues/request-lock/delete-request-lock Args: - request_id (str): ID of the request to delete the lock - forefront (bool, optional): Whether to put the request in the beginning or the end of the queue after the lock is deleted + request_id: ID of the request to delete the lock. + forefront: Whether to put the request in the beginning or the end of the queue after the lock is deleted. """ request_params = self._params(clientKey=self.client_key, forefront=forefront) @@ -303,7 +302,8 @@ def batch_add_requests( to the async client. For the sync client, this value must be set to 1, as parallel execution is not supported. max_unprocessed_requests_retries: Number of retry attempts for unprocessed requests. - min_delay_between_unprocessed_requests_retries: Minimum delay between retry attempts for unprocessed requests. + min_delay_between_unprocessed_requests_retries: Minimum delay between retry attempts for unprocessed + requests. Returns: Result containing lists of processed and unprocessed requests. @@ -367,7 +367,7 @@ def batch_delete_requests(self, requests: list[dict]) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/batch-request-operations/delete-requests Args: - requests (list[dict]): list of the requests to delete + requests: List of the requests to delete. """ request_params = self._params(clientKey=self.client_key) @@ -391,8 +391,8 @@ def list_requests( https://docs.apify.com/api/v2#/reference/request-queues/request-collection/list-requests Args: - limit (int, optional): How many requests to retrieve - exclusive_start_id (str, optional): All requests up to this one (including) are skipped from the result + limit: How many requests to retrieve. + exclusive_start_id: All requests up to this one (including) are skipped from the result. """ request_params = self._params(limit=limit, exclusive_start_id=exclusive_start_id, clientKey=self.client_key) @@ -415,10 +415,10 @@ def __init__( # noqa: D417 client_key: str | None = None, **kwargs: Any, ) -> None: - """Initialize the RequestQueueClientAsync. + """A default constructor. Args: - client_key (str, optional): A unique identifier of the client accessing the request queue + client_key: A unique identifier of the client accessing the request queue. """ resource_path = kwargs.pop('resource_path', 'request-queues') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -430,7 +430,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/request-queues/queue/get-request-queue Returns: - dict, optional: The retrieved request queue, or None, if it does not exist + The retrieved request queue, or None, if it does not exist. """ return await self._get() @@ -440,10 +440,10 @@ async def update(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/queue/update-request-queue Args: - name (str, optional): The new name for the request queue + name: The new name for the request queue. Returns: - dict: The updated request queue + The updated request queue. """ updated_fields = { 'name': name, @@ -464,10 +464,10 @@ async def list_head(self, *, limit: int | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/queue-head/get-head Args: - limit (int, optional): How many requests to retrieve + limit: How many requests to retrieve. Returns: - dict: The desired number of requests from the beginning of the queue. + The desired number of requests from the beginning of the queue. """ request_params = self._params(limit=limit, clientKey=self.client_key) @@ -485,12 +485,11 @@ async def list_and_lock_head(self, *, lock_secs: int, limit: int | None = None) https://docs.apify.com/api/v2#/reference/request-queues/queue-head-with-locks/get-head-and-lock Args: - lock_secs (int): How long the requests will be locked for, in seconds - limit (int, optional): How many requests to retrieve - + lock_secs: How long the requests will be locked for, in seconds. + limit: How many requests to retrieve. Returns: - dict: The desired number of locked requests from the beginning of the queue. + The desired number of locked requests from the beginning of the queue. """ request_params = self._params(lockSecs=lock_secs, limit=limit, clientKey=self.client_key) @@ -508,11 +507,11 @@ async def add_request(self, request: dict, *, forefront: bool | None = None) -> https://docs.apify.com/api/v2#/reference/request-queues/request-collection/add-request Args: - request (dict): The request to add to the queue - forefront (bool, optional): Whether to add the request to the head or the end of the queue + request: The request to add to the queue. + forefront: Whether to add the request to the head or the end of the queue. Returns: - dict: The added request. + The added request. """ request_params = self._params(forefront=forefront, clientKey=self.client_key) @@ -531,10 +530,10 @@ async def get_request(self, request_id: str) -> dict | None: https://docs.apify.com/api/v2#/reference/request-queues/request/get-request Args: - request_id (str): ID of the request to retrieve + request_id: ID of the request to retrieve. Returns: - dict, optional: The retrieved request, or None, if it did not exist. + The retrieved request, or None, if it did not exist. """ try: response = await self.http_client.call( @@ -555,11 +554,11 @@ async def update_request(self, request: dict, *, forefront: bool | None = None) https://docs.apify.com/api/v2#/reference/request-queues/request/update-request Args: - request (dict): The updated request - forefront (bool, optional): Whether to put the updated request in the beginning or the end of the queue + request: The updated request. + forefront: Whether to put the updated request in the beginning or the end of the queue. Returns: - dict: The updated request + The updated request. """ request_id = request['id'] @@ -580,7 +579,7 @@ async def delete_request(self, request_id: str) -> None: https://docs.apify.com/api/v2#/reference/request-queues/request/delete-request Args: - request_id (str): ID of the request to delete. + request_id: ID of the request to delete. """ request_params = self._params(clientKey=self.client_key) @@ -602,9 +601,9 @@ async def prolong_request_lock( https://docs.apify.com/api/v2#/reference/request-queues/request-lock/prolong-request-lock Args: - request_id (str): ID of the request to prolong the lock - forefront (bool, optional): Whether to put the request in the beginning or the end of the queue after lock expires - lock_secs (int): By how much to prolong the lock, in seconds + request_id: ID of the request to prolong the lock. + forefront: Whether to put the request in the beginning or the end of the queue after lock expires. + lock_secs: By how much to prolong the lock, in seconds. """ request_params = self._params(clientKey=self.client_key, forefront=forefront, lockSecs=lock_secs) @@ -627,8 +626,8 @@ async def delete_request_lock( https://docs.apify.com/api/v2#/reference/request-queues/request-lock/delete-request-lock Args: - request_id (str): ID of the request to delete the lock - forefront (bool, optional): Whether to put the request in the beginning or the end of the queue after the lock is deleted + request_id: ID of the request to delete the lock. + forefront: Whether to put the request in the beginning or the end of the queue after the lock is deleted. """ request_params = self._params(clientKey=self.client_key, forefront=forefront) @@ -717,7 +716,8 @@ async def batch_add_requests( to the async client. For the sync client, this value must be set to 1, as parallel execution is not supported. max_unprocessed_requests_retries: Number of retry attempts for unprocessed requests. - min_delay_between_unprocessed_requests_retries: Minimum delay between retry attempts for unprocessed requests. + min_delay_between_unprocessed_requests_retries: Minimum delay between retry attempts for unprocessed + requests. Returns: Result containing lists of processed and unprocessed requests. @@ -778,7 +778,7 @@ async def batch_delete_requests(self, requests: list[dict]) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/batch-request-operations/delete-requests Args: - requests (list[dict]): list of the requests to delete + requests: List of the requests to delete. """ request_params = self._params(clientKey=self.client_key) @@ -801,8 +801,8 @@ async def list_requests( https://docs.apify.com/api/v2#/reference/request-queues/request-collection/list-requests Args: - limit (int, optional): How many requests to retrieve - exclusive_start_id (str, optional): All requests up to this one (including) are skipped from the result + limit: How many requests to retrieve. + exclusive_start_id: All requests up to this one (including) are skipped from the result. """ request_params = self._params(limit=limit, exclusive_start_id=exclusive_start_id, clientKey=self.client_key) 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 f5c97808..5d458568 100644 --- a/src/apify_client/clients/resource_clients/request_queue_collection.py +++ b/src/apify_client/clients/resource_clients/request_queue_collection.py @@ -15,7 +15,6 @@ class RequestQueueCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the RequestQueueCollectionClient with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'request-queues') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -32,13 +31,13 @@ def list( https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/get-list-of-request-queues Args: - unnamed (bool, optional): Whether to include unnamed request queues in the list - limit (int, optional): How many request queues to retrieve - offset (int, optional): What request queue to include as first when retrieving the list - desc (bool, optional): Whether to sort therequest queues in descending order based on their modification date + unnamed: Whether to include unnamed request queues in the list. + limit: How many request queues to retrieve. + offset: What request queue to include as first when retrieving the list. + desc: Whether to sort therequest queues in descending order based on their modification date. Returns: - ListPage: The list of available request queues matching the specified filters. + The list of available request queues matching the specified filters. """ return self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc) @@ -48,10 +47,10 @@ def get_or_create(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/create-request-queue Args: - name (str, optional): The name of the request queue to retrieve or create. + name: The name of the request queue to retrieve or create. Returns: - dict: The retrieved or newly-created request queue. + The retrieved or newly-created request queue. """ return self._get_or_create(name=name) @@ -61,7 +60,6 @@ class RequestQueueCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the RequestQueueCollectionClientAsync with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'request-queues') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -78,13 +76,13 @@ async def list( https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/get-list-of-request-queues Args: - unnamed (bool, optional): Whether to include unnamed request queues in the list - limit (int, optional): How many request queues to retrieve - offset (int, optional): What request queue to include as first when retrieving the list - desc (bool, optional): Whether to sort therequest queues in descending order based on their modification date + unnamed: Whether to include unnamed request queues in the list. + limit: How many request queues to retrieve. + offset: What request queue to include as first when retrieving the list. + desc: Whether to sort therequest queues in descending order based on their modification date. Returns: - ListPage: The list of available request queues matching the specified filters. + The list of available request queues matching the specified filters. """ return await self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc) @@ -94,9 +92,9 @@ async def get_or_create(self, *, name: str | None = None) -> dict: https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/create-request-queue Args: - name (str, optional): The name of the request queue to retrieve or create. + name: The name of the request queue to retrieve or create. Returns: - dict: The retrieved or newly-created request queue. + The retrieved or newly-created request queue. """ return await self._get_or_create(name=name) diff --git a/src/apify_client/clients/resource_clients/run.py b/src/apify_client/clients/resource_clients/run.py index 09ecbebf..91410457 100644 --- a/src/apify_client/clients/resource_clients/run.py +++ b/src/apify_client/clients/resource_clients/run.py @@ -21,7 +21,6 @@ class RunClient(ActorJobBaseClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the RunClient.""" resource_path = kwargs.pop('resource_path', 'actor-runs') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -31,7 +30,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-runs/run-object/get-run Returns: - dict: The retrieved Actor run data + The retrieved Actor run data. """ return self._get() @@ -41,11 +40,11 @@ def update(self, *, status_message: str | None = None, is_status_message_termina https://docs.apify.com/api/v2#/reference/actor-runs/run-object/update-run Args: - status_message (str, optional): The new status message for the run - is_status_message_terminal (bool, optional): Set this flag to True if this is the final status message of the Actor run. + status_message: The new status message for the run. + is_status_message_terminal: Set this flag to True if this is the final status message of the Actor run. Returns: - dict: The updated run + The updated run. """ updated_fields = { 'statusMessage': status_message, @@ -67,12 +66,12 @@ def abort(self, *, gracefully: bool | None = None) -> dict: https://docs.apify.com/api/v2#/reference/actor-runs/abort-run/abort-run Args: - gracefully (bool, optional): If True, the Actor run will abort gracefully. - It will send ``aborting`` and ``persistStates`` events into the run and force-stop the run after 30 seconds. - It is helpful in cases where you plan to resurrect the run later. + gracefully: If True, the Actor run will abort gracefully. It will send `aborting` and `persistStates` + events into the run and force-stop the run after 30 seconds. It is helpful in cases where you plan + to resurrect the run later. Returns: - dict: The data of the aborted Actor run + The data of the aborted Actor run. """ return self._abort(gracefully=gracefully) @@ -80,11 +79,11 @@ def wait_for_finish(self, *, wait_secs: int | None = None) -> dict | None: """Wait synchronously until the run finishes or the server times out. Args: - wait_secs (int, optional): how long does the client wait for run to finish. None for indefinite. + wait_secs: How long does the client wait for run to finish. None for indefinite. Returns: - dict, optional: The Actor run data. If the status on the object is not one of the terminal statuses - (SUCEEDED, FAILED, TIMED_OUT, ABORTED), then the run has not yet finished. + The Actor run data. If the status on the object is not one of the terminal statuses (SUCEEDED, FAILED, + TIMED_OUT, ABORTED), then the run has not yet finished. """ return self._wait_for_finish(wait_secs=wait_secs) @@ -101,23 +100,21 @@ def metamorph( https://docs.apify.com/api/v2#/reference/actor-runs/metamorph-run/metamorph-run Args: - target_actor_id (str): ID of the target Actor that the run should be transformed into - target_actor_build (str, optional): The build of the target Actor. It can be either a build tag or build number. - By default, the run uses the build specified in the default run configuration for the target Actor (typically the latest build). - run_input (Any, optional): The input to pass to the new run. - content_type (str, optional): The content type of the input. + target_actor_id: ID of the target Actor that the run should be transformed into. + target_actor_build: The build of the target Actor. It can be either a build tag or build number. + By default, the run uses the build specified in the default run configuration for the target Actor + (typically the latest build). + run_input: The input to pass to the new run. + content_type: The content type of the input. Returns: - dict: The Actor run data. + The Actor run data. """ run_input, content_type = encode_key_value_store_record_value(run_input, content_type) safe_target_actor_id = to_safe_id(target_actor_id) - request_params = self._params( - targetActorId=safe_target_actor_id, - build=target_actor_build, - ) + request_params = self._params(targetActorId=safe_target_actor_id, build=target_actor_build) response = self.http_client.call( url=self._url('metamorph'), @@ -144,15 +141,15 @@ def resurrect( https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run Args: - build (str, optional): Which Actor build the resurrected run should use. It can be either a build tag or build number. - By default, the resurrected run uses the same build as before. - memory_mbytes (int, optional): New memory limit for the resurrected run, in megabytes. - By default, the resurrected run uses the same memory limit as before. - timeout_secs (int, optional): New timeout for the resurrected run, in seconds. - By default, the resurrected run uses the same timeout as before. + build: Which Actor build the resurrected run should use. It can be either a build tag or build number. + By default, the resurrected run uses the same build as before. + memory_mbytes: New memory limit for the resurrected run, in megabytes. By default, the resurrected run + uses the same memory limit as before. + timeout_secs: New timeout for the resurrected run, in seconds. By default, the resurrected run uses the + same timeout as before. Returns: - dict: The Actor run data. + The Actor run data. """ request_params = self._params( build=build, @@ -174,7 +171,7 @@ def reboot(self) -> dict: https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run Returns: - dict: The Actor run data. + The Actor run data. """ response = self.http_client.call( url=self._url('reboot'), @@ -188,7 +185,7 @@ def dataset(self) -> DatasetClient: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - DatasetClient: A client allowing access to the default dataset of this Actor run. + A client allowing access to the default dataset of this Actor run. """ return DatasetClient( **self._sub_resource_init_options(resource_path='dataset'), @@ -200,7 +197,7 @@ def key_value_store(self) -> KeyValueStoreClient: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - KeyValueStoreClient: A client allowing access to the default key-value store of this Actor run. + A client allowing access to the default key-value store of this Actor run. """ return KeyValueStoreClient( **self._sub_resource_init_options(resource_path='key-value-store'), @@ -212,7 +209,7 @@ def request_queue(self) -> RequestQueueClient: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - RequestQueueClient: A client allowing access to the default request_queue of this Actor run. + A client allowing access to the default request_queue of this Actor run. """ return RequestQueueClient( **self._sub_resource_init_options(resource_path='request-queue'), @@ -224,7 +221,7 @@ def log(self) -> LogClient: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - LogClient: A client allowing access to the log of this Actor run. + A client allowing access to the log of this Actor run. """ return LogClient( **self._sub_resource_init_options(resource_path='log'), @@ -241,13 +238,14 @@ def charge( https://docs.apify.com/api/v2#/reference/actor-runs/charge-run/charge-run Returns: - dict: Status and message of the charge event. + Status and message of the charge event. """ if not event_name: raise ValueError('event_name is required for charging an event') - idempotency_key = idempotency_key or ( - f'{self.resource_id}-{event_name}-{int(time.time() * 1000)}-{"".join(random.choices(string.ascii_letters + string.digits, k=6))}' + idempotency_key = ( + idempotency_key + or f'{self.resource_id}-{event_name}-{int(time.time() * 1000)}-{"".join(random.choices(string.ascii_letters + string.digits, k=6))}' # noqa: E501 ) response = self.http_client.call( @@ -272,7 +270,6 @@ class RunClientAsync(ActorJobBaseClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the RunClientAsync.""" resource_path = kwargs.pop('resource_path', 'actor-runs') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -282,21 +279,23 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-runs/run-object/get-run Returns: - dict: The retrieved Actor run data + The retrieved Actor run data. """ return await self._get() - async def update(self, *, status_message: str | None = None, is_status_message_terminal: bool | None = None) -> dict: + async def update( + self, *, status_message: str | None = None, is_status_message_terminal: bool | None = None + ) -> dict: """Update the run with the specified fields. https://docs.apify.com/api/v2#/reference/actor-runs/run-object/update-run Args: - status_message (str, optional): The new status message for the run - is_status_message_terminal (bool, optional): Set this flag to True if this is the final status message of the Actor run. + status_message: The new status message for the run. + is_status_message_terminal: Set this flag to True if this is the final status message of the Actor run. Returns: - dict: The updated run + The updated run. """ updated_fields = { 'statusMessage': status_message, @@ -311,12 +310,12 @@ async def abort(self, *, gracefully: bool | None = None) -> dict: https://docs.apify.com/api/v2#/reference/actor-runs/abort-run/abort-run Args: - gracefully (bool, optional): If True, the Actor run will abort gracefully. - It will send ``aborting`` and ``persistStates`` events into the run and force-stop the run after 30 seconds. - It is helpful in cases where you plan to resurrect the run later. + gracefully: If True, the Actor run will abort gracefully. It will send `aborting` and `persistStates` + events into the run and force-stop the run after 30 seconds. It is helpful in cases where you plan + to resurrect the run later. Returns: - dict: The data of the aborted Actor run + The data of the aborted Actor run. """ return await self._abort(gracefully=gracefully) @@ -324,11 +323,11 @@ async def wait_for_finish(self, *, wait_secs: int | None = None) -> dict | None: """Wait synchronously until the run finishes or the server times out. Args: - wait_secs (int, optional): how long does the client wait for run to finish. None for indefinite. + wait_secs: How long does the client wait for run to finish. None for indefinite. Returns: - dict, optional: The Actor run data. If the status on the object is not one of the terminal statuses - (SUCEEDED, FAILED, TIMED_OUT, ABORTED), then the run has not yet finished. + The Actor run data. If the status on the object is not one of the terminal statuses (SUCEEDED, FAILED, + TIMED_OUT, ABORTED), then the run has not yet finished. """ return await self._wait_for_finish(wait_secs=wait_secs) @@ -352,14 +351,15 @@ async def metamorph( https://docs.apify.com/api/v2#/reference/actor-runs/metamorph-run/metamorph-run Args: - target_actor_id (str): ID of the target Actor that the run should be transformed into - target_actor_build (str, optional): The build of the target Actor. It can be either a build tag or build number. - By default, the run uses the build specified in the default run configuration for the target Actor (typically the latest build). - run_input (Any, optional): The input to pass to the new run. - content_type (str, optional): The content type of the input. + target_actor_id: ID of the target Actor that the run should be transformed into. + target_actor_build: The build of the target Actor. It can be either a build tag or build number. + By default, the run uses the build specified in the default run configuration for the target Actor + (typically the latest build). + run_input: The input to pass to the new run. + content_type: The content type of the input. Returns: - dict: The Actor run data. + The Actor run data. """ run_input, content_type = encode_key_value_store_record_value(run_input, content_type) @@ -395,15 +395,15 @@ async def resurrect( https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run Args: - build (str, optional): Which Actor build the resurrected run should use. It can be either a build tag or build number. - By default, the resurrected run uses the same build as before. - memory_mbytes (int, optional): New memory limit for the resurrected run, in megabytes. - By default, the resurrected run uses the same memory limit as before. - timeout_secs (int, optional): New timeout for the resurrected run, in seconds. - By default, the resurrected run uses the same timeout as before. + build: Which Actor build the resurrected run should use. It can be either a build tag or build number. + By default, the resurrected run uses the same build as before. + memory_mbytes: New memory limit for the resurrected run, in megabytes. By default, the resurrected run + uses the same memory limit as before. + timeout_secs: New timeout for the resurrected run, in seconds. By default, the resurrected run uses the + same timeout as before. Returns: - dict: The Actor run data. + The Actor run data. """ request_params = self._params( build=build, @@ -425,7 +425,7 @@ async def reboot(self) -> dict: https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run Returns: - dict: The Actor run data. + The Actor run data. """ response = await self.http_client.call( url=self._url('reboot'), @@ -439,7 +439,7 @@ def dataset(self) -> DatasetClientAsync: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - DatasetClientAsync: A client allowing access to the default dataset of this Actor run. + A client allowing access to the default dataset of this Actor run. """ return DatasetClientAsync( **self._sub_resource_init_options(resource_path='dataset'), @@ -451,7 +451,7 @@ def key_value_store(self) -> KeyValueStoreClientAsync: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - KeyValueStoreClientAsync: A client allowing access to the default key-value store of this Actor run. + A client allowing access to the default key-value store of this Actor run. """ return KeyValueStoreClientAsync( **self._sub_resource_init_options(resource_path='key-value-store'), @@ -463,7 +463,7 @@ def request_queue(self) -> RequestQueueClientAsync: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - RequestQueueClientAsync: A client allowing access to the default request_queue of this Actor run. + A client allowing access to the default request_queue of this Actor run. """ return RequestQueueClientAsync( **self._sub_resource_init_options(resource_path='request-queue'), @@ -475,7 +475,7 @@ def log(self) -> LogClientAsync: https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages Returns: - LogClientAsync: A client allowing access to the log of this Actor run. + A client allowing access to the log of this Actor run. """ return LogClientAsync( **self._sub_resource_init_options(resource_path='log'), @@ -492,13 +492,13 @@ async def charge( https://docs.apify.com/api/v2#/reference/actor-runs/charge-run/charge-run Returns: - dict: Status and message of the charge event. + Status and message of the charge event. """ if not event_name: raise ValueError('event_name is required for charging an event') idempotency_key = idempotency_key or ( - f'{self.resource_id}-{event_name}-{int(time.time() * 1000)}-{"".join(random.choices(string.ascii_letters + string.digits, k=6))}' + f'{self.resource_id}-{event_name}-{int(time.time() * 1000)}-{"".join(random.choices(string.ascii_letters + string.digits, k=6))}' # noqa: E501 ) response = await self.http_client.call( diff --git a/src/apify_client/clients/resource_clients/run_collection.py b/src/apify_client/clients/resource_clients/run_collection.py index bb787b9b..c1f962fb 100644 --- a/src/apify_client/clients/resource_clients/run_collection.py +++ b/src/apify_client/clients/resource_clients/run_collection.py @@ -16,7 +16,6 @@ class RunCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the RunCollectionClient.""" resource_path = kwargs.pop('resource_path', 'actor-runs') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -28,20 +27,22 @@ def list( desc: bool | None = None, status: ActorJobStatus | None = None, ) -> ListPage[dict]: - """List all Actor runs (either of a single Actor, or all user's Actors, depending on where this client was initialized from). + """List all Actor runs. - https://docs.apify.com/api/v2#/reference/actors/run-collection/get-list-of-runs + List all Actor runs, either of a single Actor, or all user's Actors, depending on where this client + was initialized from. + https://docs.apify.com/api/v2#/reference/actors/run-collection/get-list-of-runs https://docs.apify.com/api/v2#/reference/actor-runs/run-collection/get-user-runs-list Args: - limit (int, optional): How many runs to retrieve - offset (int, optional): What run to include as first when retrieving the list - desc (bool, optional): Whether to sort the runs in descending order based on their start date - status (ActorJobStatus, optional): Retrieve only runs with the provided status + limit: How many runs to retrieve. + offset: What run to include as first when retrieving the list. + desc: Whether to sort the runs in descending order based on their start date. + status: Retrieve only runs with the provided status. Returns: - ListPage: The retrieved Actor runs + The retrieved Actor runs. """ return self._list( limit=limit, @@ -56,7 +57,6 @@ class RunCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the RunCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'actor-runs') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -68,20 +68,22 @@ async def list( desc: bool | None = None, status: ActorJobStatus | None = None, ) -> ListPage[dict]: - """List all Actor runs (either of a single Actor, or all user's Actors, depending on where this client was initialized from). + """List all Actor runs. - https://docs.apify.com/api/v2#/reference/actors/run-collection/get-list-of-runs + List all Actor runs, either of a single Actor, or all user's Actors, depending on where this client + was initialized from. + https://docs.apify.com/api/v2#/reference/actors/run-collection/get-list-of-runs https://docs.apify.com/api/v2#/reference/actor-runs/run-collection/get-user-runs-list Args: - limit (int, optional): How many runs to retrieve - offset (int, optional): What run to include as first when retrieving the list - desc (bool, optional): Whether to sort the runs in descending order based on their start date - status (ActorJobStatus, optional): Retrieve only runs with the provided status + limit: How many runs to retrieve. + offset: What run to include as first when retrieving the list. + desc: Whether to sort the runs in descending order based on their start date. + status: Retrieve only runs with the provided status. Returns: - ListPage: The retrieved Actor runs + The retrieved Actor runs. """ return await self._list( limit=limit, diff --git a/src/apify_client/clients/resource_clients/schedule.py b/src/apify_client/clients/resource_clients/schedule.py index f5cbc85b..3d73b47a 100644 --- a/src/apify_client/clients/resource_clients/schedule.py +++ b/src/apify_client/clients/resource_clients/schedule.py @@ -36,7 +36,6 @@ class ScheduleClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ScheduleClient.""" resource_path = kwargs.pop('resource_path', 'schedules') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -46,7 +45,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/schedules/schedule-object/get-schedule Returns: - dict, optional: The retrieved schedule + The retrieved schedule. """ return self._get() @@ -67,18 +66,19 @@ def update( https://docs.apify.com/api/v2#/reference/schedules/schedule-object/update-schedule Args: - cron_expression (str, optional): The cron expression used by this schedule - is_enabled (bool, optional): True if the schedule should be enabled - is_exclusive (bool, optional): When set to true, don't start Actor or Actor task if it's still running from the previous schedule. - name (str, optional): The name of the schedule to create. - actions (list of dict, optional): Actors or tasks that should be run on this schedule. See the API documentation for exact structure. - description (str, optional): Description of this schedule - timezone (str, optional): Timezone in which your cron expression runs - (TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) - title (str, optional): A human-friendly equivalent of the name + cron_expression: The cron expression used by this schedule. + is_enabled: True if the schedule should be enabled. + is_exclusive: When set to true, don't start Actor or Actor task if it's still running from the previous + schedule. + name: The name of the schedule to create. + actions: Actors or tasks that should be run on this schedule. See the API documentation for exact structure. + description: Description of this schedule. + timezone: Timezone in which your cron expression runs (TZ database name from + https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + title: A human-friendly equivalent of the name. Returns: - dict: The updated schedule + The updated schedule. """ schedule_representation = _get_schedule_representation( cron_expression=cron_expression, @@ -106,7 +106,7 @@ def get_log(self) -> list | None: https://docs.apify.com/api/v2#/reference/schedules/schedule-log/get-schedule-log Returns: - list, optional: Retrieved log of the given schedule + Retrieved log of the given schedule. """ try: response = self.http_client.call( @@ -126,7 +126,6 @@ class ScheduleClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ScheduleClientAsync.""" resource_path = kwargs.pop('resource_path', 'schedules') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -136,7 +135,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/schedules/schedule-object/get-schedule Returns: - dict, optional: The retrieved schedule + The retrieved schedule. """ return await self._get() @@ -157,18 +156,19 @@ async def update( https://docs.apify.com/api/v2#/reference/schedules/schedule-object/update-schedule Args: - cron_expression (str, optional): The cron expression used by this schedule - is_enabled (bool, optional): True if the schedule should be enabled - is_exclusive (bool, optional): When set to true, don't start Actor or Actor task if it's still running from the previous schedule. - name (str, optional): The name of the schedule to create. - actions (list of dict, optional): Actors or tasks that should be run on this schedule. See the API documentation for exact structure. - description (str, optional): Description of this schedule - timezone (str, optional): Timezone in which your cron expression runs - (TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) - title (str, optional): A human-friendly equivalent of the name + cron_expression: The cron expression used by this schedule. + is_enabled: True if the schedule should be enabled. + is_exclusive: When set to true, don't start Actor or Actor task if it's still running from the previous + schedule. + name: The name of the schedule to create. + actions: Actors or tasks that should be run on this schedule. See the API documentation for exact structure. + description: Description of this schedule. + timezone: Timezone in which your cron expression runs (TZ database name from + https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + title: A human-friendly equivalent of the name. Returns: - dict: The updated schedule + The updated schedule. """ schedule_representation = _get_schedule_representation( cron_expression=cron_expression, @@ -196,7 +196,7 @@ async def get_log(self) -> list | None: https://docs.apify.com/api/v2#/reference/schedules/schedule-log/get-schedule-log Returns: - list, optional: Retrieved log of the given schedule + Retrieved log of the given schedule. """ try: response = await self.http_client.call( diff --git a/src/apify_client/clients/resource_clients/schedule_collection.py b/src/apify_client/clients/resource_clients/schedule_collection.py index 845037a2..64ff15d2 100644 --- a/src/apify_client/clients/resource_clients/schedule_collection.py +++ b/src/apify_client/clients/resource_clients/schedule_collection.py @@ -16,7 +16,6 @@ class ScheduleCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ScheduleCollectionClient with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'schedules') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -32,12 +31,12 @@ def list( https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/get-list-of-schedules Args: - limit (int, optional): How many schedules to retrieve - offset (int, optional): What schedules to include as first when retrieving the list - desc (bool, optional): Whether to sort the schedules in descending order based on their modification date + limit: How many schedules to retrieve. + offset: What schedules to include as first when retrieving the list. + desc: Whether to sort the schedules in descending order based on their modification date. Returns: - ListPage: The list of available schedules matching the specified filters. + The list of available schedules matching the specified filters. """ return self._list(limit=limit, offset=offset, desc=desc) @@ -58,18 +57,19 @@ def create( https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/create-schedule Args: - cron_expression (str): The cron expression used by this schedule - is_enabled (bool): True if the schedule should be enabled - is_exclusive (bool): When set to true, don't start Actor or Actor task if it's still running from the previous schedule. - name (str, optional): The name of the schedule to create. - actions (list of dict, optional): Actors or tasks that should be run on this schedule. See the API documentation for exact structure. - description (str, optional): Description of this schedule - timezone (str, optional): Timezone in which your cron expression runs - (TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) - title: str, optional): Title of this schedule + cron_expression: The cron expression used by this schedule. + is_enabled: True if the schedule should be enabled. + is_exclusive: When set to true, don't start Actor or Actor task if it's still running from the previous + schedule. + name: The name of the schedule to create. + actions: Actors or tasks that should be run on this schedule. See the API documentation for exact structure. + description: Description of this schedule. + timezone: Timezone in which your cron expression runs (TZ database name from + https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + title: Title of this schedule. Returns: - dict: The created schedule. + The created schedule. """ if not actions: actions = [] @@ -93,7 +93,6 @@ class ScheduleCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the ScheduleCollectionClientAsync with the passed arguments.""" resource_path = kwargs.pop('resource_path', 'schedules') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -109,12 +108,12 @@ async def list( https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/get-list-of-schedules Args: - limit (int, optional): How many schedules to retrieve - offset (int, optional): What schedules to include as first when retrieving the list - desc (bool, optional): Whether to sort the schedules in descending order based on their modification date + limit: How many schedules to retrieve. + offset: What schedules to include as first when retrieving the list. + desc: Whether to sort the schedules in descending order based on their modification date. Returns: - ListPage: The list of available schedules matching the specified filters. + The list of available schedules matching the specified filters. """ return await self._list(limit=limit, offset=offset, desc=desc) @@ -135,18 +134,19 @@ async def create( https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/create-schedule Args: - cron_expression (str): The cron expression used by this schedule - is_enabled (bool): True if the schedule should be enabled - is_exclusive (bool): When set to true, don't start Actor or Actor task if it's still running from the previous schedule. - name (str, optional): The name of the schedule to create. - actions (list of dict, optional): Actors or tasks that should be run on this schedule. See the API documentation for exact structure. - description (str, optional): Description of this schedule - timezone (str, optional): Timezone in which your cron expression runs - (TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) - title: str, optional): Title of this schedule + cron_expression: The cron expression used by this schedule. + is_enabled: True if the schedule should be enabled. + is_exclusive: When set to true, don't start Actor or Actor task if it's still running from the previous + schedule. + name: The name of the schedule to create. + actions: Actors or tasks that should be run on this schedule. See the API documentation for exact structure. + description: Description of this schedule. + timezone: Timezone in which your cron expression runs (TZ database name from + https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + title: Title of this schedule. Returns: - dict: The created schedule. + The created schedule. """ if not actions: actions = [] diff --git a/src/apify_client/clients/resource_clients/store_collection.py b/src/apify_client/clients/resource_clients/store_collection.py index 0812d66c..1defe3db 100644 --- a/src/apify_client/clients/resource_clients/store_collection.py +++ b/src/apify_client/clients/resource_clients/store_collection.py @@ -15,7 +15,6 @@ class StoreCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the StoreCollectionClient.""" resource_path = kwargs.pop('resource_path', 'store') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -35,16 +34,17 @@ def list( https://docs.apify.com/api/v2/#/reference/store/store-actors-collection/get-list-of-actors-in-store Args: - limit (int, optional): How many Actors to list - offset (int, optional): What Actor to include as first when retrieving the list - search (str, optional): String to search by. The search runs on the following fields: title, name, description, username, readme. - sort_by (str, optional): Specifies the field by which to sort the results. - category (str, optional): Filter by this category - username (str, optional): Filter by this username - pricing_model (str, optional): Filter by this pricing model + limit: How many Actors to list. + offset: What Actor to include as first when retrieving the list. + search: String to search by. The search runs on the following fields: title, name, description, username, + readme. + sort_by: Specifies the field by which to sort the results. + category: Filter by this category. + username: Filter by this username. + pricing_model: Filter by this pricing model. Returns: - ListPage: The list of available tasks matching the specified filters. + The list of available tasks matching the specified filters. """ return self._list( limit=limit, @@ -62,7 +62,6 @@ class StoreCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the StoreCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'store') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -82,16 +81,17 @@ async def list( https://docs.apify.com/api/v2/#/reference/store/store-actors-collection/get-list-of-actors-in-store Args: - limit (int, optional): How many Actors to list - offset (int, optional): What Actor to include as first when retrieving the list - search (str, optional): String to search by. The search runs on the following fields: title, name, description, username, readme. - sort_by (str, optional): Specifies the field by which to sort the results. - category (str, optional): Filter by this category - username (str, optional): Filter by this username - pricing_model (str, optional): Filter by this pricing model + limit: How many Actors to list. + offset: What Actor to include as first when retrieving the list. + search: String to search by. The search runs on the following fields: title, name, description, username, + readme. + sort_by: Specifies the field by which to sort the results. + category: Filter by this category. + username: Filter by this username. + pricing_model: Filter by this pricing model. Returns: - ListPage: The list of available tasks matching the specified filters. + The list of available tasks matching the specified filters. """ return await self._list( limit=limit, diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index ea9e1e52..f880b583 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -14,7 +14,10 @@ from apify_client.clients.base import ResourceClient, ResourceClientAsync from apify_client.clients.resource_clients.run import RunClient, RunClientAsync from apify_client.clients.resource_clients.run_collection import RunCollectionClient, RunCollectionClientAsync -from apify_client.clients.resource_clients.webhook_collection import WebhookCollectionClient, WebhookCollectionClientAsync +from apify_client.clients.resource_clients.webhook_collection import ( + WebhookCollectionClient, + WebhookCollectionClientAsync, +) if TYPE_CHECKING: from apify_shared.consts import ActorJobStatus, MetaOrigin @@ -62,7 +65,6 @@ class TaskClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the TaskClient.""" resource_path = kwargs.pop('resource_path', 'actor-tasks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -72,7 +74,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/get-task Returns: - dict, optional: The retrieved task + The retrieved task. """ return self._get() @@ -97,25 +99,28 @@ def update( https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/update-task Args: - name (str, optional): Name of the task - build (str, optional): Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - task_input (dict, optional): Task input dictionary - title (str, optional): A human-friendly equivalent of the name - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + name: Name of the task. + build: Actor build to run. It can be either a build tag or build number. By default, the run uses + the build specified in the task settings (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, + you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + task_input: Task input dictionary. + title: A human-friendly equivalent of the name. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The updated task + The updated task. """ task_representation = get_task_representation( name=name, @@ -157,27 +162,27 @@ def start( https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task Args: - task_input (dict, optional): Task input dictionary - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - wait_for_finish (int, optional): The maximum number of seconds the server waits for the run to finish. - By default, it is 0, the maximum value is 60. - webhooks (list of dict, optional): Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) - associated with the Actor run which can be used to receive a notification, - e.g. when the Actor finished or failed. - If you already have a webhook set up for the Actor or task, you do not have to add it again here. - Each webhook is represented by a dictionary containing these items: - * ``event_types``: list of ``WebhookEventType`` values which trigger the webhook - * ``request_url``: URL to which to send the webhook HTTP request - * ``payload_template`` (optional): Optional template for the request payload + task_input: Task input dictionary. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the task settings (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged + per result, you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default, + it is 0, the maximum value is 60. + webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with + the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed. + If you already have a webhook set up for the Actor or task, you do not have to add it again here. + Each webhook is represented by a dictionary containing these items: + * `event_types`: List of ``WebhookEventType`` values which trigger the webhook. + * `request_url`: URL to which to send the webhook HTTP request. + * `payload_template`: Optional template for the request payload. Returns: - dict: The run object + The run object. """ request_params = self._params( build=build, @@ -216,21 +221,23 @@ def call( https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task Args: - task_input (dict, optional): Task input dictionary - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - webhooks (list, optional): Specifies optional webhooks associated with the Actor run, which can be used to receive a notification - e.g. when the Actor finished or failed. Note: if you already have a webhook set up for the Actor or task, - you do not have to add it again here. - wait_secs (int, optional): The maximum number of seconds the server waits for the task run to finish. If not provided, waits indefinitely. + task_input: Task input dictionary. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the task settings (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, + you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive + a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for + the Actor or task, you do not have to add it again here. + wait_secs: The maximum number of seconds the server waits for the task run to finish. If not provided, + waits indefinitely. Returns: - dict: The run object + The run object. """ started_run = self.start( task_input=task_input, @@ -249,7 +256,7 @@ def get_input(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/get-task-input Returns: - dict, optional: Retrieved task input + Retrieved task input. """ try: response = self.http_client.call( @@ -268,7 +275,7 @@ def update_input(self, *, task_input: dict) -> dict: https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/update-task-input Returns: - dict, Retrieved task input + Retrieved task input. """ response = self.http_client.call( url=self._url('input'), @@ -288,11 +295,11 @@ def last_run(self, *, status: ActorJobStatus | None = None, origin: MetaOrigin | Last run is retrieved based on the start time of the runs. Args: - status (ActorJobStatus, optional): Consider only runs with this status. - origin (MetaOrigin, optional): Consider only runs started with this origin. + status: Consider only runs with this status. + origin: Consider only runs started with this origin. Returns: - RunClient: The resource client for the last run of this task. + The resource client for the last run of this task. """ return RunClient( **self._sub_resource_init_options( @@ -315,7 +322,6 @@ class TaskClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the TaskClientAsync.""" resource_path = kwargs.pop('resource_path', 'actor-tasks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -325,7 +331,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/get-task Returns: - dict, optional: The retrieved task + The retrieved task. """ return await self._get() @@ -350,25 +356,28 @@ async def update( https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/update-task Args: - name (str, optional): Name of the task - build (str, optional): Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - task_input (dict, optional): Task input dictionary - title (str, optional): A human-friendly equivalent of the name - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + name: Name of the task. + build: Actor build to run. It can be either a build tag or build number. By default, the run uses + the build specified in the task settings (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, + you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + task_input: Task input dictionary. + title: A human-friendly equivalent of the name. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The updated task + The updated task. """ task_representation = get_task_representation( name=name, @@ -410,27 +419,27 @@ async def start( https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task Args: - task_input (dict, optional): Task input dictionary - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - wait_for_finish (int, optional): The maximum number of seconds the server waits for the run to finish. - By default, it is 0, the maximum value is 60. - webhooks (list of dict, optional): Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) - associated with the Actor run which can be used to receive a notification, - e.g. when the Actor finished or failed. - If you already have a webhook set up for the Actor or task, you do not have to add it again here. - Each webhook is represented by a dictionary containing these items: - * ``event_types``: list of ``WebhookEventType`` values which trigger the webhook - * ``request_url``: URL to which to send the webhook HTTP request - * ``payload_template`` (optional): Optional template for the request payload + task_input: Task input dictionary. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the task settings (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged + per result, you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default, + it is 0, the maximum value is 60. + webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with + the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed. + If you already have a webhook set up for the Actor or task, you do not have to add it again here. + Each webhook is represented by a dictionary containing these items: + * `event_types`: List of ``WebhookEventType`` values which trigger the webhook. + * `request_url`: URL to which to send the webhook HTTP request. + * `payload_template`: Optional template for the request payload. Returns: - dict: The run object + The run object. """ request_params = self._params( build=build, @@ -469,21 +478,23 @@ async def call( https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task Args: - task_input (dict, optional): Task input dictionary - build (str, optional): Specifies the Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - max_items (int, optional): Maximum number of results that will be returned by this run. - If the Actor is charged per result, you will not be charged for more results than the given limit. - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - webhooks (list, optional): Specifies optional webhooks associated with the Actor run, which can be used to receive a notification - e.g. when the Actor finished or failed. Note: if you already have a webhook set up for the Actor or task, - you do not have to add it again here. - wait_secs (int, optional): The maximum number of seconds the server waits for the task run to finish. If not provided, waits indefinitely. + task_input: Task input dictionary. + build: Specifies the Actor build to run. It can be either a build tag or build number. By default, + the run uses the build specified in the task settings (typically latest). + max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, + you will not be charged for more results than the given limit. + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive + a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for + the Actor or task, you do not have to add it again here. + wait_secs: The maximum number of seconds the server waits for the task run to finish. If not provided, + waits indefinitely. Returns: - dict: The run object + The run object. """ started_run = await self.start( task_input=task_input, @@ -502,7 +513,7 @@ async def get_input(self) -> dict | None: https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/get-task-input Returns: - dict, optional: Retrieved task input + Retrieved task input. """ try: response = await self.http_client.call( @@ -521,7 +532,7 @@ async def update_input(self, *, task_input: dict) -> dict: https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/update-task-input Returns: - dict, Retrieved task input + Retrieved task input. """ response = await self.http_client.call( url=self._url('input'), @@ -541,11 +552,11 @@ def last_run(self, *, status: ActorJobStatus | None = None, origin: MetaOrigin | Last run is retrieved based on the start time of the runs. Args: - status (ActorJobStatus, optional): Consider only runs with this status. - origin (MetaOrigin, optional): Consider only runs started with this origin. + status: Consider only runs with this status. + origin: Consider only runs started with this origin. Returns: - RunClientAsync: The resource client for the last run of this task. + The resource client for the last run of this task. """ return RunClientAsync( **self._sub_resource_init_options( diff --git a/src/apify_client/clients/resource_clients/task_collection.py b/src/apify_client/clients/resource_clients/task_collection.py index d32266f1..257c052d 100644 --- a/src/apify_client/clients/resource_clients/task_collection.py +++ b/src/apify_client/clients/resource_clients/task_collection.py @@ -16,7 +16,6 @@ class TaskCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the TaskCollectionClient.""" resource_path = kwargs.pop('resource_path', 'actor-tasks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -32,12 +31,12 @@ def list( https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/get-list-of-tasks Args: - limit (int, optional): How many tasks to list - offset (int, optional): What task to include as first when retrieving the list - desc (bool, optional): Whether to sort the tasks in descending order based on their creation date + limit: How many tasks to list. + offset: What task to include as first when retrieving the list. + desc: Whether to sort the tasks in descending order based on their creation date. Returns: - ListPage: The list of available tasks matching the specified filters. + The list of available tasks matching the specified filters. """ return self._list(limit=limit, offset=offset, desc=desc) @@ -63,26 +62,29 @@ def create( https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/create-task Args: - actor_id (str): Id of the Actor that should be run - name (str): Name of the task - build (str, optional): Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - max_items (int, optional): Maximum number of results that will be returned by runs of this task. - If the Actor of this task is charged per result, you will not be charged for more results than the given limit. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - task_input (dict, optional): Task input object. - title (str, optional): A human-friendly equivalent of the name - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + actor_id: Id of the Actor that should be run. + name: Name of the task. + build: Actor build to run. It can be either a build tag or build number. By default, the run uses + the build specified in the task settings (typically latest). + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + max_items: Maximum number of results that will be returned by runs of this task. If the Actor of this task + is charged per result, you will not be charged for more results than the given limit. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + task_input: Task input object. + title: A human-friendly equivalent of the name. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The created task. + The created task. """ task_representation = get_task_representation( actor_id=actor_id, @@ -108,7 +110,6 @@ class TaskCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the TaskCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'actor-tasks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -124,12 +125,12 @@ async def list( https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/get-list-of-tasks Args: - limit (int, optional): How many tasks to list - offset (int, optional): What task to include as first when retrieving the list - desc (bool, optional): Whether to sort the tasks in descending order based on their creation date + limit: How many tasks to list. + offset: What task to include as first when retrieving the list. + desc: Whether to sort the tasks in descending order based on their creation date. Returns: - ListPage: The list of available tasks matching the specified filters. + The list of available tasks matching the specified filters. """ return await self._list(limit=limit, offset=offset, desc=desc) @@ -155,26 +156,29 @@ async def create( https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/create-task Args: - actor_id (str): Id of the Actor that should be run - name (str): Name of the task - build (str, optional): Actor build to run. It can be either a build tag or build number. - By default, the run uses the build specified in the task settings (typically latest). - memory_mbytes (int, optional): Memory limit for the run, in megabytes. - By default, the run uses a memory limit specified in the task settings. - max_items (int, optional): Maximum number of results that will be returned by runs of this task. - If the Actor of this task is charged per result, you will not be charged for more results than the given limit. - timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - task_input (dict, optional): Task input object. - title (str, optional): A human-friendly equivalent of the name - actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + actor_id: Id of the Actor that should be run. + name: Name of the task. + build: Actor build to run. It can be either a build tag or build number. By default, the run uses + the build specified in the task settings (typically latest). + memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified + in the task settings. + max_items: Maximum number of results that will be returned by runs of this task. If the Actor of this task + is charged per result, you will not be charged for more results than the given limit. + timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified + in the task settings. + task_input: Task input object. + title: A human-friendly equivalent of the name. + actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. - actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. - actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. - actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. + actor_standby_idle_timeout_secs: If the Actor run does not receive any requests for this time, + it will be shut down. + actor_standby_build: The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode. Returns: - dict: The created task. + The created task. """ task_representation = get_task_representation( actor_id=actor_id, diff --git a/src/apify_client/clients/resource_clients/user.py b/src/apify_client/clients/resource_clients/user.py index c74c990a..b768100c 100644 --- a/src/apify_client/clients/resource_clients/user.py +++ b/src/apify_client/clients/resource_clients/user.py @@ -14,7 +14,6 @@ class UserClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the UserClient.""" resource_id = kwargs.pop('resource_id', None) if resource_id is None: resource_id = 'me' @@ -61,8 +60,8 @@ def monthly_usage(self) -> dict | None: def limits(self) -> dict | None: """Returns a complete summary of the user account's limits. - It is the same information which is available on the account's Limits page. The returned data includes the current - usage cycle, a summary of the account's limits, and the current usage. + It is the same information which is available on the account's Limits page. The returned data includes + the current usage cycle, a summary of the account's limits, and the current usage. https://docs.apify.com/api/v2#/reference/request-queues/request/get-request @@ -107,7 +106,6 @@ class UserClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the UserClientAsync.""" resource_id = kwargs.pop('resource_id', None) if resource_id is None: resource_id = 'me' @@ -154,8 +152,8 @@ async def monthly_usage(self) -> dict | None: async def limits(self) -> dict | None: """Returns a complete summary of the user account's limits. - It is the same information which is available on the account's Limits page. The returned data includes the current - usage cycle, a summary of the account's limits, and the current usage. + It is the same information which is available on the account's Limits page. The returned data includes + the current usage cycle, a summary of the account's limits, and the current usage. https://docs.apify.com/api/v2#/reference/request-queues/request/get-request diff --git a/src/apify_client/clients/resource_clients/webhook.py b/src/apify_client/clients/resource_clients/webhook.py index 4fa8506e..87592a15 100644 --- a/src/apify_client/clients/resource_clients/webhook.py +++ b/src/apify_client/clients/resource_clients/webhook.py @@ -12,7 +12,10 @@ from apify_client._errors import ApifyApiError from apify_client._utils import catch_not_found_or_throw, pluck_data from apify_client.clients.base import ResourceClient, ResourceClientAsync -from apify_client.clients.resource_clients.webhook_dispatch_collection import WebhookDispatchCollectionClient, WebhookDispatchCollectionClientAsync +from apify_client.clients.resource_clients.webhook_dispatch_collection import ( + WebhookDispatchCollectionClient, + WebhookDispatchCollectionClientAsync, +) if TYPE_CHECKING: from apify_shared.consts import WebhookEventType @@ -62,7 +65,6 @@ class WebhookClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookClient.""" resource_path = kwargs.pop('resource_path', 'webhooks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -72,7 +74,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/get-webhook Returns: - dict, optional: The retrieved webhook, or None if it does not exist + The retrieved webhook, or None if it does not exist. """ return self._get() @@ -95,21 +97,20 @@ def update( https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/update-webhook Args: - event_types (list of WebhookEventType, optional): List of event types that should trigger the webhook. At least one is required. - request_url (str, optional): URL that will be invoked once the webhook is triggered. - payload_template (str, optional): Specification of the payload that will be sent to request_url - headers_template (str, optional): Headers that will be sent to the request_url - actor_id (str, optional): Id of the Actor whose runs should trigger the webhook. - actor_task_id (str, optional): Id of the Actor task whose runs should trigger the webhook. - actor_run_id (str, optional): Id of the Actor run which should trigger the webhook. - ignore_ssl_errors (bool, optional): Whether the webhook should ignore SSL errors returned by request_url - do_not_retry (bool, optional): Whether the webhook should retry sending the payload to request_url upon - failure. - is_ad_hoc (bool, optional): Set to True if you want the webhook to be triggered only the first time the - condition is fulfilled. Only applicable when actor_run_id is filled. + event_types: List of event types that should trigger the webhook. At least one is required. + request_url: URL that will be invoked once the webhook is triggered. + payload_template: Specification of the payload that will be sent to request_url. + headers_template: Headers that will be sent to the request_url. + actor_id: Id of the Actor whose runs should trigger the webhook. + actor_task_id: Id of the Actor task whose runs should trigger the webhook. + actor_run_id: Id of the Actor run which should trigger the webhook. + ignore_ssl_errors: Whether the webhook should ignore SSL errors returned by request_url. + do_not_retry: Whether the webhook should retry sending the payload to request_url upon failure. + is_ad_hoc: Set to True if you want the webhook to be triggered only the first time the condition + is fulfilled. Only applicable when actor_run_id is filled. Returns: - dict: The updated webhook + The updated webhook. """ webhook_representation = get_webhook_representation( event_types=event_types, @@ -141,7 +142,7 @@ def test(self) -> dict | None: https://docs.apify.com/api/v2#/reference/webhooks/webhook-test/test-webhook Returns: - dict, optional: The webhook dispatch created by the test + The webhook dispatch created by the test. """ try: response = self.http_client.call( @@ -163,7 +164,7 @@ def dispatches(self) -> WebhookDispatchCollectionClient: https://docs.apify.com/api/v2#/reference/webhooks/dispatches-collection/get-collection Returns: - WebhookDispatchCollectionClient: A client allowing access to dispatches of this webhook using its list method + A client allowing access to dispatches of this webhook using its list method. """ return WebhookDispatchCollectionClient( **self._sub_resource_init_options(resource_path='dispatches'), @@ -175,7 +176,6 @@ class WebhookClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookClientAsync.""" resource_path = kwargs.pop('resource_path', 'webhooks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -185,7 +185,7 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/get-webhook Returns: - dict, optional: The retrieved webhook, or None if it does not exist + The retrieved webhook, or None if it does not exist. """ return await self._get() @@ -208,21 +208,20 @@ async def update( https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/update-webhook Args: - event_types (list of WebhookEventType, optional): List of event types that should trigger the webhook. At least one is required. - request_url (str, optional): URL that will be invoked once the webhook is triggered. - payload_template (str, optional): Specification of the payload that will be sent to request_url - headers_template (str, optional): Headers that will be sent to the request_url - actor_id (str, optional): Id of the Actor whose runs should trigger the webhook. - actor_task_id (str, optional): Id of the Actor task whose runs should trigger the webhook. - actor_run_id (str, optional): Id of the Actor run which should trigger the webhook. - ignore_ssl_errors (bool, optional): Whether the webhook should ignore SSL errors returned by request_url - do_not_retry (bool, optional): Whether the webhook should retry sending the payload to request_url upon - failure. - is_ad_hoc (bool, optional): Set to True if you want the webhook to be triggered only the first time the - condition is fulfilled. Only applicable when actor_run_id is filled. + event_types: List of event types that should trigger the webhook. At least one is required. + request_url: URL that will be invoked once the webhook is triggered. + payload_template: Specification of the payload that will be sent to request_url. + headers_template: Headers that will be sent to the request_url. + actor_id: Id of the Actor whose runs should trigger the webhook. + actor_task_id: Id of the Actor task whose runs should trigger the webhook. + actor_run_id: Id of the Actor run which should trigger the webhook. + ignore_ssl_errors: Whether the webhook should ignore SSL errors returned by request_url. + do_not_retry: Whether the webhook should retry sending the payload to request_url upon failure. + is_ad_hoc: Set to True if you want the webhook to be triggered only the first time the condition + is fulfilled. Only applicable when actor_run_id is filled. Returns: - dict: The updated webhook + The updated webhook. """ webhook_representation = get_webhook_representation( event_types=event_types, @@ -254,7 +253,7 @@ async def test(self) -> dict | None: https://docs.apify.com/api/v2#/reference/webhooks/webhook-test/test-webhook Returns: - dict, optional: The webhook dispatch created by the test + The webhook dispatch created by the test. """ try: response = await self.http_client.call( @@ -276,7 +275,7 @@ def dispatches(self) -> WebhookDispatchCollectionClientAsync: https://docs.apify.com/api/v2#/reference/webhooks/dispatches-collection/get-collection Returns: - WebhookDispatchCollectionClientAsync: A client allowing access to dispatches of this webhook using its list method + A client allowing access to dispatches of this webhook using its list method. """ return WebhookDispatchCollectionClientAsync( **self._sub_resource_init_options(resource_path='dispatches'), diff --git a/src/apify_client/clients/resource_clients/webhook_collection.py b/src/apify_client/clients/resource_clients/webhook_collection.py index 451e73fd..ea4f11a3 100644 --- a/src/apify_client/clients/resource_clients/webhook_collection.py +++ b/src/apify_client/clients/resource_clients/webhook_collection.py @@ -17,7 +17,6 @@ class WebhookCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookCollectionClient.""" resource_path = kwargs.pop('resource_path', 'webhooks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -33,12 +32,12 @@ def list( https://docs.apify.com/api/v2#/reference/webhooks/webhook-collection/get-list-of-webhooks Args: - limit (int, optional): How many webhooks to retrieve - offset (int, optional): What webhook to include as first when retrieving the list - desc (bool, optional): Whether to sort the webhooks in descending order based on their date of creation + limit: How many webhooks to retrieve. + offset: What webhook to include as first when retrieving the list. + desc: Whether to sort the webhooks in descending order based on their date of creation. Returns: - ListPage: The list of available webhooks matching the specified filters. + The list of available webhooks matching the specified filters. """ return self._list(limit=limit, offset=offset, desc=desc) @@ -64,23 +63,22 @@ def create( https://docs.apify.com/api/v2#/reference/webhooks/webhook-collection/create-webhook Args: - event_types (list of WebhookEventType): List of event types that should trigger the webhook. At least one is required. - request_url (str): URL that will be invoked once the webhook is triggered. - payload_template (str, optional): Specification of the payload that will be sent to request_url - headers_template (str, optional): Headers that will be sent to the request_url - actor_id (str, optional): Id of the Actor whose runs should trigger the webhook. - actor_task_id (str, optional): Id of the Actor task whose runs should trigger the webhook. - actor_run_id (str, optional): Id of the Actor run which should trigger the webhook. - ignore_ssl_errors (bool, optional): Whether the webhook should ignore SSL errors returned by request_url - do_not_retry (bool, optional): Whether the webhook should retry sending the payload to request_url upon - failure. - idempotency_key (str, optional): A unique identifier of a webhook. You can use it to ensure that you won't - create the same webhook multiple times. - is_ad_hoc (bool, optional): Set to True if you want the webhook to be triggered only the first time the - condition is fulfilled. Only applicable when actor_run_id is filled. + event_types: List of event types that should trigger the webhook. At least one is required. + request_url: URL that will be invoked once the webhook is triggered. + payload_template: Specification of the payload that will be sent to request_url. + headers_template: Headers that will be sent to the request_url. + actor_id: Id of the Actor whose runs should trigger the webhook. + actor_task_id: Id of the Actor task whose runs should trigger the webhook. + actor_run_id: Id of the Actor run which should trigger the webhook. + ignore_ssl_errors: Whether the webhook should ignore SSL errors returned by request_url. + do_not_retry: Whether the webhook should retry sending the payload to request_url upon failure. + idempotency_key: A unique identifier of a webhook. You can use it to ensure that you won't create + the same webhook multiple times. + is_ad_hoc: Set to True if you want the webhook to be triggered only the first time the condition + is fulfilled. Only applicable when actor_run_id is filled. Returns: - dict: The created webhook + The created webhook. """ webhook_representation = get_webhook_representation( event_types=event_types, @@ -104,7 +102,6 @@ class WebhookCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'webhooks') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -120,12 +117,12 @@ async def list( https://docs.apify.com/api/v2#/reference/webhooks/webhook-collection/get-list-of-webhooks Args: - limit (int, optional): How many webhooks to retrieve - offset (int, optional): What webhook to include as first when retrieving the list - desc (bool, optional): Whether to sort the webhooks in descending order based on their date of creation + limit: How many webhooks to retrieve. + offset: What webhook to include as first when retrieving the list. + desc: Whether to sort the webhooks in descending order based on their date of creation. Returns: - ListPage: The list of available webhooks matching the specified filters. + The list of available webhooks matching the specified filters. """ return await self._list(limit=limit, offset=offset, desc=desc) @@ -151,23 +148,22 @@ async def create( https://docs.apify.com/api/v2#/reference/webhooks/webhook-collection/create-webhook Args: - event_types (list of WebhookEventType): List of event types that should trigger the webhook. At least one is required. - request_url (str): URL that will be invoked once the webhook is triggered. - payload_template (str, optional): Specification of the payload that will be sent to request_url - headers_template (str, optional): Headers that will be sent to the request_url - actor_id (str, optional): Id of the Actor whose runs should trigger the webhook. - actor_task_id (str, optional): Id of the Actor task whose runs should trigger the webhook. - actor_run_id (str, optional): Id of the Actor run which should trigger the webhook. - ignore_ssl_errors (bool, optional): Whether the webhook should ignore SSL errors returned by request_url - do_not_retry (bool, optional): Whether the webhook should retry sending the payload to request_url upon - failure. - idempotency_key (str, optional): A unique identifier of a webhook. You can use it to ensure that you won't - create the same webhook multiple times. - is_ad_hoc (bool, optional): Set to True if you want the webhook to be triggered only the first time the - condition is fulfilled. Only applicable when actor_run_id is filled. + event_types: List of event types that should trigger the webhook. At least one is required. + request_url: URL that will be invoked once the webhook is triggered. + payload_template: Specification of the payload that will be sent to request_url. + headers_template: Headers that will be sent to the request_url. + actor_id: Id of the Actor whose runs should trigger the webhook. + actor_task_id: Id of the Actor task whose runs should trigger the webhook. + actor_run_id: Id of the Actor run which should trigger the webhook. + ignore_ssl_errors: Whether the webhook should ignore SSL errors returned by request_url. + do_not_retry: Whether the webhook should retry sending the payload to request_url upon failure. + idempotency_key: A unique identifier of a webhook. You can use it to ensure that you won't create + the same webhook multiple times. + is_ad_hoc: Set to True if you want the webhook to be triggered only the first time the condition + is fulfilled. Only applicable when actor_run_id is filled. Returns: - dict: The created webhook + The created webhook. """ webhook_representation = get_webhook_representation( event_types=event_types, diff --git a/src/apify_client/clients/resource_clients/webhook_dispatch.py b/src/apify_client/clients/resource_clients/webhook_dispatch.py index ce5bf83b..323d8959 100644 --- a/src/apify_client/clients/resource_clients/webhook_dispatch.py +++ b/src/apify_client/clients/resource_clients/webhook_dispatch.py @@ -12,7 +12,6 @@ class WebhookDispatchClient(ResourceClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookDispatchClient.""" resource_path = kwargs.pop('resource_path', 'webhook-dispatches') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -22,7 +21,7 @@ def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatch-object/get-webhook-dispatch Returns: - dict, optional: The retrieved webhook dispatch, or None if it does not exist + The retrieved webhook dispatch, or None if it does not exist. """ return self._get() @@ -32,7 +31,6 @@ class WebhookDispatchClientAsync(ResourceClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookDispatchClientAsync.""" resource_path = kwargs.pop('resource_path', 'webhook-dispatches') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -42,6 +40,6 @@ async def get(self) -> dict | None: https://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatch-object/get-webhook-dispatch Returns: - dict, optional: The retrieved webhook dispatch, or None if it does not exist + The retrieved webhook dispatch, or None if it does not exist. """ return await self._get() 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 3afad78e..cdf4d964 100644 --- a/src/apify_client/clients/resource_clients/webhook_dispatch_collection.py +++ b/src/apify_client/clients/resource_clients/webhook_dispatch_collection.py @@ -15,7 +15,6 @@ class WebhookDispatchCollectionClient(ResourceCollectionClient): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookDispatchCollectionClient.""" resource_path = kwargs.pop('resource_path', 'webhook-dispatches') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -31,12 +30,12 @@ def list( https://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatches-collection/get-list-of-webhook-dispatches Args: - limit (int, optional): How many webhook dispatches to retrieve - offset (int, optional): What webhook dispatch to include as first when retrieving the list - desc (bool, optional): Whether to sort the webhook dispatches in descending order based on the date of their creation + limit: How many webhook dispatches to retrieve. + offset: What webhook dispatch to include as first when retrieving the list. + desc: Whether to sort the webhook dispatches in descending order based on the date of their creation. Returns: - ListPage: The retrieved webhook dispatches of a user + The retrieved webhook dispatches of a user. """ return self._list(limit=limit, offset=offset, desc=desc) @@ -46,7 +45,6 @@ class WebhookDispatchCollectionClientAsync(ResourceCollectionClientAsync): @ignore_docs def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the WebhookDispatchCollectionClientAsync.""" resource_path = kwargs.pop('resource_path', 'webhook-dispatches') super().__init__(*args, resource_path=resource_path, **kwargs) @@ -62,11 +60,11 @@ async def list( https://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatches-collection/get-list-of-webhook-dispatches Args: - limit (int, optional): How many webhook dispatches to retrieve - offset (int, optional): What webhook dispatch to include as first when retrieving the list - desc (bool, optional): Whether to sort the webhook dispatches in descending order based on the date of their creation + limit: How many webhook dispatches to retrieve. + offset: What webhook dispatch to include as first when retrieving the list. + desc: Whether to sort the webhook dispatches in descending order based on the date of their creation. Returns: - ListPage: The retrieved webhook dispatches of a user + The retrieved webhook dispatches of a user. """ return await self._list(limit=limit, offset=offset, desc=desc) diff --git a/tests/integration/test_request_queue.py b/tests/integration/test_request_queue.py index 029d3234..a004d4ea 100644 --- a/tests/integration/test_request_queue.py +++ b/tests/integration/test_request_queue.py @@ -50,7 +50,9 @@ def test_request_batch_operations(self, apify_client: ApifyClient) -> None: queue = apify_client.request_queue(created_queue['id']) # Add requests to queue and check if they were added - requests_to_add = [{'url': f'http://test-batch.com/{i}', 'uniqueKey': f'http://test-batch.com/{i}'} for i in range(25)] + requests_to_add = [ + {'url': f'http://test-batch.com/{i}', 'uniqueKey': f'http://test-batch.com/{i}'} for i in range(25) + ] added_requests = queue.batch_add_requests(requests_to_add) assert len(added_requests.get('processedRequests', [])) > 0 requests_in_queue = queue.list_requests() @@ -58,7 +60,9 @@ def test_request_batch_operations(self, apify_client: ApifyClient) -> None: # Delete requests from queue and check if they were deleted requests_to_delete = requests_in_queue['items'][:20] - delete_response = queue.batch_delete_requests([{'uniqueKey': req.get('uniqueKey')} for req in requests_to_delete]) + delete_response = queue.batch_delete_requests( + [{'uniqueKey': req.get('uniqueKey')} for req in requests_to_delete] + ) requests_in_queue2 = queue.list_requests() assert len(requests_in_queue2['items']) == 25 - len(delete_response['processedRequests']) @@ -100,7 +104,9 @@ async def test_request_batch_operations(self, apify_client_async: ApifyClientAsy queue = apify_client_async.request_queue(created_queue['id']) # Add requests to queue and check if they were added - requests_to_add = [{'url': f'http://test-batch.com/{i}', 'uniqueKey': f'http://test-batch.com/{i}'} for i in range(25)] + requests_to_add = [ + {'url': f'http://test-batch.com/{i}', 'uniqueKey': f'http://test-batch.com/{i}'} for i in range(25) + ] added_requests = await queue.batch_add_requests(requests_to_add) assert len(added_requests.get('processedRequests', [])) > 0 requests_in_queue = await queue.list_requests() @@ -108,7 +114,9 @@ async def test_request_batch_operations(self, apify_client_async: ApifyClientAsy # Delete requests from queue and check if they were deleted requests_to_delete = requests_in_queue['items'][:20] - delete_response = await queue.batch_delete_requests([{'uniqueKey': req.get('uniqueKey')} for req in requests_to_delete]) + delete_response = await queue.batch_delete_requests( + [{'uniqueKey': req.get('uniqueKey')} for req in requests_to_delete] + ) requests_in_queue2 = await queue.list_requests() assert len(requests_in_queue2['items']) == 25 - len(delete_response['processedRequests']) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index d783e073..95e75c1f 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -62,7 +62,9 @@ def bails_on_third_attempt(stop_retrying: Callable, attempt: int) -> Any: # Returns the correct result after the correct time (should take 100 + 200 + 400 + 800 = 1500 ms) start = time.time() - result = retry_with_exp_backoff(returns_on_fifth_attempt, backoff_base_millis=100, backoff_factor=2, random_factor=0) + result = retry_with_exp_backoff( + returns_on_fifth_attempt, backoff_base_millis=100, backoff_factor=2, random_factor=0 + ) elapsed_time_seconds = time.time() - start assert result == 'SUCCESS' assert attempt_counter == 5 @@ -111,7 +113,9 @@ async def bails_on_third_attempt(stop_retrying: Callable, attempt: int) -> Any: # Returns the correct result after the correct time (should take 100 + 200 + 400 + 800 = 1500 ms) start = time.time() - result = await retry_with_exp_backoff_async(returns_on_fifth_attempt, backoff_base_millis=100, backoff_factor=2, random_factor=0) + result = await retry_with_exp_backoff_async( + returns_on_fifth_attempt, backoff_base_millis=100, backoff_factor=2, random_factor=0 + ) elapsed_time_seconds = time.time() - start assert result == 'SUCCESS' assert attempt_counter == 5 From 87515e8a99b07d3180ad1ac28c92ba0085356f93 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Tue, 10 Dec 2024 16:06:05 +0100 Subject: [PATCH 2/2] . --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed2a062a..44e9daa4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ Install the necessary dependencies: yarn ``` -Start the project in development mode with Hot Module Replacement +Start the project in development mode with Hot Module Replacement (HMR): ```sh yarn start