From 71802bf6ffc5ff2bf4c7464bebfb0d1dbd782c23 Mon Sep 17 00:00:00 2001 From: odyszews Date: Mon, 10 Aug 2026 10:40:58 +0200 Subject: [PATCH 1/3] feat: [DPS-44447] Add endpoint to expose streams limit per account --- linode_api4/groups/monitor.py | 18 ++++++++++++ linode_api4/objects/monitor.py | 14 +++++++++ test/fixtures/monitor_streams_quotas.json | 21 +++++++++++++ test/unit/objects/monitor_test.py | 36 +++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 test/fixtures/monitor_streams_quotas.json diff --git a/linode_api4/groups/monitor.py b/linode_api4/groups/monitor.py index 46f37561f..64ba756bd 100644 --- a/linode_api4/groups/monitor.py +++ b/linode_api4/groups/monitor.py @@ -22,6 +22,7 @@ AkamaiObjectStorageLogsDestinationDetails, CustomHTTPSLogsDestinationDetails, LogsStreamDetails, + LogsStreamQuota, ) __all__ = [ @@ -625,3 +626,20 @@ def stream_create( ) return LogsStream(self.client, result["id"], result) + + def streams_quotas(self, *filters) -> PaginatedList: + """ + Retrieve quota definitions available for the authenticated account's streams. + + This reads from ``/monitor/streams/quotas`` on the API v4 endpoint. + + :param filters: Any number of filters to apply to this query. + See :doc:`Filtering Collections` + for more details on filtering. + + :returns: A paginated list of stream quota definitions. + :rtype: PaginatedList[LogsStreamQuota] + """ + return self.client._get_and_filter( + LogsStreamQuota, *filters, endpoint="/monitor/streams/quotas" + ) diff --git a/linode_api4/objects/monitor.py b/linode_api4/objects/monitor.py index c23e4cead..2ab8c969c 100644 --- a/linode_api4/objects/monitor.py +++ b/linode_api4/objects/monitor.py @@ -40,6 +40,7 @@ "LogsStreamStatus", "LogsStreamDetails", "LogsStreamDestination", + "LogsStreamQuota", ] @@ -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 = "" diff --git a/test/fixtures/monitor_streams_quotas.json b/test/fixtures/monitor_streams_quotas.json new file mode 100644 index 000000000..3176b20c3 --- /dev/null +++ b/test/fixtures/monitor_streams_quotas.json @@ -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 +} \ No newline at end of file diff --git a/test/unit/objects/monitor_test.py b/test/unit/objects/monitor_test.py index c0999e485..05f4083a3 100644 --- a/test/unit/objects/monitor_test.py +++ b/test/unit/objects/monitor_test.py @@ -16,6 +16,7 @@ DestinationAuthentication, LogsDestinationDetailsBase, LogsStreamDetails, + LogsStreamQuota, LogsStreamType, ) @@ -653,6 +654,41 @@ def test_delete_stream(self): self.assertEqual(m.call_url, "/monitor/streams/1") + def test_streams_quotas(self): + """ + Test that streams_quotas returns a paginated list of quota objects. + """ + url = "/monitor/streams/quotas" + with self.mock_get(url) as m: + result = self.client.monitor.streams_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): """ From 87e5601b2282c299c8223b55b0315c2689038d57 Mon Sep 17 00:00:00 2001 From: odyszews Date: Tue, 11 Aug 2026 10:53:13 +0200 Subject: [PATCH 2/3] feat: [DPS-44447] Add endpoint to expose streams limit per account --- linode_api4/groups/monitor.py | 10 ++-------- test/fixtures/monitor_streams_quotas.json | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/linode_api4/groups/monitor.py b/linode_api4/groups/monitor.py index 64ba756bd..5855ae314 100644 --- a/linode_api4/groups/monitor.py +++ b/linode_api4/groups/monitor.py @@ -627,19 +627,13 @@ def stream_create( return LogsStream(self.client, result["id"], result) - def streams_quotas(self, *filters) -> PaginatedList: + def streams_quotas(self) -> PaginatedList: """ Retrieve quota definitions available for the authenticated account's streams. This reads from ``/monitor/streams/quotas`` on the API v4 endpoint. - :param filters: Any number of filters to apply to this query. - See :doc:`Filtering Collections` - for more details on filtering. - :returns: A paginated list of stream quota definitions. :rtype: PaginatedList[LogsStreamQuota] """ - return self.client._get_and_filter( - LogsStreamQuota, *filters, endpoint="/monitor/streams/quotas" - ) + return self.client._get_objects("/monitor/streams/quotas", LogsStreamQuota) diff --git a/test/fixtures/monitor_streams_quotas.json b/test/fixtures/monitor_streams_quotas.json index 3176b20c3..6d2b83138 100644 --- a/test/fixtures/monitor_streams_quotas.json +++ b/test/fixtures/monitor_streams_quotas.json @@ -18,4 +18,4 @@ "results": 2, "page": 1, "pages": 1 -} \ No newline at end of file +} From b1ae8c3aea6ff3f146e7c9ca734c376a0c2c51fe Mon Sep 17 00:00:00 2001 From: odyszews Date: Tue, 11 Aug 2026 11:08:28 +0200 Subject: [PATCH 3/3] feat: [DPS-44447] fix formatting issues --- linode_api4/groups/monitor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linode_api4/groups/monitor.py b/linode_api4/groups/monitor.py index 5855ae314..d24c96ac1 100644 --- a/linode_api4/groups/monitor.py +++ b/linode_api4/groups/monitor.py @@ -636,4 +636,6 @@ def streams_quotas(self) -> PaginatedList: :returns: A paginated list of stream quota definitions. :rtype: PaginatedList[LogsStreamQuota] """ - return self.client._get_objects("/monitor/streams/quotas", LogsStreamQuota) + return self.client._get_objects( + "/monitor/streams/quotas", LogsStreamQuota + )