Skip to content

Add global quotas and quota usage support for OBJ services#661

Open
zliang-akamai wants to merge 3 commits intolinode:devfrom
zliang-akamai:zhiwei/obj-quotas
Open

Add global quotas and quota usage support for OBJ services#661
zliang-akamai wants to merge 3 commits intolinode:devfrom
zliang-akamai:zhiwei/obj-quotas

Conversation

@zliang-akamai
Copy link
Member

📝 Description

Add support for OBJ quota and global quota udpates.

✔️ How to Test

pytest test/integration/models/object_storage/test_obj_quotas.py -v
make test-unit

@zliang-akamai zliang-akamai requested a review from a team as a code owner March 5, 2026 22:04
@zliang-akamai zliang-akamai requested review from ckulinsk and mawilk90 and removed request for a team March 5, 2026 22:04
@zliang-akamai zliang-akamai requested a review from Copilot March 6, 2026 05:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ObjectStorageGlobalQuota model with a usage() helper for global quota usage retrieval.
  • Expose quota_type and has_usage properties on ObjectStorageQuota, and add ObjectStorageGroup.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.

Comment on lines +624 to +625

API documentation: TBD
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
API documentation: TBD

Copilot uses AI. Check for mistakes.
Comment on lines +542 to +543
API Documentation: TBD

Copy link

Copilot AI Mar 6, 2026

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.

Suggested change
API Documentation: TBD

Copilot uses AI. Check for mistakes.
quota.usage()

assert exc.value.status == 404
assert "Usage not supported" in str(exc.value)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
assert "Usage not supported" in str(exc.value)

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +117
with pytest.raises(ApiError) as exc:
quota.usage()

assert exc.value.status == 404
assert "Usage not supported" in str(exc.value)
return
Copy link

Copilot AI Mar 6, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants