Abyss-lord commented on code in PR #10554:
URL: https://github.com/apache/gravitino/pull/10554#discussion_r3013033103
##########
clients/client-python/gravitino/client/dto_converters.py:
##########
@@ -285,3 +291,44 @@ def to_job_template_update_request(
return UpdateJobTemplateContentRequest(template_update_dto)
raise ValueError(f"Unknown change type: {type(change).__name__}")
+
+ @staticmethod
+ def to_tag_update_request(
+ change: TagChange,
+ ) -> tp.Union[
+ TagUpdateRequest.RenameTagRequest,
+ TagUpdateRequest.UpdateTagCommentRequest,
+ TagUpdateRequest.SetTagPropertyRequest,
+ TagUpdateRequest.RemoveTagPropertyRequest,
+ ]:
+ """
+ Convert the tag change to the corresponding tag update request.
+
+ Args:
+ change (TagChange): The tag change.
+
+ Raises:
+ ValueError: if the change type is not supported.
+
+ Returns:
+ tp.Union[ TagUpdateRequest.RenameTagRequest,
+ TagUpdateRequest.UpdateTagCommentRequest,
+ TagUpdateRequest.SetTagPropertyRequest,
+ TagUpdateRequest.RemoveTagPropertyRequest,
+ ]: The tag update request.
+ """
+ if isinstance(change, TagChange.RenameTag):
+ return TagUpdateRequest.RenameTagRequest(change.new_name)
+
+ if isinstance(change, TagChange.UpdateTagComment):
+ return TagUpdateRequest.UpdateTagCommentRequest(change.new_comment)
+
+ if isinstance(change, TagChange.SetProperty):
+ return TagUpdateRequest.SetTagPropertyRequest(
+ change.name,
+ change.value,
+ )
+ if isinstance(change, TagChange.RemoveProperty):
+ return
TagUpdateRequest.RemoveTagPropertyRequest(change.removed_property)
+
+ raise ValueError(f"Unknown change type: {type(change)}")
Review Comment:
fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]