Skip to content

Commit

Permalink
feat: create folder with uid and parent_uid
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental committed Jun 26, 2024
1 parent a4fc0ef commit c1b14cd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/modules/grafana_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ def get_version(self):
return {"major": int(major), "minor": int(minor), "rev": int(rev)}
raise GrafanaError("Failed to retrieve version from '%s'" % url)

def create_folder(self, title):
def create_folder(self, title, uid=None, parent_uid=None):
url = "/api/folders"
folder = dict(title=title)
folder = dict(title=title, uid=uid, parentUid=parent_uid)
response = self._send_request(
url, data=folder, headers=self.headers, method="POST"
)
Expand Down Expand Up @@ -343,10 +343,9 @@ def main():

if state == "present":
if folder is None:
grafana_iface.create_folder(title)
folder = grafana_iface.get_folder(title)
grafana_iface.create_folder(title, uid, parent_uid)
folder = grafana_iface.get_folder(title, uid, parent_uid)
changed = True
folder = grafana_iface.get_folder(title)
module.exit_json(changed=changed, folder=folder)
elif state == "absent":
if folder is None:
Expand Down

0 comments on commit c1b14cd

Please sign in to comment.