Skip to content

Commit 1134f90

Browse files
committed
feat: add user.update_limits
1 parent f5e099e commit 1134f90

File tree

1 file changed

+38
-1
lines changed
  • src/apify_client/clients/resource_clients

1 file changed

+38
-1
lines changed

src/apify_client/clients/resource_clients/user.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any
44

5-
from apify_shared.utils import ignore_docs, parse_date_fields
5+
from apify_shared.utils import ignore_docs, parse_date_fields, filter_out_none_values_recursively
66

77
from apify_client._errors import ApifyApiError
88
from apify_client._utils import catch_not_found_or_throw, pluck_data
@@ -82,6 +82,24 @@ def limits(self: UserClient) -> dict | None:
8282

8383
return None
8484

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+
"""
92+
Updates the account's limits manageable on your account's Limits page.
93+
"""
94+
self.http_client.call(
95+
url=self._url('limits'),
96+
method='PUT',
97+
params=self._params(),
98+
json=filter_out_none_values_recursively({
99+
'maxMonthlyUsageUsd': max_monthly_usage_usd,
100+
'dataRetentionDays': data_retention_days,
101+
}),
102+
)
85103

86104
class UserClientAsync(ResourceClientAsync):
87105
"""Async sub-client for querying user data."""
@@ -155,3 +173,22 @@ async def limits(self: UserClientAsync) -> dict | None:
155173
catch_not_found_or_throw(exc)
156174

157175
return None
176+
177+
async def update_limits(
178+
self: UserClientAsync,
179+
*,
180+
max_monthly_usage_usd: int | None = None,
181+
data_retention_days: int | None = None,
182+
) -> None:
183+
"""
184+
Updates the account's limits manageable on your account's Limits page.
185+
"""
186+
await self.http_client.call(
187+
url=self._url('limits'),
188+
method='PUT',
189+
params=self._params(),
190+
json=filter_out_none_values_recursively({
191+
'maxMonthlyUsageUsd': max_monthly_usage_usd,
192+
'dataRetentionDays': data_retention_days,
193+
}),
194+
)

0 commit comments

Comments
 (0)