Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_internetservicecustom.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_internetservicecustom
15 short_description: Configure custom Internet Services.
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_internetservicecustom:
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 id:
43 type: int
44 description: Disable entry ID.
45 ip_range:
46 aliases: ['ip-range']
47 type: list
48 elements: dict
49 description: Ip range.
50 suboptions:
51 end_ip:
52 aliases: ['end-ip']
53 type: str
54 description: End IP address.
55 id:
56 type: int
57 description: Disable entry range ID.
58 start_ip:
59 aliases: ['start-ip']
60 type: str
61 description: Start IP address.
62 port:
63 type: raw
64 description: (list) Integer value for the TCP/IP port
65 protocol:
66 type: int
67 description: Integer value for the protocol type as defined by IANA
68 entry:
69 type: list
70 elements: dict
71 description: Entry.
72 suboptions:
73 dst:
74 type: raw
75 description: (list or str) Destination address or address group name.
76 id:
77 type: int
78 description: Entry ID
79 port_range:
80 aliases: ['port-range']
81 type: list
82 elements: dict
83 description: Port range.
84 suboptions:
85 end_port:
86 aliases: ['end-port']
87 type: int
88 description: Integer value for ending TCP/UDP/SCTP destination port in range
89 id:
90 type: int
91 description: Custom entry port range ID.
92 start_port:
93 aliases: ['start-port']
94 type: int
95 description: Integer value for starting TCP/UDP/SCTP destination port in range
96 protocol:
97 type: int
98 description: Integer value for the protocol type as defined by IANA
99 addr_mode:
100 aliases: ['addr-mode']
101 type: str
102 description: Address mode
103 choices: ['ipv4', 'ipv6']
104 dst6:
105 type: raw
106 description: (list) Destination address6 or address6 group name.
107 master_service_id:
108 aliases: ['master-service-id']
109 type: str
110 description: Internet Service ID in the Internet Service database.
111 name:
112 type: str
113 description: Internet Service name.
114 required: true
115 reputation:
116 type: int
117 description: Reputation level of the custom Internet Service.
118 id:
119 type: int
120 description: Internet Service ID.
121 '''
122
123 EXAMPLES = '''
124 - name: Example playbook
125 hosts: fortimanagers
126 gather_facts: false
127 connection: httpapi
128 vars:
129 ansible_httpapi_use_ssl: true
130 ansible_httpapi_validate_certs: false
131 ansible_httpapi_port: 443
132 tasks:
133 - name: Configure custom Internet Services via Generic Module.
134 fortinet.fortimanager.fmgr_generic:
135 method: "set"
136 params:
137 - url: "/pm/config/adom/ansible/obj/firewall/internet-service-custom"
138 data:
139 - name: "ansible-test"
140 comment: "ansible-comment"
141 - name: Configure custom Internet Services.
142 when: false
143 fortinet.fortimanager.fmgr_firewall_internetservicecustom:
144 bypass_validation: false
145 adom: ansible
146 state: present
147 firewall_internetservicecustom:
148 comment: "ansible-comment"
149 name: "ansible-test"
150
151 - name: Gathering fortimanager facts
152 hosts: fortimanagers
153 gather_facts: false
154 connection: httpapi
155 vars:
156 ansible_httpapi_use_ssl: true
157 ansible_httpapi_validate_certs: false
158 ansible_httpapi_port: 443
159 tasks:
160 - name: Retrieve all the custom Internet Services
161 fortinet.fortimanager.fmgr_fact:
162 facts:
163 selector: "firewall_internetservicecustom"
164 params:
165 adom: "ansible"
166 internet_service_custom: "your_value"
167 '''
168
169 RETURN = '''
170 meta:
171 description: The result of the request.
172 type: dict
173 returned: always
174 contains:
175 request_url:
176 description: The full url requested.
177 returned: always
178 type: str
179 sample: /sys/login/user
180 response_code:
181 description: The status of api request.
182 returned: always
183 type: int
184 sample: 0
185 response_data:
186 description: The api response.
187 type: list
188 returned: always
189 response_message:
190 description: The descriptive message of the api response.
191 type: str
192 returned: always
193 sample: OK.
194 system_information:
195 description: The information of the target system.
196 type: dict
197 returned: always
198 rc:
199 description: The status the request.
200 type: int
201 returned: always
202 sample: 0
203 version_check_warning:
204 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
205 type: list
206 returned: complex
207 '''
208 from ansible.module_utils.basic import AnsibleModule
209 from ansible.module_utils.connection import Connection
210 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
211 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
212
213
214 def main():
215 urls_list = [
216 '/pm/config/adom/{adom}/obj/firewall/internet-service-custom',
217 '/pm/config/global/obj/firewall/internet-service-custom'
218 ]
219 module_arg_spec = {
220 'adom': {'required': True, 'type': 'str'},
221 'revision_note': {'type': 'str'},
222 'firewall_internetservicecustom': {
223 'type': 'dict', 'v_range': [['6.0.0', '']],
224 'options': {
225 'comment': {'type': 'str'},
226 'disable-entry': {
227 'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']],
228 'type': 'list',
229 'options': {
230 'id': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'},
231 'ip-range': {
232 'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']],
233 'type': 'list',
234 'options': {
235 'end-ip': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'str'},
236 'id': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'},
237 'start-ip': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'str'}
238 },
239 'elements': 'dict'
240 },
241 'port': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'raw'},
242 'protocol': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'}
243 },
244 'elements': 'dict'
245 },
246 'entry': {
247 'type': 'list',
248 'options': {
249 'dst': {'type': 'raw'},
250 'id': {'type': 'int'},
251 'port-range': {
252 'type': 'list',
253 'options': {'end-port': {'type': 'int'}, 'id': {'type': 'int'}, 'start-port': {'type': 'int'}},
254 'elements': 'dict'
255 },
256 'protocol': {'type': 'int'},
257 'addr-mode': {'v_range': [['7.2.1', '']], 'choices': ['ipv4', 'ipv6'], 'type': 'str'},
258 'dst6': {'v_range': [['7.2.1', '']], 'type': 'raw'}
259 },
260 'elements': 'dict'
261 },
262 'master-service-id': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'str'},
263 'name': {'required': True, 'type': 'str'},
264 'reputation': {'v_range': [['6.2.0', '']], 'type': 'int'},
265 'id': {'v_range': [['6.4.2', '']], 'type': 'int'}
266 }
267 }
268 }
269
270 module_option_spec = get_module_arg_spec('full crud')
271 module_arg_spec.update(module_option_spec)
272 check_galaxy_version(module_arg_spec)
273 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetservicecustom'),
274 supports_check_mode=True)
275 if not module._socket_path:
276 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
277 connection = Connection(module._socket_path)
278 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
279 'name', 'data', module, connection)
280 fmgr.process_crud()
281 module.exit_json(meta=module.params)
282
283
284 if __name__ == '__main__':
285 main()