Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import absolute_import, division, print_function
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_access_rule_facts
33 short_description: Get access-rule objects facts on Check Point over Web Services API
34 description:
35 - Get access-rule objects facts on Check Point devices.
36 - All operations are performed over Web Services API.
37 - This module handles both operations, get a specific object and get several objects,
38 For getting a specific object use the parameter 'name'.
39 - Available from R80 management version.
40 version_added: "1.0.0"
41 author: "Or Soffer (@chkp-orso)"
42 options:
43 name:
44 description:
45 - Object name. Should be unique in the domain.
46 type: str
47 layer:
48 description:
49 - Layer that the rule belongs to identified by the name or UID.
50 type: str
51 show_as_ranges:
52 description:
53 - When true, the source, destination and services & applications parameters are displayed as ranges of IP addresses and port numbers rather than
54 network objects.<br /> Objects that are not represented using IP addresses or port numbers are presented as objects.<br /> In addition, the response
55 of each rule does not contain the parameters, source, source-negate, destination, destination-negate, service and service-negate, but instead it
56 contains the parameters, source-ranges, destination-ranges and service-ranges.<br /><br /> Note, Requesting to show rules as ranges is limited up to
57 20 rules per request, otherwise an error is returned. If you wish to request more rules, use the offset and limit parameters to limit your request.
58 - Available from R80.20 management version.
59 type: bool
60 show_hits:
61 description:
62 - N/A
63 type: bool
64 hits_settings:
65 description:
66 - N/A
67 type: dict
68 suboptions:
69 from_date:
70 description:
71 - Format, 'YYYY-MM-DD', 'YYYY-mm-ddThh:mm:ss'.
72 type: str
73 target:
74 description:
75 - Target gateway name or UID.
76 type: str
77 to_date:
78 description:
79 - Format, 'YYYY-MM-DD', 'YYYY-mm-ddThh:mm:ss'.
80 type: str
81 details_level:
82 description:
83 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
84 representation of the object.
85 type: str
86 choices: ['uid', 'standard', 'full']
87 filter:
88 description:
89 - Search expression to filter the rulebase. The provided text should be exactly the same as it would be given in Smart Console. The logical
90 operators in the expression ('AND', 'OR') should be provided in capital letters. If an operator is not used, the default OR operator applies.
91 type: str
92 filter_settings:
93 description:
94 - Sets filter preferences.
95 - Available from R80.10 management version.
96 type: dict
97 suboptions:
98 search_mode:
99 description:
100 - When set to 'general', both the Full Text Search and Packet Search are enabled. In this mode, Packet Search will not match on 'Any'
101 object, a negated cell or a group-with-exclusion. When the search-mode is set to 'packet', by default, the match on 'Any' object, a negated cell
102 or a group-with-exclusion are enabled. packet-search-settings may be provided to change the default behavior.
103 type: str
104 choices: ['general', 'packet']
105 packet_search_settings:
106 description:
107 - When 'search-mode' is set to 'packet', this object allows to set the packet search preferences.
108 type: dict
109 suboptions:
110 expand_group_members:
111 description:
112 - When true, if the search expression contains a UID or a name of a group object, results will include rules that match on at
113 least one member of the group.
114 - Available from R80.20 management version.
115 type: bool
116 expand_group_with_exclusion_members:
117 description:
118 - When true, if the search expression contains a UID or a name of a group-with-exclusion object, results will include rules that
119 match at least one member of the "include" part and is not a member of the "except" part.
120 - Available from R80.20 management version.
121 type: bool
122 match_on_any:
123 description:
124 - Whether to match on 'Any' object.
125 type: bool
126 match_on_group_with_exclusion:
127 description:
128 - Whether to match on a group-with-exclusion.
129 type: bool
130 match_on_negate:
131 description:
132 - Whether to match on a negated cell.
133 type: bool
134 limit:
135 description:
136 - No more than that many results will be returned.
137 This parameter is relevant only for getting few objects.
138 - Valid values are between 1 and 500.
139 type: int
140 offset:
141 description:
142 - Skip that many results before beginning to return them.
143 This parameter is relevant only for getting few objects.
144 type: int
145 order:
146 description:
147 - Sorts results by the given field. By default the results are sorted in the ascending order by name.
148 This parameter is relevant only for getting few objects.
149 type: list
150 elements: dict
151 suboptions:
152 ASC:
153 description:
154 - Sorts results by the given field in ascending order.
155 type: str
156 choices: ['name']
157 DESC:
158 description:
159 - Sorts results by the given field in descending order.
160 type: str
161 choices: ['name']
162 package:
163 description:
164 - Name of the package.
165 type: str
166 use_object_dictionary:
167 description:
168 - N/A
169 type: bool
170 dereference_group_members:
171 description:
172 - Indicates whether to dereference "members" field by details level for every object in reply.
173 - Available from R80.10 management version.
174 type: bool
175 show_membership:
176 description:
177 - Indicates whether to calculate and show "groups" field for every object in reply.
178 - Available from R80.10 management version.
179 type: bool
180 async_response:
181 description:
182 - Run command in asynchronous mode and return task UID. Use show-task command to check the progress of the task.
183 - Available with customized HF.
184 type: bool
185 default: false
186 version_added: "6.6.0"
187 wait_for_task:
188 description:
189 - Wait for the task to end. Such as publish task.
190 type: bool
191 default: True
192 version_added: "6.6.0"
193 wait_for_task_timeout:
194 description:
195 - How many minutes to wait until throwing a timeout error.
196 type: int
197 default: 30
198 version_added: "6.6.0"
199 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
200 """
201
202 EXAMPLES = """
203 - name: show-access-rule
204 cp_mgmt_access_rule_facts:
205 layer: Network
206 name: Rule 1
207
208 - name: show-access-rulebase
209 cp_mgmt_access_rule_facts:
210 details_level: standard
211 limit: 20
212 name: Network
213 offset: 0
214 use_object_dictionary: true
215 """
216
217 RETURN = """
218 ansible_facts:
219 description: The checkpoint object facts.
220 returned: always.
221 type: dict
222 """
223
224 from ansible.module_utils.basic import AnsibleModule
225 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
226 checkpoint_argument_spec_for_facts,
227 api_call_facts_for_rule,
228 )
229
230
231 def main():
232 argument_spec = dict(
233 name=dict(type="str"),
234 layer=dict(type="str"),
235 show_as_ranges=dict(type="bool"),
236 show_hits=dict(type="bool"),
237 hits_settings=dict(
238 type="dict",
239 options=dict(
240 from_date=dict(type="str"),
241 target=dict(type="str"),
242 to_date=dict(type="str"),
243 ),
244 ),
245 details_level=dict(type="str", choices=["uid", "standard", "full"]),
246 filter=dict(type="str"),
247 filter_settings=dict(
248 type="dict",
249 options=dict(
250 search_mode=dict(type="str", choices=["general", "packet"]),
251 packet_search_settings=dict(
252 type="dict",
253 options=dict(
254 expand_group_members=dict(type="bool"),
255 expand_group_with_exclusion_members=dict(type="bool"),
256 match_on_any=dict(type="bool"),
257 match_on_group_with_exclusion=dict(type="bool"),
258 match_on_negate=dict(type="bool"),
259 ),
260 ),
261 ),
262 ),
263 limit=dict(type="int"),
264 offset=dict(type="int"),
265 order=dict(
266 type="list",
267 elements="dict",
268 options=dict(
269 ASC=dict(type="str", choices=["name"]),
270 DESC=dict(type="str", choices=["name"]),
271 ),
272 ),
273 package=dict(type="str"),
274 use_object_dictionary=dict(type="bool"),
275 dereference_group_members=dict(type="bool"),
276 show_membership=dict(type="bool"),
277 async_response=dict(type="bool", default=False),
278 wait_for_task=dict(type="bool", default=True),
279 wait_for_task_timeout=dict(type="int", default=30),
280 )
281 argument_spec.update(checkpoint_argument_spec_for_facts)
282
283 module = AnsibleModule(
284 argument_spec=argument_spec, supports_check_mode=True
285 )
286
287 api_call_object = "access-rule"
288 api_call_object_plural_version = "access-rulebase"
289
290 result = api_call_facts_for_rule(
291 module, api_call_object, api_call_object_plural_version
292 )
293 module.exit_json(ansible_facts=result)
294
295
296 if __name__ == "__main__":
297 main()