-
Notifications
You must be signed in to change notification settings - Fork 82
Add global quotas and quota usage support for OBJ services #661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -596,6 +596,8 @@ class ObjectStorageQuota(Base): | |||||
| "description": Property(), | ||||||
| "quota_limit": Property(), | ||||||
| "resource_metric": Property(), | ||||||
| "quota_type": Property(), | ||||||
| "has_usage": Property(), | ||||||
| } | ||||||
|
|
||||||
| def usage(self): | ||||||
|
|
@@ -614,3 +616,41 @@ def usage(self): | |||||
| ) | ||||||
|
|
||||||
| return ObjectStorageQuotaUsage.from_json(result) | ||||||
|
|
||||||
|
|
||||||
| class ObjectStorageGlobalQuota(Base): | ||||||
| """ | ||||||
| An account-level Object Storage quota. | ||||||
|
|
||||||
| API documentation: TBD | ||||||
|
Comment on lines
+624
to
+625
|
||||||
| API documentation: TBD |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "quota_id": "obj-access-keys-per-account", | ||
| "quota_type": "obj-access-keys", | ||
| "quota_name": "Object Storage Access Keys per Account", | ||
| "description": "Maximum number of access keys this customer is allowed to have on their account.", | ||
| "resource_metric": "access_key", | ||
| "quota_limit": 100, | ||
| "has_usage": true | ||
| }, | ||
| { | ||
| "quota_id": "obj-total-capacity-per-account", | ||
| "quota_type": "obj-total-capacity", | ||
| "quota_name": "Object Storage Total Capacity per Account", | ||
| "description": "Maximum total storage capacity in bytes this customer is allowed on their account.", | ||
| "resource_metric": "byte", | ||
| "quota_limit": 1099511627776, | ||
| "has_usage": true | ||
| } | ||
| ], | ||
| "page": 1, | ||
| "pages": 1, | ||
| "results": 2 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "quota_id": "obj-access-keys-per-account", | ||
| "quota_type": "obj-access-keys", | ||
| "quota_name": "Object Storage Access Keys per Account", | ||
| "description": "Maximum number of access keys this customer is allowed to have on their account.", | ||
| "resource_metric": "access_key", | ||
| "quota_limit": 100, | ||
| "has_usage": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "quota_limit": 100, | ||
| "usage": 25 | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||
| import pytest | ||||
|
|
||||
| from linode_api4.errors import ApiError | ||||
| from linode_api4.objects.object_storage import ( | ||||
| ObjectStorageGlobalQuota, | ||||
| ObjectStorageQuota, | ||||
| ObjectStorageQuotaUsage, | ||||
| ) | ||||
|
|
@@ -25,6 +27,8 @@ def test_list_and_get_obj_storage_quotas(test_linode_client): | |||
| assert found_quota.description == get_quota.description | ||||
| assert found_quota.quota_limit == get_quota.quota_limit | ||||
| assert found_quota.resource_metric == get_quota.resource_metric | ||||
| assert found_quota.quota_type == get_quota.quota_type | ||||
| assert found_quota.has_usage == get_quota.has_usage | ||||
|
|
||||
|
|
||||
| def test_get_obj_storage_quota_usage(test_linode_client): | ||||
|
|
@@ -33,7 +37,22 @@ def test_get_obj_storage_quota_usage(test_linode_client): | |||
| if len(quotas) < 1: | ||||
| pytest.skip("No available quota for testing. Skipping now...") | ||||
|
|
||||
| quota_id = quotas[0].quota_id | ||||
| quota_with_usage = next( | ||||
| (quota for quota in quotas if quota.has_usage), None | ||||
| ) | ||||
|
|
||||
| if quota_with_usage is None: | ||||
| quota_id = quotas[0].quota_id | ||||
| quota = test_linode_client.load(ObjectStorageQuota, quota_id) | ||||
|
|
||||
| with pytest.raises(ApiError) as exc: | ||||
| quota.usage() | ||||
|
|
||||
| assert exc.value.status == 404 | ||||
| assert "Usage not supported" in str(exc.value) | ||||
|
||||
| assert "Usage not supported" in str(exc.value) |
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here: asserting the exact error message substring makes the test brittle. Prefer checking status==404 and (optionally) structured error details instead of relying on str(ApiError) content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new group method docstring still says "API Documentation: TBD". Please replace it with the correct techdocs link (or remove the line) to avoid shipping placeholder documentation for a public API.