Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_time.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_time
33 short_description: Manages time objects on Check Point over Web Services API
34 description:
35 - Manages time objects on Check Point 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: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 end:
47 description:
48 - End time. Note, Each gateway may interpret this time differently according to its time zone.
49 type: dict
50 suboptions:
51 date:
52 description:
53 - Date in format dd-MMM-yyyy.
54 type: str
55 iso_8601:
56 description:
57 - Date and time represented in international ISO 8601 format. Time zone information is ignored.
58 type: str
59 posix:
60 description:
61 - Number of milliseconds that have elapsed since 00,00,00, 1 January 1970.
62 type: int
63 time:
64 description:
65 - Time in format HH,mm.
66 type: str
67 end_never:
68 description:
69 - End never.
70 type: bool
71 hours_ranges:
72 description:
73 - Hours recurrence. Note, Each gateway may interpret this time differently according to its time zone.
74 type: list
75 elements: dict
76 suboptions:
77 enabled:
78 description:
79 - Is hour range enabled.
80 type: bool
81 from:
82 description:
83 - Time in format HH,MM.
84 type: str
85 index:
86 description:
87 - Hour range index.
88 type: int
89 to:
90 description:
91 - Time in format HH,MM.
92 type: str
93 start:
94 description:
95 - Starting time. Note, Each gateway may interpret this time differently according to its time zone.
96 type: dict
97 suboptions:
98 date:
99 description:
100 - Date in format dd-MMM-yyyy.
101 type: str
102 iso_8601:
103 description:
104 - Date and time represented in international ISO 8601 format. Time zone information is ignored.
105 type: str
106 posix:
107 description:
108 - Number of milliseconds that have elapsed since 00,00,00, 1 January 1970.
109 type: int
110 time:
111 description:
112 - Time in format HH,mm.
113 type: str
114 start_now:
115 description:
116 - Start immediately.
117 type: bool
118 tags:
119 description:
120 - Collection of tag identifiers.
121 type: list
122 elements: str
123 recurrence:
124 description:
125 - Days recurrence.
126 type: dict
127 suboptions:
128 days:
129 description:
130 - Valid on specific days. Multiple options, support range of days in months. Example,["1","3","9-20"].
131 type: list
132 elements: str
133 month:
134 description:
135 - Valid on month. Example, "1", "2","12","Any".
136 type: str
137 pattern:
138 description:
139 - Valid on "Daily", "Weekly", "Monthly" base.
140 type: str
141 weekdays:
142 description:
143 - Valid on weekdays. Example, "Sun", "Mon"..."Sat".
144 type: list
145 elements: str
146 color:
147 description:
148 - Color of the object. Should be one of existing colors.
149 type: str
150 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
151 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
152 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
153 comments:
154 description:
155 - Comments string.
156 type: str
157 details_level:
158 description:
159 - 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
160 representation of the object.
161 type: str
162 choices: ['uid', 'standard', 'full']
163 groups:
164 description:
165 - Collection of group identifiers.
166 type: list
167 elements: str
168 ignore_warnings:
169 description:
170 - Apply changes ignoring warnings.
171 type: bool
172 ignore_errors:
173 description:
174 - 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.
175 type: bool
176 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
177 """
178
179 EXAMPLES = """
180 - name: add-time
181 cp_mgmt_time:
182 end:
183 date: 24-Nov-2014
184 time: '21:22'
185 end_never: 'false'
186 hours_ranges:
187 - enabled: true
188 from: 00:00
189 index: 1
190 to: 00:00
191 - enabled: false
192 from: 00:00
193 index: 2
194 to: 00:00
195 name: timeObject1
196 recurrence:
197 days:
198 - '1'
199 month: Any
200 pattern: Daily
201 weekdays:
202 - Sun
203 - Mon
204 start_now: 'true'
205 state: present
206
207 - name: set-time
208 cp_mgmt_time:
209 hours_ranges:
210 - from: 00:22
211 to: 00:33
212 name: timeObject1
213 recurrence:
214 month: Any
215 pattern: Weekly
216 weekdays:
217 - Fri
218 state: present
219
220 - name: delete-time
221 cp_mgmt_time:
222 name: timeObject1
223 state: absent
224 """
225
226 RETURN = """
227 cp_mgmt_time:
228 description: The checkpoint object created or updated.
229 returned: always, except when deleting the object.
230 type: dict
231 """
232
233 from ansible.module_utils.basic import AnsibleModule
234 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
235 checkpoint_argument_spec_for_objects,
236 api_call,
237 )
238
239
240 def main():
241 argument_spec = dict(
242 name=dict(type="str", required=True),
243 end=dict(
244 type="dict",
245 options=dict(
246 date=dict(type="str"),
247 iso_8601=dict(type="str"),
248 posix=dict(type="int"),
249 time=dict(type="str"),
250 ),
251 ),
252 end_never=dict(type="bool"),
253 hours_ranges=dict(
254 type="list",
255 elements="dict",
256 options=dict(
257 enabled=dict(type="bool"),
258 index=dict(type="int"),
259 to=dict(type="str"),
260 ),
261 ),
262 start=dict(
263 type="dict",
264 options=dict(
265 date=dict(type="str"),
266 iso_8601=dict(type="str"),
267 posix=dict(type="int"),
268 time=dict(type="str"),
269 ),
270 ),
271 start_now=dict(type="bool"),
272 tags=dict(type="list", elements="str"),
273 recurrence=dict(
274 type="dict",
275 options=dict(
276 days=dict(type="list", elements="str"),
277 month=dict(type="str"),
278 pattern=dict(type="str"),
279 weekdays=dict(type="list", elements="str"),
280 ),
281 ),
282 color=dict(
283 type="str",
284 choices=[
285 "aquamarine",
286 "black",
287 "blue",
288 "crete blue",
289 "burlywood",
290 "cyan",
291 "dark green",
292 "khaki",
293 "orchid",
294 "dark orange",
295 "dark sea green",
296 "pink",
297 "turquoise",
298 "dark blue",
299 "firebrick",
300 "brown",
301 "forest green",
302 "gold",
303 "dark gold",
304 "gray",
305 "dark gray",
306 "light green",
307 "lemon chiffon",
308 "coral",
309 "sea green",
310 "sky blue",
311 "magenta",
312 "purple",
313 "slate blue",
314 "violet red",
315 "navy blue",
316 "olive",
317 "orange",
318 "red",
319 "sienna",
320 "yellow",
321 ],
322 ),
323 comments=dict(type="str"),
324 details_level=dict(type="str", choices=["uid", "standard", "full"]),
325 groups=dict(type="list", elements="str"),
326 ignore_warnings=dict(type="bool"),
327 ignore_errors=dict(type="bool"),
328 )
329 argument_spec["hours_ranges"]["options"]["from"] = dict(type="str")
330 argument_spec.update(checkpoint_argument_spec_for_objects)
331
332 module = AnsibleModule(
333 argument_spec=argument_spec, supports_check_mode=True
334 )
335 api_call_object = "time"
336
337 result = api_call(module, api_call_object)
338 module.exit_json(**result)
339
340
341 if __name__ == "__main__":
342 main()