Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_schedule_recurring.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_firewall_schedule_recurring
15 short_description: Recurring schedule configuration.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 firewall_schedule_recurring:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 color:
34 type: int
35 description: Color of icon on the GUI.
36 day:
37 type: list
38 elements: str
39 description: One or more days of the week on which the schedule is valid.
40 choices: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday',
41 'saturday', 'none']
42 end:
43 type: str
44 description: Time of day to end the schedule, format hh
45 name:
46 type: str
47 description: Recurring schedule name.
48 required: true
49 start:
50 type: str
51 description: Time of day to start the schedule, format hh
52 global_object:
53 aliases: ['global-object']
54 type: int
55 description: Global Object.
56 fabric_object:
57 aliases: ['fabric-object']
58 type: str
59 description: Security Fabric global object setting.
60 choices: ['disable', 'enable']
61 uuid:
62 type: str
63 description: Universally Unique Identifier
64 label_day:
65 aliases: ['label-day']
66 type: str
67 description: Configure a window during the time of day in which the schedule job is executed.
68 choices: ['none', 'over-night', 'early-morning', 'morning', 'midday', 'afternoon',
69 'evening', 'night', 'late-night']
70 '''
71
72 EXAMPLES = '''
73 - name: Example playbook
74 hosts: fortimanagers
75 gather_facts: false
76 connection: httpapi
77 vars:
78 ansible_httpapi_use_ssl: true
79 ansible_httpapi_validate_certs: false
80 ansible_httpapi_port: 443
81 tasks:
82 - name: Recurring schedule configuration.
83 fortinet.fortimanager.fmgr_firewall_schedule_recurring:
84 bypass_validation: false
85 adom: ansible
86 state: present
87 firewall_schedule_recurring:
88 color: 1
89 day:
90 - sunday
91 - monday
92 - tuesday
93 - wednesday
94 - thursday
95 - friday
96 - saturday
97 - none
98 end: "15:00"
99 name: "ansible-test-recurring"
100 start: "07:00"
101
102 - name: Gathering fortimanager facts
103 hosts: fortimanagers
104 gather_facts: false
105 connection: httpapi
106 vars:
107 ansible_httpapi_use_ssl: true
108 ansible_httpapi_validate_certs: false
109 ansible_httpapi_port: 443
110 tasks:
111 - name: Retrieve all the recurring schedles
112 fortinet.fortimanager.fmgr_fact:
113 facts:
114 selector: "firewall_schedule_recurring"
115 params:
116 adom: "ansible"
117 recurring: "your_value"
118 '''
119
120 RETURN = '''
121 meta:
122 description: The result of the request.
123 type: dict
124 returned: always
125 contains:
126 request_url:
127 description: The full url requested.
128 returned: always
129 type: str
130 sample: /sys/login/user
131 response_code:
132 description: The status of api request.
133 returned: always
134 type: int
135 sample: 0
136 response_data:
137 description: The api response.
138 type: list
139 returned: always
140 response_message:
141 description: The descriptive message of the api response.
142 type: str
143 returned: always
144 sample: OK.
145 system_information:
146 description: The information of the target system.
147 type: dict
148 returned: always
149 rc:
150 description: The status the request.
151 type: int
152 returned: always
153 sample: 0
154 version_check_warning:
155 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
156 type: list
157 returned: complex
158 '''
159 from ansible.module_utils.basic import AnsibleModule
160 from ansible.module_utils.connection import Connection
161 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
162 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
163
164
165 def main():
166 urls_list = [
167 '/pm/config/adom/{adom}/obj/firewall/schedule/recurring',
168 '/pm/config/global/obj/firewall/schedule/recurring'
169 ]
170 module_arg_spec = {
171 'adom': {'required': True, 'type': 'str'},
172 'revision_note': {'type': 'str'},
173 'firewall_schedule_recurring': {
174 'type': 'dict', 'v_range': [['6.0.0', '']],
175 'options': {
176 'color': {'type': 'int'},
177 'day': {
178 'type': 'list',
179 'choices': ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'none'],
180 'elements': 'str'
181 },
182 'end': {'type': 'str'},
183 'name': {'required': True, 'type': 'str'},
184 'start': {'type': 'str'},
185 'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'},
186 'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
187 'uuid': {'v_range': [['7.6.0', '']], 'type': 'str'},
188 'label-day': {
189 'v_range': [['7.6.5', '']],
190 'choices': ['none', 'over-night', 'early-morning', 'morning', 'midday', 'afternoon', 'evening', 'night', 'late-night'],
191 'type': 'str'
192 }
193 }
194 }
195 }
196
197 module_option_spec = get_module_arg_spec('full crud')
198 module_arg_spec.update(module_option_spec)
199 check_galaxy_version(module_arg_spec)
200 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_schedule_recurring'),
201 supports_check_mode=True)
202 if not module._socket_path:
203 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
204 connection = Connection(module._socket_path)
205 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
206 'name', 'data', module, connection)
207 fmgr.process_crud()
208 module.exit_json(meta=module.params)
209
210
211 if __name__ == '__main__':
212 main()