Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_threat_layers.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2022 Red Hat
4 # GNU General Public License v3.0+
5 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 """
8 The module file for cp_mgmt_threat_layers
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13 __metaclass__ = type
14
15 DOCUMENTATION = """
16 module: cp_mgmt_threat_layers
17 short_description: Manages THREAT LAYERS resource module
18 description:
19 - This resource module allows for addition, deletion, or modification of CP Threat Layers.
20 - This resource module also takes care of gathering Threat Layers config facts
21 - Available from R80 management version.
22 version_added: "5.0.0"
23 author: Ansible Security Automation Team (@justjais) <https://github.com/ansible-security>-
24 options:
25 config:
26 description: A dictionary of THREAT LAYERS options
27 type: dict
28 suboptions:
29 name:
30 description: Object name. Must be unique in the domain.
31 type: str
32 add_default_rule:
33 description: Indicates whether to include a default rule in the new layer.
34 type: bool
35 tags:
36 description: Collection of tag identifiers.
37 type: list
38 elements: str
39 color:
40 description: Color of the object. Should be one of existing colors.
41 type: str
42 choices:
43 - aquamarine
44 - black
45 - blue
46 - crete blue
47 - burlywood
48 - cyan
49 - dark green
50 - khaki
51 - orchid
52 - dark orange
53 - dark sea green
54 - pink
55 - turquoise
56 - dark blue
57 - firebrick
58 - brown
59 - forest green
60 - gold
61 - dark gold
62 - gray
63 - dark gray
64 - light green
65 - lemon chiffon
66 - coral
67 - sea green
68 - sky blue
69 - magenta
70 - purple
71 - slate blue
72 - violet red
73 - navy blue
74 - olive
75 - orange
76 - red
77 - sienna
78 - yellow
79 comments:
80 description: Comments string.
81 type: str
82 details_level:
83 description: The level of detail for some of the fields in the response can
84 vary from showing only the UID value of the object to a fully detailed representation
85 of the object.
86 type: str
87 choices:
88 - uid
89 - standard
90 - full
91 ignore_warnings:
92 description: Apply changes ignoring warnings.
93 type: bool
94 ignore_errors:
95 description: Apply changes ignoring errors. You won't be able to publish such
96 a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
97 type: bool
98 limit:
99 description:
100 - The maximal number of returned results.
101 - NOTE, this parameter is a valid parameter only for the GATHERED state, for config states
102 like, MERGED, REPLACED, and DELETED state it won't be applicable.
103 type: int
104 offset:
105 description:
106 - Number of the results to initially skip.
107 - NOTE, this parameter is a valid parameter only for the GATHERED state, for config states
108 like, MERGED, REPLACED, and DELETED state it won't be applicable.
109 type: int
110 order:
111 description:
112 - Sorts results by the given field. By default the results are sorted in the ascending order by name.
113 This parameter is relevant only for getting few objects.
114 - NOTE, this parameter is a valid parameter only for the GATHERED state, for config states
115 like, MERGED, REPLACED, and DELETED state it won't be applicable.
116 type: list
117 elements: dict
118 suboptions:
119 ASC:
120 description:
121 - Sorts results by the given field in ascending order.
122 type: str
123 DESC:
124 description:
125 - Sorts results by the given field in descending order.
126 type: str
127 round_trip:
128 description:
129 - If set to True, the round trip will filter out the module parameters from the response param,
130 which will enable the user to fire the config request using the structured gathered data.
131 - NOTE, this parameter makes relevance only with the GATHERED state, as for config states like,
132 MERGED, REPLACED, and DELETED state it won't make any config updates,
133 as it's not a module config parameter.
134 auto_publish_session:
135 description:
136 - Publish the current session if changes have been performed
137 after task completes.
138 type: bool
139 version:
140 description:
141 - Version of checkpoint. If not given one, the latest version taken.
142 type: str
143 state:
144 description:
145 - The state the configuration should be left in
146 - The state I(gathered) will get the module API configuration from the device
147 and transform it into structured data in the format as per the module argspec
148 and the value is returned in the I(gathered) key within the result.
149 type: str
150 choices:
151 - merged
152 - replaced
153 - gathered
154 - deleted
155 """
156
157 EXAMPLES = """
158
159 # Using MERGED state
160 # -------------------
161
162 - name: To Add Merge Threat-Layers config
163 cp_mgmt_threat_layers:
164 state: merged
165 config:
166 name: New Layer 1
167 add_default_rule: true
168 tags:
169 - test_threat_layer
170 color: turquoise
171 comments: test description
172 ignore_warnings: false
173 ignore_errors: false
174 round_trip: true
175
176 # RUN output:
177 # -----------
178
179 # mgmt_threat_layers:
180 # after:
181 # color: turquoise
182 # comments: test description
183 # icon: ApplicationFirewall/rulebase
184 # ips-layer: false
185 # name: New Layer 1
186 # tags:
187 # - test_threat_layer
188 # before: {}
189
190 # Using REPLACED state
191 # --------------------
192
193 - name: Replace Threat-layer config
194 cp_mgmt_threat_layers:
195 state: replaced
196 config:
197 name: New Layer 1
198 add_default_rule: true
199 tags:
200 - test_threat_layer_replaced
201 color: cyan
202 comments: REPLACED description
203 ignore_warnings: false
204 ignore_errors: false
205 round_trip: true
206
207 # RUN output:
208 # -----------
209
210 # mgmt_threat_layers:
211 # after:
212 # color: cyan
213 # comments: REPLACED description
214 # icon: ApplicationFirewall/rulebase
215 # ips-layer: false
216 # name: New Layer 1
217 # tags:
218 # - test_threat_layer_replaced
219 # before:
220 # color: turquoise
221 # comments: test description
222 # icon: ApplicationFirewall/rulebase
223 # ips-layer: false
224 # name: New Layer 1
225 # tags:
226 # - test_threat_layer
227
228 # Using GATHERED state
229 # --------------------
230
231 # 1. With Round Trip set to True
232
233 - name: To Gather threat-layer by Name
234 cp_mgmt_threat_layers:
235 config:
236 name: New Layer 1
237 round_trip: true
238 state: gathered
239
240 # RUN output:
241 # -----------
242
243 # gathered:
244 # color: turquoise
245 # comments: test description
246 # domain: SMC User
247 # icon: ApplicationFirewall/rulebase
248 # ips-layer: false
249 # name: New Layer 1
250 # read-only: false
251 # tags:
252 # - test_threat_layer
253 # uid: 4dc060e2-0ed6-48c5-9b0f-3d2fbeb552ba
254
255 # 2. With Round Trip set to False which is the default behaviour
256
257 - name: To Gather threat-layer by Name
258 cp_mgmt_threat_layers:
259 config:
260 name: New Layer 1
261 state: gathered
262
263 # RUN output:
264 # -----------
265
266 # gathered:
267 # color: turquoise
268 # comments: test description
269 # domain:
270 # domain-type: domain
271 # name: SMC User
272 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
273 # icon: ApplicationFirewall/rulebase
274 # ips-layer: false
275 # meta-info:
276 # creation-time:
277 # iso-8601: 2022-11-21T07:30+0000
278 # posix: 1669015820472
279 # creator: admin
280 # last-modifier: admin
281 # last-modify-time:
282 # iso-8601: 2022-11-21T07:30+0000
283 # posix: 1669015821024
284 # lock: unlocked
285 # validation-state: ok
286 # name: New Layer 1
287 # read-only: false
288 # tags:
289 # - domain:
290 # domain-type: domain
291 # name: SMC User
292 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
293 # name: test_threat_layer
294 # type: tag
295 # uid: 59f23149-ed5e-439f-9012-0cdf222a1c97
296 # type: threat-layer
297 # uid: ca196a80-fdc4-4e7b-8b25-e3eed125a25f
298
299 # 3. Gather ALL threat-layer config with DESC order filter
300
301 - name: To Gather ALL threat-layer and order by Name
302 cp_mgmt_threat_layers:
303 config:
304 order:
305 - DESC: name
306 state: gathered
307
308 # RUN output:
309 # -----------
310
311 # gathered:
312 # - color: black
313 # comments: ''
314 # domain:
315 # domain-type: domain
316 # name: SMC User
317 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
318 # icon: ApplicationFirewall/sharedrulebase
319 # ips-layer: true
320 # meta-info:
321 # creation-time:
322 # iso-8601: 2020-01-20T09:43+0000
323 # posix: 1579513387322
324 # creator: System
325 # last-modifier: System
326 # last-modify-time:
327 # iso-8601: 2020-01-20T09:43+0000
328 # posix: 1579513387377
329 # lock: unlocked
330 # validation-state: ok
331 # name: IPS
332 # read-only: false
333 # tags: []
334 # type: threat-layer
335 # uid: 90678011-1bcb-4296-8154-fa58c23ecf3b
336 # - color: black
337 # comments: ''
338 # domain:
339 # domain-type: domain
340 # name: SMC User
341 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
342 # icon: ApplicationFirewall/rulebase
343 # ips-layer: false
344 # meta-info:
345 # creation-time:
346 # iso-8601: 2020-01-20T09:43+0000
347 # posix: 1579513386848
348 # creator: System
349 # last-modifier: System
350 # last-modify-time:
351 # iso-8601: 2020-01-20T09:43+0000
352 # posix: 1579513387396
353 # lock: unlocked
354 # validation-state: ok
355 # name: Standard Threat Prevention
356 # read-only: false
357 # tags: []
358 # type: threat-layer
359 # uid: 0dbe7c44-6d3f-4f28-8f2b-0e6790e57f8a
360
361 # Using DELETED state
362 # -------------------
363
364 - name: Delete Threat-layer config by Name and Layer
365 cp_mgmt_threat_layers:
366 config:
367 layer: IPS
368 name: First threat layer
369 round_trip: true
370 state: deleted
371
372 # RUN output:
373 # -----------
374
375 # mgmt_threat_layers:
376 # after: {}
377 # before:
378 # action: Optimized
379 # comments: This is the THREAT RULE
380 # destination:
381 # - Any
382 # destination_negate: false
383 # enabled: true
384 # install_on:
385 # - Policy Targets
386 # layer: 90678011-1bcb-4296-8154-fa58c23ecf3b
387 # name: First threat layer
388 # protected_scope:
389 # - All_Internet
390 # protected_scope_negate: false
391 # service:
392 # - Any
393 # service_negate: false
394 # source:
395 # - Any
396 # source_negate: false
397 # track: None
398 # track_settings:
399 # packet_capture: true
400 """
401
402 RETURN = """
403 before:
404 description: The configuration prior to the module execution.
405 returned: when state is I(merged), I(replaced), I(deleted)
406 type: dict
407 sample: >
408 This output will always be in the same format as the
409 module argspec.
410 after:
411 description: The resulting configuration after module execution.
412 returned: when changed
413 type: dict
414 sample: >
415 This output will always be in the same format as the
416 module argspec.
417 gathered:
418 description: Facts about the network resource gathered from the remote device as structured data.
419 returned: when state is I(gathered)
420 type: dict
421 sample: >
422 This output will always be in the same format as the
423 module argspec.
424 """