Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_trusted_client.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_trusted_client
33 short_description: Manages trusted-client objects on Checkpoint over Web Services API
34 description:
35 - Manages trusted-client objects on Checkpoint devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "2.1.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 ip_address:
47 description:
48 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
49 type: str
50 ipv4_address:
51 description:
52 - IPv4 address.
53 type: str
54 ipv6_address:
55 description:
56 - IPv6 address.
57 type: str
58 domains_assignment:
59 description:
60 - Domains to be added to this profile. Use domain name only. See example below, "add-trusted-client (with domain)".
61 type: list
62 elements: str
63 ip_address_first:
64 description:
65 - First IP address in the range. If both IPv4 and IPv6 address ranges are required, use the ipv4-address-first and the ipv6-address-first fields instead.
66 type: str
67 ipv4_address_first:
68 description:
69 - First IPv4 address in the range.
70 type: str
71 ipv6_address_first:
72 description:
73 - First IPv6 address in the range.
74 type: str
75 ip_address_last:
76 description:
77 - Last IP address in the range. If both IPv4 and IPv6 address ranges are required, use the ipv4-address-first and the ipv6-address-first fields instead.
78 type: str
79 ipv4_address_last:
80 description:
81 - Last IPv4 address in the range.
82 type: str
83 ipv6_address_last:
84 description:
85 - Last IPv6 address in the range.
86 type: str
87 mask_length:
88 description:
89 - IPv4 or IPv6 mask length. If both masks are required use mask-length4 and mask-length6 fields explicitly.
90 type: int
91 mask_length4:
92 description:
93 - IPv4 mask length.
94 type: int
95 mask_length6:
96 description:
97 - IPv6 mask length.
98 type: int
99 multi_domain_server_trusted_client:
100 description:
101 - Let this trusted client connect to all Multi-Domain Servers in the deployment.
102 type: bool
103 tags:
104 description:
105 - Collection of tag identifiers.
106 type: list
107 elements: str
108 type:
109 description:
110 - Trusted client type.
111 type: str
112 choices: ['any', 'domain', 'ipv4 address', 'ipv4 address range', 'ipv4 netmask', 'ipv6 address', 'ipv6 address range', 'ipv6 netmask', 'name',
113 'wild cards (ip only)']
114 wild_card:
115 description:
116 - IP wild card (e.g. 192.0.2.*).
117 type: str
118 color:
119 description:
120 - Color of the object. Should be one of existing colors.
121 type: str
122 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
123 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
124 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
125 comments:
126 description:
127 - Comments string.
128 type: str
129 details_level:
130 description:
131 - 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
132 representation of the object.
133 type: str
134 choices: ['uid', 'standard', 'full']
135 ignore_warnings:
136 description:
137 - Apply changes ignoring warnings.
138 type: bool
139 ignore_errors:
140 description:
141 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
142 type: bool
143 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
144 """
145
146 EXAMPLES = """
147 - name: add-trusted-client
148 cp_mgmt_trusted_client:
149 name: my client
150 state: present
151 type: ANY
152
153 - name: set-trusted-client
154 cp_mgmt_trusted_client:
155 ip_address: 192.0.2.1
156 mask_length: '24'
157 name: my client
158 state: present
159 type: NETMASK
160
161 - name: delete-trusted-client
162 cp_mgmt_trusted_client:
163 name: my client
164 state: absent
165 """
166
167 RETURN = """
168 cp_mgmt_trusted_client:
169 description: The checkpoint object created or updated.
170 returned: always, except when deleting the object.
171 type: dict
172 """
173
174 from ansible.module_utils.basic import AnsibleModule
175 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
176 checkpoint_argument_spec_for_objects,
177 api_call,
178 )
179
180
181 def main():
182 argument_spec = dict(
183 name=dict(type="str", required=True),
184 ip_address=dict(type="str"),
185 ipv4_address=dict(type="str"),
186 ipv6_address=dict(type="str"),
187 domains_assignment=dict(type="list", elements="str"),
188 ip_address_first=dict(type="str"),
189 ipv4_address_first=dict(type="str"),
190 ipv6_address_first=dict(type="str"),
191 ip_address_last=dict(type="str"),
192 ipv4_address_last=dict(type="str"),
193 ipv6_address_last=dict(type="str"),
194 mask_length=dict(type="int"),
195 mask_length4=dict(type="int"),
196 mask_length6=dict(type="int"),
197 multi_domain_server_trusted_client=dict(type="bool"),
198 tags=dict(type="list", elements="str"),
199 type=dict(
200 type="str",
201 choices=[
202 "any",
203 "domain",
204 "ipv4 address",
205 "ipv4 address range",
206 "ipv4 netmask",
207 "ipv6 address",
208 "ipv6 address range",
209 "ipv6 netmask",
210 "name",
211 "wild cards (ip only)",
212 ],
213 ),
214 wild_card=dict(type="str"),
215 color=dict(
216 type="str",
217 choices=[
218 "aquamarine",
219 "black",
220 "blue",
221 "crete blue",
222 "burlywood",
223 "cyan",
224 "dark green",
225 "khaki",
226 "orchid",
227 "dark orange",
228 "dark sea green",
229 "pink",
230 "turquoise",
231 "dark blue",
232 "firebrick",
233 "brown",
234 "forest green",
235 "gold",
236 "dark gold",
237 "gray",
238 "dark gray",
239 "light green",
240 "lemon chiffon",
241 "coral",
242 "sea green",
243 "sky blue",
244 "magenta",
245 "purple",
246 "slate blue",
247 "violet red",
248 "navy blue",
249 "olive",
250 "orange",
251 "red",
252 "sienna",
253 "yellow",
254 ],
255 ),
256 comments=dict(type="str"),
257 details_level=dict(type="str", choices=["uid", "standard", "full"]),
258 ignore_warnings=dict(type="bool"),
259 ignore_errors=dict(type="bool"),
260 )
261 argument_spec.update(checkpoint_argument_spec_for_objects)
262
263 module = AnsibleModule(
264 argument_spec=argument_spec, supports_check_mode=True
265 )
266 api_call_object = "trusted-client"
267
268 result = api_call(module, api_call_object)
269 module.exit_json(**result)
270
271
272 if __name__ == "__main__":
273 main()