Skip to content

Commit

Permalink
adds _repair_tags() because the API…
Browse files Browse the repository at this point in the history
  • Loading branch information
gurubert committed Dec 7, 2023
1 parent 5fa70cc commit 427e85a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Binary file removed check_mk_api/check_mk_api-5.4.0.mkp
Binary file not shown.
Binary file added check_mk_api/check_mk_api-5.4.1.mkp
Binary file not shown.
12 changes: 10 additions & 2 deletions check_mk_api/lib/python3/checkmkapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def _site_creds(username=None):
'automation.secret')).read().strip()
return username, password

def _repair_tags(tags):
for tag in tags:
if "id" in tag:
if "ident" not in tag:
tag["ident"] = tag["id"]
del(tag["id"])
return tags

class CMKRESTAPI():
def __init__(self, site_url=None, api_user=None, api_secret=None):
"""Initialize a REST-API instance. URL, User and Secret can be automatically taken from local site if running as site user.
Expand Down Expand Up @@ -1119,7 +1127,7 @@ def create_host_tag_group(self, name, title, tags, topic = None, help = None):
params={
'ident': name,
'title': title,
'tags': tags,
'tags': _repair_tags(tags),
}
if topic:
params['topic'] = topic
Expand Down Expand Up @@ -1206,7 +1214,7 @@ def edit_host_tag_group(self, name, etag, title = None, topic = None, help = Non
if help:
params['help'] = help
if len(tags) > 0:
params['tags'] = tags
params['tags'] = _repair_tags(tags)
if params:
data, etag, resp = self._put_url(
f"objects/host_tag_group/{name}",
Expand Down

0 comments on commit 427e85a

Please sign in to comment.