From 4f4075a54287b0886be48b8b5a89bf5b75b4fe88 Mon Sep 17 00:00:00 2001 From: Nils Brinkmann Date: Sun, 12 May 2024 09:21:39 +0200 Subject: [PATCH] Added parameter to select Content-Type when accessing the Rundeck API (#7684) * Added parameter to select Content-Type when accessing the Rundeck API * Removed autogenerated file * Fixed missing yml extension * Updated changelog text better describe what has happened Co-authored-by: Felix Fontein --------- Co-authored-by: Nils Brinkmann Co-authored-by: Felix Fontein --- .gitignore | 4 ++++ changelogs/fragments/7683-added-contenttype-parameter.yml | 2 ++ plugins/module_utils/rundeck.py | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7683-added-contenttype-parameter.yml diff --git a/.gitignore b/.gitignore index b7868a9e41..cf1f74e41c 100644 --- a/.gitignore +++ b/.gitignore @@ -512,3 +512,7 @@ $RECYCLE.BIN/ # Integration tests cloud configs tests/integration/cloud-config-*.ini + + +# VSCode specific extensions +.vscode/settings.json diff --git a/changelogs/fragments/7683-added-contenttype-parameter.yml b/changelogs/fragments/7683-added-contenttype-parameter.yml new file mode 100644 index 0000000000..52f4b6b0c5 --- /dev/null +++ b/changelogs/fragments/7683-added-contenttype-parameter.yml @@ -0,0 +1,2 @@ +minor_changes: + - rundeck module utils - allow to pass ``Content-Type`` to API requests (https://github.com/ansible-collections/community.general/pull/7684). \ No newline at end of file diff --git a/plugins/module_utils/rundeck.py b/plugins/module_utils/rundeck.py index 7df68a3603..cffca7b4ee 100644 --- a/plugins/module_utils/rundeck.py +++ b/plugins/module_utils/rundeck.py @@ -28,7 +28,7 @@ def api_argument_spec(): return api_argument_spec -def api_request(module, endpoint, data=None, method="GET"): +def api_request(module, endpoint, data=None, method="GET", content_type="application/json"): """Manages Rundeck API requests via HTTP(S) :arg module: The AnsibleModule (used to get url, api_version, api_token, etc). @@ -63,7 +63,7 @@ def api_request(module, endpoint, data=None, method="GET"): data=json.dumps(data), method=method, headers={ - "Content-Type": "application/json", + "Content-Type": content_type, "Accept": "application/json", "X-Rundeck-Auth-Token": module.params["api_token"] }