Debian Codegraph @

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

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