Skip to content

Commit

Permalink
Module util vmware_rest_client: Remove get_tag_by_category (#1899)
Browse files Browse the repository at this point in the history
Module util vmware_rest_client: Remove get_tag_by_category

SUMMARY
Fixes: #1898
Remove get_tag_by_category(). It's deprecated and not used anymore in the collection.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
vmware_rest_client
ADDITIONAL INFORMATION
#1605
  • Loading branch information
mariolenz authored Oct 26, 2023
1 parent 35d1674 commit d14eb30
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1898-vmware_rest_client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
breaking_changes:
- vmware_rest_client - Remove deprecated method `get_tag_by_category()` (https://github.com/ansible-collections/community.vmware/issues/1898).
33 changes: 0 additions & 33 deletions plugins/module_utils/vmware_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,36 +539,3 @@ def get_tag_by_category_name(self, tag_name=None, category_name=None):
category_id = category_obj.id

return self.get_tag_by_category_id(tag_name=tag_name, category_id=category_id)

def get_tag_by_category(self, tag_name=None, category_name=None, category_id=None):
"""
Return tag object by name and category name specified
Args:
tag_name: Name of tag
category_name: Name of category (mutually exclusive with 'category_id')
category_id: Id of category, if known in advance (mutually exclusive with 'category_name')
Returns: Tag object if found else None
"""
message = "The method 'get_tag_by_category' is deprecated and scheduled for removal. "\
"Please update your code and use 'get_tag_by_category_id' or 'get_tag_by_category_name' instead"
self.module.deprecate(message, version='4.0.0', collection_name='community.vmware')

if not tag_name:
return None

if category_id or category_name:
if not category_id:
category_obj = self.get_category_by_name(category_name=category_name)

if not category_obj:
return None

category_id = category_obj.id

for tag_object in self.api_client.tagging.Tag.list_tags_for_category(category_id):
tag_obj = self.api_client.tagging.Tag.get(tag_object)

if tag_obj.name == tag_name:
return tag_obj
else:
return self.search_svc_object_by_name(service=self.api_client.tagging.Tag, svc_obj_name=tag_name)

0 comments on commit d14eb30

Please sign in to comment.