Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_schedule_onetime.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_onetime
15 short_description: Onetime 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_onetime:
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 end:
37 type: str
38 description: Schedule end date and time, format hh
39 expiration_days:
40 aliases: ['expiration-days']
41 type: int
42 description: Write an event log message this many days before the schedule expires.
43 name:
44 type: str
45 description: Onetime schedule name.
46 required: true
47 start:
48 type: str
49 description: Schedule start date and time, format hh
50 global_object:
51 aliases: ['global-object']
52 type: int
53 description: Global Object.
54 fabric_object:
55 aliases: ['fabric-object']
56 type: str
57 description: Security Fabric global object setting.
58 choices: ['disable', 'enable']
59 end_utc:
60 aliases: ['end-utc']
61 type: str
62 description: Schedule end date and time, in epoch format.
63 start_utc:
64 aliases: ['start-utc']
65 type: str
66 description: Schedule start date and time, in epoch format.
67 uuid:
68 type: str
69 description: Universally Unique Identifier
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: Onetime schedule configuration.
83 fortinet.fortimanager.fmgr_firewall_schedule_onetime:
84 bypass_validation: false
85 adom: ansible
86 state: present
87 firewall_schedule_onetime:
88 color: 1
89 end: "15:00 2020/08/17"
90 name: "ansible-test-onetime"
91 start: "07:00 2020/08/17"
92
93 - name: Gathering fortimanager facts
94 hosts: fortimanagers
95 gather_facts: false
96 connection: httpapi
97 vars:
98 ansible_httpapi_use_ssl: true
99 ansible_httpapi_validate_certs: false
100 ansible_httpapi_port: 443
101 tasks:
102 - name: Retrieve all the onetime schedules
103 fortinet.fortimanager.fmgr_fact:
104 facts:
105 selector: "firewall_schedule_onetime"
106 params:
107 adom: "ansible"
108 onetime: "your_value"
109 '''
110
111 RETURN = '''
112 meta:
113 description: The result of the request.
114 type: dict
115 returned: always
116 contains:
117 request_url:
118 description: The full url requested.
119 returned: always
120 type: str
121 sample: /sys/login/user
122 response_code:
123 description: The status of api request.
124 returned: always
125 type: int
126 sample: 0
127 response_data:
128 description: The api response.
129 type: list
130 returned: always
131 response_message:
132 description: The descriptive message of the api response.
133 type: str
134 returned: always
135 sample: OK.
136 system_information:
137 description: The information of the target system.
138 type: dict
139 returned: always
140 rc:
141 description: The status the request.
142 type: int
143 returned: always
144 sample: 0
145 version_check_warning:
146 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
147 type: list
148 returned: complex
149 '''
150 from ansible.module_utils.basic import AnsibleModule
151 from ansible.module_utils.connection import Connection
152 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
153 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
154
155
156 def main():
157 urls_list = [
158 '/pm/config/adom/{adom}/obj/firewall/schedule/onetime',
159 '/pm/config/global/obj/firewall/schedule/onetime'
160 ]
161 module_arg_spec = {
162 'adom': {'required': True, 'type': 'str'},
163 'revision_note': {'type': 'str'},
164 'firewall_schedule_onetime': {
165 'type': 'dict', 'v_range': [['6.0.0', '']],
166 'options': {
167 'color': {'type': 'int'},
168 'end': {'type': 'str'},
169 'expiration-days': {'type': 'int'},
170 'name': {'required': True, 'type': 'str'},
171 'start': {'type': 'str'},
172 'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'},
173 'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
174 'end-utc': {'v_range': [['7.2.2', '']], 'type': 'str'},
175 'start-utc': {'v_range': [['7.2.2', '']], 'type': 'str'},
176 'uuid': {'v_range': [['7.6.0', '']], 'type': 'str'}
177 }
178 }
179 }
180
181 module_option_spec = get_module_arg_spec('full crud')
182 module_arg_spec.update(module_option_spec)
183 check_galaxy_version(module_arg_spec)
184 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_schedule_onetime'),
185 supports_check_mode=True)
186 if not module._socket_path:
187 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
188 connection = Connection(module._socket_path)
189 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
190 'name', 'data', module, connection)
191 fmgr.process_crud()
192 module.exit_json(meta=module.params)
193
194
195 if __name__ == '__main__':
196 main()