Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_internetserviceextension.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_internetserviceextension
15 short_description: Configure Internet Services Extension.
16 version_added: "2.10.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_internetserviceextension:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Comment.
36 disable_entry:
37 aliases: ['disable-entry']
38 type: list
39 elements: dict
40 description: Disable entry.
41 suboptions:
42 addr_mode:
43 aliases: ['addr-mode']
44 type: str
45 description: Address mode
46 choices: ['ipv4', 'ipv6']
47 id:
48 type: int
49 description: Disable entry ID.
50 ip_range:
51 aliases: ['ip-range']
52 type: list
53 elements: dict
54 description: Ip range.
55 suboptions:
56 end_ip:
57 aliases: ['end-ip']
58 type: str
59 description: End IPv4 address.
60 id:
61 type: int
62 description: Disable entry range ID.
63 start_ip:
64 aliases: ['start-ip']
65 type: str
66 description: Start IPv4 address.
67 ip6_range:
68 aliases: ['ip6-range']
69 type: list
70 elements: dict
71 description: Ip6 range.
72 suboptions:
73 end_ip6:
74 aliases: ['end-ip6']
75 type: str
76 description: End IPv6 address.
77 id:
78 type: int
79 description: Disable entry range ID.
80 start_ip6:
81 aliases: ['start-ip6']
82 type: str
83 description: Start IPv6 address.
84 port_range:
85 aliases: ['port-range']
86 type: list
87 elements: dict
88 description: Port range.
89 suboptions:
90 end_port:
91 aliases: ['end-port']
92 type: int
93 description: Ending TCP/UDP/SCTP destination port
94 id:
95 type: int
96 description: Custom entry port range ID.
97 start_port:
98 aliases: ['start-port']
99 type: int
100 description: Starting TCP/UDP/SCTP destination port
101 protocol:
102 type: int
103 description: Integer value for the protocol type as defined by IANA
104 entry:
105 type: list
106 elements: dict
107 description: Entry.
108 suboptions:
109 addr_mode:
110 aliases: ['addr-mode']
111 type: str
112 description: Address mode
113 choices: ['ipv4', 'ipv6']
114 dst:
115 type: list
116 elements: str
117 description: Destination address or address group name.
118 dst6:
119 type: list
120 elements: str
121 description: Destination address6 or address6 group name.
122 id:
123 type: int
124 description: Entry ID
125 port_range:
126 aliases: ['port-range']
127 type: list
128 elements: dict
129 description: Port range.
130 suboptions:
131 end_port:
132 aliases: ['end-port']
133 type: int
134 description: Integer value for ending TCP/UDP/SCTP destination port in range
135 id:
136 type: int
137 description: Custom entry port range ID.
138 start_port:
139 aliases: ['start-port']
140 type: int
141 description: Integer value for starting TCP/UDP/SCTP destination port in range
142 protocol:
143 type: int
144 description: Integer value for the protocol type as defined by IANA
145 id:
146 required: true
147 type: list
148 elements: str
149 description: Internet Service ID in the Internet Service database.
150 '''
151
152 EXAMPLES = '''
153 - name: Example playbook (generated based on argument schema)
154 hosts: fortimanagers
155 connection: httpapi
156 gather_facts: false
157 tasks:
158 - name: Configure Internet Services Extension.
159 fortinet.fortimanager.fmgr_firewall_internetserviceextension:
160 # workspace_locking_adom: <global or your adom name>
161 adom: <your own value>
162 state: present # <value in [present, absent]>
163 firewall_internetserviceextension:
164 id: [] # Required variable
165 # comment: <string>
166 # disable_entry:
167 # - addr_mode: <value in [ipv4, ipv6]>
168 # id: <integer>
169 # ip_range:
170 # - end_ip: <string>
171 # id: <integer>
172 # start_ip: <string>
173 # ip6_range:
174 # - end_ip6: <string>
175 # id: <integer>
176 # start_ip6: <string>
177 # port_range:
178 # - end_port: <integer>
179 # id: <integer>
180 # start_port: <integer>
181 # protocol: <integer>
182 # entry:
183 # - addr_mode: <value in [ipv4, ipv6]>
184 # dst: <list or string>
185 # dst6: <list or string>
186 # id: <integer>
187 # port_range:
188 # - end_port: <integer>
189 # id: <integer>
190 # start_port: <integer>
191 # protocol: <integer>
192 '''
193
194 RETURN = '''
195 meta:
196 description: The result of the request.
197 type: dict
198 returned: always
199 contains:
200 request_url:
201 description: The full url requested.
202 returned: always
203 type: str
204 sample: /sys/login/user
205 response_code:
206 description: The status of api request.
207 returned: always
208 type: int
209 sample: 0
210 response_data:
211 description: The api response.
212 type: list
213 returned: always
214 response_message:
215 description: The descriptive message of the api response.
216 type: str
217 returned: always
218 sample: OK.
219 system_information:
220 description: The information of the target system.
221 type: dict
222 returned: always
223 rc:
224 description: The status the request.
225 type: int
226 returned: always
227 sample: 0
228 version_check_warning:
229 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
230 type: list
231 returned: complex
232 '''
233 from ansible.module_utils.basic import AnsibleModule
234 from ansible.module_utils.connection import Connection
235 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
236 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
237
238
239 def main():
240 urls_list = [
241 '/pm/config/adom/{adom}/obj/firewall/internet-service-extension',
242 '/pm/config/global/obj/firewall/internet-service-extension'
243 ]
244 module_arg_spec = {
245 'adom': {'required': True, 'type': 'str'},
246 'revision_note': {'type': 'str'},
247 'firewall_internetserviceextension': {
248 'type': 'dict', 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
249 'options': {
250 'comment': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
251 'disable-entry': {
252 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
253 'type': 'list',
254 'options': {
255 'addr-mode': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'choices': ['ipv4', 'ipv6'], 'type': 'str'},
256 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
257 'ip-range': {
258 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
259 'type': 'list',
260 'options': {
261 'end-ip': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
262 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
263 'start-ip': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'}
264 },
265 'elements': 'dict'
266 },
267 'ip6-range': {
268 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
269 'type': 'list',
270 'options': {
271 'end-ip6': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
272 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
273 'start-ip6': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'}
274 },
275 'elements': 'dict'
276 },
277 'port-range': {
278 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
279 'type': 'list',
280 'options': {
281 'end-port': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
282 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
283 'start-port': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
284 },
285 'elements': 'dict'
286 },
287 'protocol': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
288 },
289 'elements': 'dict'
290 },
291 'entry': {
292 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
293 'type': 'list',
294 'options': {
295 'addr-mode': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'choices': ['ipv4', 'ipv6'], 'type': 'str'},
296 'dst': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
297 'dst6': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
298 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
299 'port-range': {
300 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']],
301 'type': 'list',
302 'options': {
303 'end-port': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
304 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
305 'start-port': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
306 },
307 'elements': 'dict'
308 },
309 'protocol': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'int'}
310 },
311 'elements': 'dict'
312 },
313 'id': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'required': True, 'type': 'list', 'elements': 'str'}
314 }
315 }
316 }
317
318 module_option_spec = get_module_arg_spec('full crud')
319 module_arg_spec.update(module_option_spec)
320 check_galaxy_version(module_arg_spec)
321 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetserviceextension'),
322 supports_check_mode=True)
323 if not module._socket_path:
324 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
325 connection = Connection(module._socket_path)
326 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
327 'id', 'data', module, connection)
328 fmgr.process_crud()
329 module.exit_json(meta=module.params)
330
331
332 if __name__ == '__main__':
333 main()