diff --git a/src/apify_client/clients/resource_clients/user.py b/src/apify_client/clients/resource_clients/user.py index 49db0746..6a28db6c 100644 --- a/src/apify_client/clients/resource_clients/user.py +++ b/src/apify_client/clients/resource_clients/user.py @@ -2,7 +2,7 @@ from typing import Any -from apify_shared.utils import ignore_docs, parse_date_fields +from apify_shared.utils import filter_out_none_values_recursively, ignore_docs, parse_date_fields from apify_client._errors import ApifyApiError from apify_client._utils import catch_not_found_or_throw, pluck_data @@ -82,6 +82,25 @@ def limits(self: UserClient) -> dict | None: return None + def update_limits( + self: UserClient, + *, + max_monthly_usage_usd: int | None = None, + data_retention_days: int | None = None, + ) -> None: + """Updates the account's limits manageable on your account's Limits page.""" + self.http_client.call( + url=self._url('limits'), + method='PUT', + params=self._params(), + json=filter_out_none_values_recursively( + { + 'maxMonthlyUsageUsd': max_monthly_usage_usd, + 'dataRetentionDays': data_retention_days, + } + ), + ) + class UserClientAsync(ResourceClientAsync): """Async sub-client for querying user data.""" @@ -155,3 +174,22 @@ async def limits(self: UserClientAsync) -> dict | None: catch_not_found_or_throw(exc) return None + + async def update_limits( + self: UserClientAsync, + *, + max_monthly_usage_usd: int | None = None, + data_retention_days: int | None = None, + ) -> None: + """Updates the account's limits manageable on your account's Limits page.""" + await self.http_client.call( + url=self._url('limits'), + method='PUT', + params=self._params(), + json=filter_out_none_values_recursively( + { + 'maxMonthlyUsageUsd': max_monthly_usage_usd, + 'dataRetentionDays': data_retention_days, + } + ), + )