Skip to content

Commit 5766d24

Browse files
authored
Split arguments that can accept either a String or list of objects to two (#82)
* Update version parameter name in simple-cluster * Remove uid param from publish module * Support 'top' and 'bottom' in position param * Add state param * Update galaxy.yml * Split arguments that can accept either a String or list of objects to two
1 parent 4cb218f commit 5766d24

File tree

5 files changed

+52
-15
lines changed

5 files changed

+52
-15
lines changed

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace: check_point
99
name: mgmt
1010

1111
# The version of the collection. Must be compatible with semantic versioning
12-
version: 3.0.0
12+
version: 3.1.0
1313

1414
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1515
readme: README.md

plugins/module_utils/checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def get_relevant_show_rulebase_command(api_call_object):
435435
return 'show-threat-rulebase'
436436
elif api_call_object == "threat-exception":
437437
return 'show-threat-rule-exception-rulebase'
438-
#uncomment code below when https & nat modules are added as crud modules
438+
# uncomment code below when https & nat modules are added as crud modules
439439
# elif api_call_object == 'nat-rule':
440440
# return 'show-nat-rulebase'
441441
# elif api_call_object == 'https-rule':

plugins/modules/cp_mgmt_access_role.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
- Object name.
4141
type: str
4242
required: True
43-
machines:
43+
machines_list:
4444
description:
4545
- Machines that can access the system.
4646
type: list
@@ -59,6 +59,11 @@
5959
description:
6060
- When source is "Active Directory" use "base-dn" to refine the query in AD database.
6161
type: str
62+
machines:
63+
description:
64+
- Any or All Identified.
65+
type: str
66+
choices: ['any', 'all identified']
6267
networks:
6368
description:
6469
- Collection of Network objects identified by the name or UID that can access the system.
@@ -73,7 +78,7 @@
7378
- Collection of tag identifiers.
7479
type: list
7580
elements: str
76-
users:
81+
users_list:
7782
description:
7883
- Users that can access the system.
7984
type: list
@@ -92,6 +97,11 @@
9297
description:
9398
- When source is "Active Directory" use "base-dn" to refine the query in AD database.
9499
type: str
100+
users:
101+
description:
102+
- Any or All Identified.
103+
type: str
104+
choices: ['any', 'all identified']
95105
color:
96106
description:
97107
- Color of the object. Should be one of existing colors.
@@ -123,7 +133,6 @@
123133
EXAMPLES = """
124134
- name: add-access-role
125135
cp_mgmt_access_role:
126-
machines: all identified
127136
name: New Access Role 1
128137
networks: any
129138
remote_access_clients: any
@@ -132,10 +141,11 @@
132141
133142
- name: set-access-role
134143
cp_mgmt_access_role:
135-
machines: any
144+
users_list:
145+
- source: "Internal User Groups"
146+
selection: usersGroup
136147
name: New Access Role 1
137148
state: present
138-
users: all identified
139149
140150
- name: delete-access-role
141151
cp_mgmt_access_role:
@@ -157,19 +167,21 @@
157167
def main():
158168
argument_spec = dict(
159169
name=dict(type='str', required=True),
160-
machines=dict(type='list', elements='dict', options=dict(
170+
machines_list=dict(type='list', elements='dict', options=dict(
161171
source=dict(type='str'),
162172
selection=dict(type='list', elements='str'),
163173
base_dn=dict(type='str')
164174
)),
175+
machines=dict(type='str', choices=['any', 'all identified']),
165176
networks=dict(type='list', elements='str'),
166177
remote_access_clients=dict(type='str'),
167178
tags=dict(type='list', elements='str'),
168-
users=dict(type='list', elements='dict', options=dict(
179+
users_list=dict(type='list', elements='dict', options=dict(
169180
source=dict(type='str'),
170181
selection=dict(type='list', elements='str'),
171182
base_dn=dict(type='str')
172183
)),
184+
users=dict(type='str', choices=['any', 'all identified']),
173185
color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
174186
'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
175187
'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
@@ -185,6 +197,18 @@ def main():
185197
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
186198
api_call_object = 'access-role'
187199

200+
if module.params["machines_list"] is not None:
201+
if module.params["machines"] is not None:
202+
raise AssertionError("The use of both 'machines_list' and 'machines' arguments isn't allowed")
203+
module.params["machines"] = module.params["machines_list"]
204+
module.params.pop("machines_list")
205+
206+
if module.params["users_list"] is not None:
207+
if module.params["users"] is not None:
208+
raise AssertionError("The use of both 'users_list' and 'users' arguments isn't allowed")
209+
module.params["users"] = module.params["users_list"]
210+
module.params.pop("users_list")
211+
188212
result = api_call(module, api_call_object)
189213
module.exit_json(**result)
190214

plugins/modules/cp_mgmt_access_rule.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
description:
219219
- N/A
220220
type: str
221-
vpn:
221+
vpn_list:
222222
description:
223223
- Communities or Directional.
224224
type: list
@@ -228,7 +228,7 @@
228228
description:
229229
- List of community name or UID.
230230
type: list
231-
elements: dict
231+
elements: str
232232
directional:
233233
description:
234234
- Communities directional match condition.
@@ -243,6 +243,11 @@
243243
description:
244244
- To community name or UID.
245245
type: str
246+
vpn:
247+
description:
248+
- Any or All_GwToGw.
249+
type: str
250+
choices: ['Any', 'All_GwToGw']
246251
comments:
247252
description:
248253
- Comments string.
@@ -273,6 +278,7 @@
273278
service:
274279
- SMTP
275280
- AOL
281+
vpn: All_GwToGw
276282
state: present
277283
278284
- name: set-access-rule
@@ -353,23 +359,30 @@ def main():
353359
frequency=dict(type='str', choices=['once a day', 'once a week', 'once a month', 'custom frequency...']),
354360
interaction=dict(type='str')
355361
)),
356-
vpn=dict(type='list', elements='dict', options=dict(
357-
community=dict(type='list', elements='dict'),
362+
vpn_list=dict(type='list', elements='dict', options=dict(
363+
community=dict(type='list', elements='str'),
358364
directional=dict(type='list', elements='dict', options=dict(
359365
to=dict(type='str')
360366
))
361367
)),
368+
vpn=dict(type='str', choices=['Any', 'All_GwToGw']),
362369
comments=dict(type='str'),
363370
details_level=dict(type='str', choices=['uid', 'standard', 'full']),
364371
ignore_warnings=dict(type='bool'),
365372
ignore_errors=dict(type='bool')
366373
)
367-
argument_spec['vpn']['options']['directional']['options']['from'] = dict(type='str')
374+
argument_spec['vpn_list']['options']['directional']['options']['from'] = dict(type='str')
368375
argument_spec.update(checkpoint_argument_spec_for_objects)
369376

370377
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
371378
api_call_object = 'access-rule'
372379

380+
if module.params["vpn_list"] is not None:
381+
if module.params["vpn"] is not None:
382+
raise AssertionError("The use of both 'vpn_list' and 'vpn' arguments isn't allowed")
383+
module.params["vpn"] = module.params["vpn_list"]
384+
module.params.pop("vpn_list")
385+
373386
if module.params['action'] is None and module.params['position'] is None:
374387
result = api_call(module, api_call_object)
375388
else:

plugins/modules/cp_mgmt_access_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,4 @@ def main():
370370

371371

372372
if __name__ == '__main__':
373-
main()
373+
main()

0 commit comments

Comments
 (0)