|
2 | 2 |
|
3 | 3 | from typing import Any
|
4 | 4 |
|
5 |
| -from apify_shared.utils import ignore_docs, parse_date_fields |
| 5 | +from apify_shared.utils import filter_out_none_values_recursively, ignore_docs, parse_date_fields |
6 | 6 |
|
7 | 7 | from apify_client._errors import ApifyApiError
|
8 | 8 | from apify_client._utils import catch_not_found_or_throw, pluck_data
|
@@ -82,6 +82,25 @@ def limits(self: UserClient) -> dict | None:
|
82 | 82 |
|
83 | 83 | return None
|
84 | 84 |
|
| 85 | + def update_limits( |
| 86 | + self: UserClient, |
| 87 | + *, |
| 88 | + max_monthly_usage_usd: int | None = None, |
| 89 | + data_retention_days: int | None = None, |
| 90 | + ) -> None: |
| 91 | + """Updates the account's limits manageable on your account's Limits page.""" |
| 92 | + self.http_client.call( |
| 93 | + url=self._url('limits'), |
| 94 | + method='PUT', |
| 95 | + params=self._params(), |
| 96 | + json=filter_out_none_values_recursively( |
| 97 | + { |
| 98 | + 'maxMonthlyUsageUsd': max_monthly_usage_usd, |
| 99 | + 'dataRetentionDays': data_retention_days, |
| 100 | + } |
| 101 | + ), |
| 102 | + ) |
| 103 | + |
85 | 104 |
|
86 | 105 | class UserClientAsync(ResourceClientAsync):
|
87 | 106 | """Async sub-client for querying user data."""
|
@@ -155,3 +174,22 @@ async def limits(self: UserClientAsync) -> dict | None:
|
155 | 174 | catch_not_found_or_throw(exc)
|
156 | 175 |
|
157 | 176 | return None
|
| 177 | + |
| 178 | + async def update_limits( |
| 179 | + self: UserClientAsync, |
| 180 | + *, |
| 181 | + max_monthly_usage_usd: int | None = None, |
| 182 | + data_retention_days: int | None = None, |
| 183 | + ) -> None: |
| 184 | + """Updates the account's limits manageable on your account's Limits page.""" |
| 185 | + await self.http_client.call( |
| 186 | + url=self._url('limits'), |
| 187 | + method='PUT', |
| 188 | + params=self._params(), |
| 189 | + json=filter_out_none_values_recursively( |
| 190 | + { |
| 191 | + 'maxMonthlyUsageUsd': max_monthly_usage_usd, |
| 192 | + 'dataRetentionDays': data_retention_days, |
| 193 | + } |
| 194 | + ), |
| 195 | + ) |
0 commit comments