From 64fc70433f9286bb48f0f364680f5faff11af9ae Mon Sep 17 00:00:00 2001 From: Mohamad Ghanem Date: Mon, 2 Dec 2024 11:55:39 +0100 Subject: [PATCH 1/4] add name_like to get config request --- plugins/modules/sentinelone_config_overrides.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/modules/sentinelone_config_overrides.py b/plugins/modules/sentinelone_config_overrides.py index a5a1bd9..0149b4c 100644 --- a/plugins/modules/sentinelone_config_overrides.py +++ b/plugins/modules/sentinelone_config_overrides.py @@ -6,6 +6,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type + DOCUMENTATION = ''' --- module: sentinelone_config_overrides @@ -172,7 +173,7 @@ from ansible_collections.sva.sentinelone.plugins.module_utils.sentinelone.sentinelone_base import SentineloneBase, lib_imp_errors from ansible.module_utils.six.moves.urllib.parse import quote_plus import copy - +#import urllib.parse class SentineloneConfigOverrides(SentineloneBase): def __init__(self, module: AnsibleModule): @@ -275,7 +276,9 @@ def get_current_config_override(self, module: AnsibleModule): else: query_options.append("versionOption=SPECIFIC") query_options.append(f"agentVersions={self.agent_version}") - + # Encode the parameters + encoded_params_name_like = quote_plus(self.config_override_name) + query_options.append(f"name__like={encoded_params_name_like}") query_uri = '&'.join(query_options) api_url = f"{self.api_endpoint_config_overrides}?{query_uri}" response = self.api_call(module, api_url, error_msg=error_msg) From 55b56aa469a4eb8eff8fcf8c780bda2bfa6ecbd9 Mon Sep 17 00:00:00 2001 From: Mohamad Ghanem Date: Mon, 2 Dec 2024 15:11:53 +0100 Subject: [PATCH 2/4] skip Encoding for config_override_name if is null or "" --- plugins/modules/sentinelone_config_overrides.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/modules/sentinelone_config_overrides.py b/plugins/modules/sentinelone_config_overrides.py index 0149b4c..f760fdb 100644 --- a/plugins/modules/sentinelone_config_overrides.py +++ b/plugins/modules/sentinelone_config_overrides.py @@ -276,9 +276,14 @@ def get_current_config_override(self, module: AnsibleModule): else: query_options.append("versionOption=SPECIFIC") query_options.append(f"agentVersions={self.agent_version}") - # Encode the parameters - encoded_params_name_like = quote_plus(self.config_override_name) - query_options.append(f"name__like={encoded_params_name_like}") + + if self.config_override_name is None or self.config_override_name == "": + query_options.append(f"name__like={self.config_override_name}") + else: + # Encode the parameters + encoded_params_name_like = quote_plus(self.config_override_name) + query_options.append(f"name__like={encoded_params_name_like}") + query_uri = '&'.join(query_options) api_url = f"{self.api_endpoint_config_overrides}?{query_uri}" response = self.api_call(module, api_url, error_msg=error_msg) From 384150316044166d0b49bea3dd74265a00bc0023 Mon Sep 17 00:00:00 2001 From: Mohamad Ghanem Date: Mon, 2 Dec 2024 15:53:20 +0100 Subject: [PATCH 3/4] Linting --- plugins/modules/sentinelone_config_overrides.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/sentinelone_config_overrides.py b/plugins/modules/sentinelone_config_overrides.py index f760fdb..83404f9 100644 --- a/plugins/modules/sentinelone_config_overrides.py +++ b/plugins/modules/sentinelone_config_overrides.py @@ -173,7 +173,6 @@ from ansible_collections.sva.sentinelone.plugins.module_utils.sentinelone.sentinelone_base import SentineloneBase, lib_imp_errors from ansible.module_utils.six.moves.urllib.parse import quote_plus import copy -#import urllib.parse class SentineloneConfigOverrides(SentineloneBase): def __init__(self, module: AnsibleModule): From 39076465d630e0079504293e11a25667bc2ad440 Mon Sep 17 00:00:00 2001 From: Mohamad Ghanem Date: Mon, 2 Dec 2024 16:00:48 +0100 Subject: [PATCH 4/4] add 2 blank lines --- plugins/modules/sentinelone_config_overrides.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/sentinelone_config_overrides.py b/plugins/modules/sentinelone_config_overrides.py index 83404f9..bc7ecbb 100644 --- a/plugins/modules/sentinelone_config_overrides.py +++ b/plugins/modules/sentinelone_config_overrides.py @@ -174,6 +174,7 @@ from ansible.module_utils.six.moves.urllib.parse import quote_plus import copy + class SentineloneConfigOverrides(SentineloneBase): def __init__(self, module: AnsibleModule): """