-
Notifications
You must be signed in to change notification settings - Fork 321
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
Add UserTags support to list_objects API #1381
Add UserTags support to list_objects API #1381
Conversation
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.
Filtering objects by any parameter should be done outside of minio-py
. Please keep the PR focusing on adding UserTags
support.
@balamurugana out of interest how come filtering by UserTags should be done outside of minio-py? The list_objects function has a prefix parameter that allows you to filter by path. How come that is different to filtering by UserTags? The filtering I have added here is optional. So the original functionality of the function is preserved. |
Filtering by |
7bcf676
to
9c6d2d6
Compare
minio/datatypes.py
Outdated
@@ -132,6 +133,7 @@ def __init__( # pylint: disable=too-many-arguments | |||
owner_name: str | None = None, | |||
content_type: str | None = None, | |||
is_delete_marker: bool = False, | |||
tags: Tags = Tags.new_object_tags(), |
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.
It should be tags: Tags | None = None
minio/commonconfig.py
Outdated
@@ -83,6 +83,16 @@ def fromxml(cls: Type[A], element: ET.Element) -> A: | |||
obj[key] = value | |||
return obj | |||
|
|||
@classmethod | |||
def object_from_user_tags_text(cls: Type[A], string: str | None) -> A: |
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.
Remove this method and move the logic into https://github.com/minio/minio-py/pull/1381/files#diff-321a5d1087d9a70eb00a39c6bfe8b7295ff787da4efe97f7fe7fd16aed5c2df3R265
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.
import List
, Tuple
, Any
at line no. 30
Can I get a second review please |
This adds the tags property to the Object class which can be set in the constructor of the class. This defaults to an empty Tags class.
The http response already contains the tags in the xml response under the text in the "UserTags" key. The fromxml method has been modified to set the tags to a populated version of the Tags class. This used the added Tags.object_from_user_tags_text method.
The Tags.object_from_user_tags_text method is a new method that creates a Tags class instance for Objects from a string in the format "key1=value1&key2=value2". This is the format the tags are in the text of the "UserTags" key.