8000 feat: add user.update_limits (#279) · apify/apify-client-python@7aed9c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7aed9c9

Browse files
authored
feat: add user.update_limits (#279)
Resolves apify/apify-client-js#329 - add `update_limits` function to `UserClient`, which does `PUT: /v2/users/:userId/limits` Api docs PR here: apify/openapi#103 Client JS PR here: apify/apify-client-js#595 Console api docs PR here: apify/apify-core#18038 Endpoint is already implemented, only api docs and clients were missing
1 parent f5e099e commit 7aed9c9

File tree

1 file changed

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

1 file changed

+39
-1
lines changed

src/apify_client/clients/resource_clients/user.py

Lines changed: 39 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 filter_out_none_values_recursively, ignore_docs, parse_date_fields
66

77
from apify_client._errors import ApifyApiError
88
from apify_client._utils import catch_not_found_or_throw, pluck_data
@@ -82,6 +82,25 @@ 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+
"""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+
85104

86105
class UserClientAsync(ResourceClientAsync):
87106
"""Async sub-client for querying user data."""
@@ -155,3 +174,22 @@ async def limits(self: UserClientAsync) -> dict | None:
155174
catch_not_found_or_throw(exc)
156175

157176
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

Comments
 (0)
0