Source code for limitry.client.resources.quota_alerts
"""Auto-generated operation classes.
This file is auto-generated by the operators generator.
Do not edit this file manually.
"""
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from limitry.client.types import (
QuotaAlert,
QuotaAlertLog,
QuotaAlertsDeleteResponse,
QuotaAlertsPutRequest
)
from limitry.client.utils.pagination import PaginatedResponse
if TYPE_CHECKING:
from limitry.client.client import Client
[docs]
class QuotaAlerts:
"""Operations for quotaalerts."""
[docs]
def __init__(self, client: "Client") -> None:
"""Initialize QuotaAlerts operations.
Args:
client: The Limitry client instance
"""
self._client = client
[docs]
async def get(
self,
alert_id: str
) -> QuotaAlert:
"""Get a quota alert.
Get details of a specific alert.
Args:
alert_id: No description provided
Returns:
QuotaAlert: Alert details
Example::
result = await client.quota-alerts.get_quota_alert(
"alertid_123"
)
print(result)
Raises:
AuthenticationError: Unauthorized
APIError: Alert not found
NetworkError: If a network error occurs"""
response = await self._client.request("GET", f"/quota-alerts/{alert_id}")
return QuotaAlert(**response)
[docs]
async def update(
self,
alert_id: str,
request: QuotaAlertsPutRequest
) -> QuotaAlert:
"""Update a quota alert.
Update the threshold for an alert.
Args:
alert_id: No description provided
request: QuotaAlertsPutRequest object
Returns:
QuotaAlert: Alert updated successfully
Example::
request = QuotaAlertsPutRequest(
threshold=123
)
result = await client.quota-alerts.update_quota_alert(
"alertid_123",
request
)
print(result)
Raises:
AuthenticationError: Unauthorized
APIError: Alert not found
NetworkError: If a network error occurs"""
response = await self._client.request("PUT", f"/quota-alerts/{alert_id}", json=request.model_dump(mode='json', exclude_none=True))
return QuotaAlert(**response)
[docs]
async def delete(
self,
alert_id: str
) -> QuotaAlertsDeleteResponse:
"""Delete a quota alert.
Remove an alert configuration.
Args:
alert_id: No description provided
Returns:
QuotaAlertsDeleteResponse: Alert deleted successfully
Example::
result = await client.quota-alerts.delete_quota_alert(
"alertid_123"
)
print(result)
Raises:
AuthenticationError: Unauthorized
APIError: Alert not found
NetworkError: If a network error occurs"""
response = await self._client.request("DELETE", f"/quota-alerts/{alert_id}")
return QuotaAlertsDeleteResponse(**response)
[docs]
async def get_history(
self,
alert_id: str,
limit: Optional[str] = None,
cursor: Optional[str] = None
) -> PaginatedResponse[QuotaAlertLog]:
"""Get alert history.
View a log of triggered alerts for a specific alert.
Args:
alert_id: No description provided
limit: Maximum number of log entries to return (1-100, default: 50) (default: "50")
cursor: Pagination cursor from the previous response
Returns:
PaginatedResponse[QuotaAlertLog]: Alert history
Example::
items = await client.quota-alerts.get_quota_alert_history(
"alertid_123"
)
for item in items.data:
print(item)
Raises:
AuthenticationError: Unauthorized
APIError: Alert not found
NetworkError: If a network error occurs"""
params = {
"limit": limit,
"cursor": cursor,
}
params = {k: v for k, v in params.items() if v is not None}
response = await self._client.request("GET", f"/quota-alerts/{alert_id}/history", params=params)
return PaginatedResponse(
data=[QuotaAlertLog(**item) for item in response['data']],
next_cursor=response.get('nextCursor'),
has_more=response.get('hasMore', False)
)