Skip to content

Commit 71802bf

Browse files
committed
feat: [DPS-44447] Add endpoint to expose streams limit per account
1 parent 04e0a70 commit 71802bf

4 files changed

Lines changed: 89 additions & 0 deletions

File tree

linode_api4/groups/monitor.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
AkamaiObjectStorageLogsDestinationDetails,
2323
CustomHTTPSLogsDestinationDetails,
2424
LogsStreamDetails,
25+
LogsStreamQuota,
2526
)
2627

2728
__all__ = [
@@ -625,3 +626,20 @@ def stream_create(
625626
)
626627

627628
return LogsStream(self.client, result["id"], result)
629+
630+
def streams_quotas(self, *filters) -> PaginatedList:
631+
"""
632+
Retrieve quota definitions available for the authenticated account's streams.
633+
634+
This reads from ``/monitor/streams/quotas`` on the API v4 endpoint.
635+
636+
:param filters: Any number of filters to apply to this query.
637+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
638+
for more details on filtering.
639+
640+
:returns: A paginated list of stream quota definitions.
641+
:rtype: PaginatedList[LogsStreamQuota]
642+
"""
643+
return self.client._get_and_filter(
644+
LogsStreamQuota, *filters, endpoint="/monitor/streams/quotas"
645+
)

linode_api4/objects/monitor.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"LogsStreamStatus",
4141
"LogsStreamDetails",
4242
"LogsStreamDestination",
43+
"LogsStreamQuota",
4344
]
4445

4546

@@ -904,3 +905,16 @@ def history(self):
904905
"{}/history".format(LogsStream.api_endpoint.format(id=self.id)),
905906
LogsStreamHistory,
906907
)
908+
909+
910+
@dataclass
911+
class LogsStreamQuota(JSONObject):
912+
"""
913+
Represents a quota definition for logs streams.
914+
"""
915+
916+
quota_id: str = ""
917+
quota_name: str = ""
918+
quota_limit: int = 0
919+
quota_type: str = ""
920+
description: str = ""
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"data": [
3+
{
4+
"quota_id": "aclp_audit_logs_streams",
5+
"quota_name": "Number of Audit Logs Streams",
6+
"description": "Current number of audit logs streams per account",
7+
"quota_limit": 5,
8+
"quota_type": "logs_streams_aclp_audit_logs_streams"
9+
},
10+
{
11+
"quota_id": "aclp_lke_audit_logs_streams",
12+
"quota_name": "Number of LKE Audit Logs Streams",
13+
"description": "Current number of LKE audit logs streams per account",
14+
"quota_limit": 10,
15+
"quota_type": "logs_streams_aclp_lke_audit_logs_streams"
16+
}
17+
],
18+
"results": 2,
19+
"page": 1,
20+
"pages": 1
21+
}

test/unit/objects/monitor_test.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
DestinationAuthentication,
1717
LogsDestinationDetailsBase,
1818
LogsStreamDetails,
19+
LogsStreamQuota,
1920
LogsStreamType,
2021
)
2122

@@ -653,6 +654,41 @@ def test_delete_stream(self):
653654

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

657+
def test_streams_quotas(self):
658+
"""
659+
Test that streams_quotas returns a paginated list of quota objects.
660+
"""
661+
url = "/monitor/streams/quotas"
662+
with self.mock_get(url) as m:
663+
result = self.client.monitor.streams_quotas()
664+
665+
self.assertEqual(m.call_url, url)
666+
self.assertEqual(len(result), 2)
667+
self.assertIsInstance(result[0], LogsStreamQuota)
668+
self.assertEqual(result[0].quota_id, "aclp_audit_logs_streams")
669+
self.assertEqual(result[0].quota_name, "Number of Audit Logs Streams")
670+
self.assertEqual(
671+
result[0].description,
672+
"Current number of audit logs streams per account",
673+
)
674+
self.assertEqual(result[0].quota_limit, 5)
675+
self.assertEqual(
676+
result[0].quota_type, "logs_streams_aclp_audit_logs_streams"
677+
)
678+
self.assertIsInstance(result[1], LogsStreamQuota)
679+
self.assertEqual(result[1].quota_id, "aclp_lke_audit_logs_streams")
680+
self.assertEqual(
681+
result[1].quota_name, "Number of LKE Audit Logs Streams"
682+
)
683+
self.assertEqual(
684+
result[1].description,
685+
"Current number of LKE audit logs streams per account",
686+
)
687+
self.assertEqual(result[1].quota_limit, 10)
688+
self.assertEqual(
689+
result[1].quota_type, "logs_streams_aclp_lke_audit_logs_streams"
690+
)
691+
656692

657693
class LkeAuditLogsStreamTest(ClientBaseCase):
658694
"""

0 commit comments

Comments
 (0)