Skip to content

Commit 83f2603

Browse files
author
Shiva Shankar Vaddepally
committed
correcting GET url to include queryparameter args with type
Signed-off-by: Shiva Shankar Vaddepally <shivashankar.vaddepally@cloud.com>
1 parent 1442475 commit 83f2603

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

plugins/module_utils/common.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
HTTP_RESOURCE_ALREADY_EXISTS,
1414
HTTP_RESOURCE_NOT_FOUND,
1515
HTTP_SUCCESS_CODES,
16+
GLOBAL_BINDING_ARG_LIST
1617
)
1718
from .decorators import trace
1819
from .logger import log
1920
from .nitro_resource_map import NITRO_RESOURCE_MAP
2021

21-
2222
@trace
2323
def get_netscaler_version(client):
2424
is_exist, response = get_resource(client, "nsversion")
@@ -61,11 +61,21 @@ def get_resource(client, resource_name, resource_id=None, resource_module_params
6161

6262
if resource_name.endswith("_binding"):
6363
# binding resources require `filter` instead of `args` to uniquely identify a resource
64-
status_code, response_body = client.get(
65-
resource=resource_name,
66-
id=resource_id,
67-
filter=get_args,
68-
)
64+
if resource_name in GLOBAL_BINDING_ARG_LIST:
65+
# here we are making sure that for globalbindings present in the list query params args=type and filter=get_arg_keys
66+
del get_args["type"]
67+
status_code, response_body = client.get(
68+
resource=resource_name,
69+
id=resource_id,
70+
filter=get_args,
71+
args={"type": resource_module_params["type"]},
72+
)
73+
else:
74+
status_code, response_body = client.get(
75+
resource=resource_name,
76+
id=resource_id,
77+
filter=get_args,
78+
)
6979
elif resource_name in {"sslcertfile"}:
7080
status_code, response_body = client.get(
7181
resource=resource_name,

plugins/module_utils/constants.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,24 @@
114114
fallback=(env_fallback, ["MANAGED_NETSCALER_INSTANCE_PASSWORD"]),
115115
),
116116
)
117+
118+
# this list contains globalbindings whose GET call must have query params args=type and filter=get_arg_keys (check in nitro_resource_map)
119+
GLOBAL_BINDING_ARG_LIST = [
120+
'dnsglobal_dnspolicy_binding',
121+
'responderglobal_responderpolicy_binding',
122+
'contentinspectionglobal_contentinspectionpolicy_binding',
123+
'appflowglobal_appflowpolicy_binding',
124+
'appfwglobal_auditnslogpolicy_binding',
125+
'appfwglobal_auditsyslogpolicy_binding',
126+
'appfwglobal_appfwpolicy_binding',
127+
'rewriteglobal_rewritepolicy_binding',
128+
'transformglobal_transformpolicy_binding',
129+
'sslglobal_sslpolicy_binding',
130+
'tunnelglobal_tunneltrafficpolicy_binding',
131+
'cmpglobal_cmppolicy_binding',
132+
'feoglobal_feopolicy_binding',
133+
'icaglobal_icapolicy_binding',
134+
'lbglobal_lbpolicy_binding',
135+
'cacheglobal_cachepolicy_binding',
136+
'botglobal_botpolicy_binding',
137+
]

0 commit comments

Comments
 (0)