feat: Add ownership parameter to storage collection listing methods#696
feat: Add ownership parameter to storage collection listing methods#696
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #696 +/- ##
==========================================
+ Coverage 94.79% 94.84% +0.04%
==========================================
Files 45 45
Lines 4403 4405 +2
==========================================
+ Hits 4174 4178 +4
+ Misses 229 227 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tobice
left a comment
There was a problem hiding this comment.
Thanks Nish!
From my PoV, it's just piping the param to API, which makes sense. I'll leave the Python stuff to the tooling team.
vdusek
left a comment
There was a problem hiding this comment.
Looks good, just one small thing:
Could you please move the definition of the ownership type
Literal['ownedByMe', 'sharedWithMe']
to a _types.py and give it a name?
This is the preferred approach for now. In the future, it should be derived from the specs and live in _models.py, but _types.py is currently the right place for manually defined types.
Thanks.
| StorageOwnership = Literal['ownedByMe', 'sharedWithMe'] | ||
| """Filter for storage listing methods to return only storages owned by the user or shared with the user.""" |
There was a problem hiding this comment.
I was wondering whether we should have a conversion mechanism between snake_case and camelCase for literal values. But we already have camelCase values in the codebase, e.g.:
sort_by: Literal['createdAt', 'stats.lastRunStartedAt'] | None = 'createdAt'So let's merge this as-is.
However, we should consider whether to introduce such a mechanism before v3 - allowing snake_case values in the Python interface and converting them to camelCase for the API under the hood.
cc @janbuchar , @Pijukatel
Description
Adds an
ownershipquery parameter (ownedByMe | sharedWithMe) to thelist()method onDatasetCollectionClient,KeyValueStoreCollectionClient, andRequestQueueCollectionClient(both sync and async variants). This allows filtering listed storages by whether they are owned by the user or shared with the user.Testing
Includes unit tests verifying the parameter is correctly passed through to the API request for all three storage types.