Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_threat_exception_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_threat_exception_facts
33 short_description: Get threat-exception objects facts on Check Point over Web Services API
34 description:
35 - Get threat-exception 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 - The name of the layer containing the parent threat rule.
46 This parameter is relevant only for getting few objects.
47 type: str
48 exception_group_uid:
49 description:
50 - The UID of the exception-group.
51 type: str
52 exception_group_name:
53 description:
54 - The name of the exception-group.
55 type: str
56 layer:
57 description:
58 - Layer that the rule belongs to identified by the name or UID.
59 type: str
60 rule_name:
61 description:
62 - The name of the parent rule.
63 type: str
64 details_level:
65 description:
66 - 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
67 representation of the object.
68 type: str
69 choices: ['uid', 'standard', 'full']
70 filter:
71 description:
72 - Search expression to filter the rulebase. The provided text should be exactly the same as it would be given in Smart Console. The logical
73 operators in the expression ('AND', 'OR') should be provided in capital letters. If an operator is not used, the default OR operator applies.
74 - Available from R80.10 management version.
75 type: str
76 filter_settings:
77 description:
78 - Sets filter preferences.
79 type: dict
80 suboptions:
81 search_mode:
82 description:
83 - When set to 'general', both the Full Text Search and Packet Search are enabled. In this mode, Packet Search will not match on 'Any'
84 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
85 or a group-with-exclusion are enabled. packet-search-settings may be provided to change the default behavior.
86 type: str
87 choices: ['general', 'packet']
88 packet_search_settings:
89 description:
90 - When 'search-mode' is set to 'packet', this object allows to set the packet search preferences.
91 type: dict
92 suboptions:
93 expand_group_members:
94 description:
95 - When true, if the search expression contains a UID or a name of a group object, results will include rules that match on at
96 least one member of the group.
97 type: bool
98 expand_group_with_exclusion_members:
99 description:
100 - When true, if the search expression contains a UID or a name of a group-with-exclusion object, results will include rules that
101 match at least one member of the "include" part and is not a member of the "except" part.
102 type: bool
103 match_on_any:
104 description:
105 - Whether to match on 'Any' object.
106 type: bool
107 match_on_group_with_exclusion:
108 description:
109 - Whether to match on a group-with-exclusion.
110 type: bool
111 match_on_negate:
112 description:
113 - Whether to match on a negated cell.
114 type: bool
115 limit:
116 description:
117 - No more than that many results will be returned.
118 This parameter is relevant only for getting few objects.
119 type: int
120 offset:
121 description:
122 - Skip that many results before beginning to return them.
123 This parameter is relevant only for getting few objects.
124 type: int
125 order:
126 description:
127 - Sorts results by the given field. By default the results are sorted in the ascending order by name.
128 This parameter is relevant only for getting few objects.
129 type: list
130 elements: dict
131 suboptions:
132 ASC:
133 description:
134 - Sorts results by the given field in ascending order.
135 type: str
136 choices: ['name']
137 DESC:
138 description:
139 - Sorts results by the given field in descending order.
140 type: str
141 choices: ['name']
142 package:
143 description:
144 - Name of the package.
145 type: str
146 use_object_dictionary:
147 description:
148 - N/A
149 type: bool
150 dereference_group_members:
151 description:
152 - Indicates whether to dereference "members" field by details level for every object in reply.
153 - Available from R80.10 management version.
154 type: bool
155 show_membership:
156 description:
157 - Indicates whether to calculate and show "groups" field for every object in reply.
158 - Available from R80.10 management version.
159 type: bool
160 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
161 """
162
163 EXAMPLES = """
164 - name: show-threat-exception
165 cp_mgmt_threat_exception_facts:
166 name: Exception Rule
167 layer: New Layer 1
168 rule_name: Threat Rule 1
169
170 - name: show-threat-rule-exception-rulebase
171 cp_mgmt_threat_exception_facts:
172 name: Standard Threat Prevention
173 rule_name: Threat Rule 1
174 """
175
176 RETURN = """
177 ansible_facts:
178 description: The checkpoint object facts.
179 returned: always.
180 type: dict
181 """
182
183 from ansible.module_utils.basic import AnsibleModule
184 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
185 checkpoint_argument_spec_for_facts,
186 api_call_facts,
187 )
188
189
190 def main():
191 argument_spec = dict(
192 name=dict(type="str"),
193 exception_group_uid=dict(type="str"),
194 exception_group_name=dict(type="str"),
195 layer=dict(type="str"),
196 rule_name=dict(type="str"),
197 details_level=dict(type="str", choices=["uid", "standard", "full"]),
198 filter=dict(type="str"),
199 filter_settings=dict(
200 type="dict",
201 options=dict(
202 search_mode=dict(type="str", choices=["general", "packet"]),
203 packet_search_settings=dict(
204 type="dict",
205 options=dict(
206 expand_group_members=dict(type="bool"),
207 expand_group_with_exclusion_members=dict(type="bool"),
208 match_on_any=dict(type="bool"),
209 match_on_group_with_exclusion=dict(type="bool"),
210 match_on_negate=dict(type="bool"),
211 ),
212 ),
213 ),
214 ),
215 limit=dict(type="int"),
216 offset=dict(type="int"),
217 order=dict(
218 type="list",
219 elements="dict",
220 options=dict(
221 ASC=dict(type="str", choices=["name"]),
222 DESC=dict(type="str", choices=["name"]),
223 ),
224 ),
225 package=dict(type="str"),
226 use_object_dictionary=dict(type="bool"),
227 dereference_group_members=dict(type="bool"),
228 show_membership=dict(type="bool"),
229 )
230 argument_spec.update(checkpoint_argument_spec_for_facts)
231
232 module = AnsibleModule(
233 argument_spec=argument_spec, supports_check_mode=True
234 )
235
236 api_call_object = "threat-exception"
237 api_call_object_plural_version = "threat-rule-exception-rulebase"
238
239 result = api_call_facts(
240 module, api_call_object, api_call_object_plural_version
241 )
242 module.exit_json(ansible_facts=result)
243
244
245 if __name__ == "__main__":
246 main()