Add global quotas and quota usage support for OBJ services#661
Add global quotas and quota usage support for OBJ services#661zliang-akamai wants to merge 3 commits intolinode:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds client-side support for Object Storage global (account-level) quotas and enriches existing Object Storage quota models with quota type and usage support metadata, along with corresponding unit/integration tests and fixtures.
Changes:
- Add
ObjectStorageGlobalQuotamodel with ausage()helper for global quota usage retrieval. - Expose
quota_typeandhas_usageproperties onObjectStorageQuota, and addObjectStorageGroup.global_quotas()for listing global quotas. - Extend unit/integration tests and fixtures to cover global quotas and the new quota fields.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
linode_api4/objects/object_storage.py |
Adds quota_type/has_usage to ObjectStorageQuota and introduces ObjectStorageGlobalQuota model + usage call. |
linode_api4/groups/object_storage.py |
Adds ObjectStorageGroup.global_quotas() collection method. |
test/unit/objects/object_storage_test.py |
Adds unit coverage for new quota fields and global quota get/list/usage flows. |
test/integration/models/object_storage/test_obj_quotas.py |
Extends integration coverage for quota_type/has_usage and adds global quota tests and 404 handling cases. |
test/fixtures/object-storage_quotas_obj-objects-us-ord-1.json |
Updates quota fixture to include quota_type and has_usage. |
test/fixtures/object-storage_quotas.json |
Updates quotas list fixture to include quota_type and has_usage. |
test/fixtures/object-storage_global-quotas.json |
Adds fixture for global quotas list endpoint. |
test/fixtures/object-storage_global-quotas_obj-access-keys-per-account.json |
Adds fixture for a single global quota GET endpoint. |
test/fixtures/object-storage_global-quotas_obj-access-keys-per-account_usage.json |
Adds fixture for global quota usage endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| API documentation: TBD |
There was a problem hiding this comment.
The docstring still contains "API documentation: TBD" for a newly added public model. Please replace "TBD" with the correct docs URL (or remove the line) so users can discover the corresponding list/get endpoints, similar to the usage() method docstring below.
| API documentation: TBD |
| API Documentation: TBD | ||
|
|
There was a problem hiding this comment.
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.
| API Documentation: TBD |
| quota.usage() | ||
|
|
||
| assert exc.value.status == 404 | ||
| assert "Usage not supported" in str(exc.value) |
There was a problem hiding this comment.
These integration tests assert a specific substring in the ApiError string ("Usage not supported"), which can be unstable across API versions and error formatting changes. To make the test less brittle, consider asserting only the HTTP status (404) and/or validating a structured field such as exc.value.errors when present, rather than matching the rendered message.
| assert "Usage not supported" in str(exc.value) |
| with pytest.raises(ApiError) as exc: | ||
| quota.usage() | ||
|
|
||
| assert exc.value.status == 404 | ||
| assert "Usage not supported" in str(exc.value) | ||
| return |
There was a problem hiding this comment.
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.
📝 Description
Add support for OBJ quota and global quota udpates.
✔️ How to Test