Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion src/apify_client/clients/resource_clients/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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,
}
),
)