Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions linode_api4/groups/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
AkamaiObjectStorageLogsDestinationDetails,
CustomHTTPSLogsDestinationDetails,
LogsStreamDetails,
LogsStreamQuota,
)

__all__ = [
Expand Down Expand Up @@ -625,3 +626,18 @@ def stream_create(
)

return LogsStream(self.client, result["id"], result)

def stream_quotas(self) -> PaginatedList:
"""
Retrieve quota definitions available for the authenticated account's streams.

This reads from ``/monitor/streams/quotas`` on the API v4 endpoint.

API Documentation: TODO

:returns: A paginated list of stream quota definitions.
:rtype: PaginatedList[LogsStreamQuota]
"""
Comment on lines +631 to +640

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a placeholder for techdoc link in the docstring?

return self.client._get_objects(
"/monitor/streams/quotas", LogsStreamQuota
)
14 changes: 14 additions & 0 deletions linode_api4/objects/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"LogsStreamStatus",
"LogsStreamDetails",
"LogsStreamDestination",
"LogsStreamQuota",
]


Expand Down Expand Up @@ -904,3 +905,16 @@ def history(self):
"{}/history".format(LogsStream.api_endpoint.format(id=self.id)),
LogsStreamHistory,
)


@dataclass
class LogsStreamQuota(JSONObject):
"""
Represents a quota definition for logs streams.
"""

quota_id: str = ""
quota_name: str = ""
quota_limit: int = 0
quota_type: str = ""
description: str = ""
21 changes: 21 additions & 0 deletions test/fixtures/monitor_streams_quotas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"data": [
{
"quota_id": "aclp_audit_logs_streams",
"quota_name": "Number of Audit Logs Streams",
"description": "Current number of audit logs streams per account",
"quota_limit": 5,
"quota_type": "logs_streams_aclp_audit_logs_streams"
},
{
"quota_id": "aclp_lke_audit_logs_streams",
"quota_name": "Number of LKE Audit Logs Streams",
"description": "Current number of LKE audit logs streams per account",
"quota_limit": 10,
"quota_type": "logs_streams_aclp_lke_audit_logs_streams"
}
],
"results": 2,
"page": 1,
"pages": 1
}
36 changes: 36 additions & 0 deletions test/unit/objects/monitor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DestinationAuthentication,
LogsDestinationDetailsBase,
LogsStreamDetails,
LogsStreamQuota,
LogsStreamType,
)

Expand Down Expand Up @@ -653,6 +654,41 @@ def test_delete_stream(self):

self.assertEqual(m.call_url, "/monitor/streams/1")

def test_stream_quotas(self):
"""
Test that stream_quotas returns a paginated list of quota objects.
"""
url = "/monitor/streams/quotas"
with self.mock_get(url) as m:
result = self.client.monitor.stream_quotas()

self.assertEqual(m.call_url, url)
self.assertEqual(len(result), 2)
self.assertIsInstance(result[0], LogsStreamQuota)
self.assertEqual(result[0].quota_id, "aclp_audit_logs_streams")
self.assertEqual(result[0].quota_name, "Number of Audit Logs Streams")
self.assertEqual(
result[0].description,
"Current number of audit logs streams per account",
)
self.assertEqual(result[0].quota_limit, 5)
self.assertEqual(
result[0].quota_type, "logs_streams_aclp_audit_logs_streams"
)
self.assertIsInstance(result[1], LogsStreamQuota)
self.assertEqual(result[1].quota_id, "aclp_lke_audit_logs_streams")
self.assertEqual(
result[1].quota_name, "Number of LKE Audit Logs Streams"
)
self.assertEqual(
result[1].description,
"Current number of LKE audit logs streams per account",
)
self.assertEqual(result[1].quota_limit, 10)
self.assertEqual(
result[1].quota_type, "logs_streams_aclp_lke_audit_logs_streams"
)


class LkeAuditLogsStreamTest(ClientBaseCase):
"""
Expand Down