Debian Codegraph @

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