Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_telemetrycontroller_profile_application.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_telemetrycontroller_profile_application
15 short_description: Configure applications.
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 profile:
29 description: The parameter (profile) in requested url.
30 type: str
31 required: true
32 telemetrycontroller_profile_application:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 app_name:
38 aliases: ['app-name']
39 type: list
40 elements: str
41 description: Application name.
42 app_throughput:
43 aliases: ['app-throughput']
44 type: int
45 description: Application throughput in megabytes
46 atdt_threshold:
47 aliases: ['atdt-threshold']
48 type: int
49 description: Threshold of application total downloading time in milliseconds
50 dns_time_threshold:
51 aliases: ['dns-time-threshold']
52 type: int
53 description: Threshold of DNS resolution time in milliseconds
54 experience_score_threshold:
55 aliases: ['experience-score-threshold']
56 type: int
57 description: Threshold of experience score
58 failure_rate_threshold:
59 aliases: ['failure-rate-threshold']
60 type: int
61 description: Threshold of failure rate
62 id:
63 type: int
64 description: ID.
65 required: true
66 interval:
67 type: int
68 description: Time in milliseconds to check the application
69 jitter_threshold:
70 aliases: ['jitter-threshold']
71 type: int
72 description: Threshold of jitter in milliseconds
73 latency_threshold:
74 aliases: ['latency-threshold']
75 type: int
76 description: Threshold of latency in milliseconds
77 monitor:
78 type: str
79 description: Enable/disable monitoring of the application.
80 choices: ['disable', 'enable']
81 packet_loss_threshold:
82 aliases: ['packet-loss-threshold']
83 type: int
84 description: Threshold of packet loss
85 sla:
86 type: dict
87 description: Sla.
88 suboptions:
89 app_throughput_threshold:
90 aliases: ['app-throughput-threshold']
91 type: int
92 description: Threshold of application throughput in megabytes
93 atdt_threshold:
94 aliases: ['atdt-threshold']
95 type: int
96 description: Threshold of application total downloading time in milliseconds
97 dns_time_threshold:
98 aliases: ['dns-time-threshold']
99 type: int
100 description: Threshold of 95th percentile of DNS resolution time in milliseconds
101 experience_score_threshold:
102 aliases: ['experience-score-threshold']
103 type: int
104 description: Threshold of experience score
105 failure_rate_threshold:
106 aliases: ['failure-rate-threshold']
107 type: int
108 description: Threshold of failure rate
109 jitter_threshold:
110 aliases: ['jitter-threshold']
111 type: int
112 description: Threshold of jitter in milliseconds
113 latency_threshold:
114 aliases: ['latency-threshold']
115 type: int
116 description: Threshold of latency in milliseconds
117 packet_loss_threshold:
118 aliases: ['packet-loss-threshold']
119 type: int
120 description: Threshold of packet loss
121 sla_factor:
122 aliases: ['sla-factor']
123 type: list
124 elements: str
125 description: Criteria on which metric to SLA threshold list.
126 choices: ['latency', 'jitter', 'packet-loss', 'experience-score',
127 'failure-rate', 'ttfb', 'atdt', 'tcp-rtt', 'dns-time',
128 'tls-time', 'app-throughput']
129 tcp_rtt_threshold:
130 aliases: ['tcp-rtt-threshold']
131 type: int
132 description: Threshold of TCP round-trip time in milliseconds
133 tls_time_threshold:
134 aliases: ['tls-time-threshold']
135 type: int
136 description: Threshold of 95th percentile of TLS handshake time in milliseconds
137 ttfb_threshold:
138 aliases: ['ttfb-threshold']
139 type: int
140 description: Threshold of time to first byte in milliseconds
141 tcp_rtt_threshold:
142 aliases: ['tcp-rtt-threshold']
143 type: int
144 description: Threshold of TCP round-trip time in milliseconds
145 tls_time_threshold:
146 aliases: ['tls-time-threshold']
147 type: int
148 description: Threshold of TLS handshake time in milliseconds
149 ttfb_threshold:
150 aliases: ['ttfb-threshold']
151 type: int
152 description: Threshold of time to first byte in milliseconds
153 '''
154
155 EXAMPLES = '''
156 - name: Example playbook (generated based on argument schema)
157 hosts: fortimanagers
158 connection: httpapi
159 gather_facts: false
160 tasks:
161 - name: Configure applications.
162 fortinet.fortimanager.fmgr_telemetrycontroller_profile_application:
163 # workspace_locking_adom: <global or your adom name>
164 adom: <your own value>
165 profile: <your own value>
166 state: present # <value in [present, absent]>
167 telemetrycontroller_profile_application:
168 id: 0 # Required variable, integer
169 # app_name: <list or string>
170 # app_throughput: <integer>
171 # atdt_threshold: <integer>
172 # dns_time_threshold: <integer>
173 # experience_score_threshold: <integer>
174 # failure_rate_threshold: <integer>
175 # interval: <integer>
176 # jitter_threshold: <integer>
177 # latency_threshold: <integer>
178 # monitor: <value in [disable, enable]>
179 # packet_loss_threshold: <integer>
180 # sla:
181 # app_throughput_threshold: <integer>
182 # atdt_threshold: <integer>
183 # dns_time_threshold: <integer>
184 # experience_score_threshold: <integer>
185 # failure_rate_threshold: <integer>
186 # jitter_threshold: <integer>
187 # latency_threshold: <integer>
188 # packet_loss_threshold: <integer>
189 # sla_factor: ["latency", "jitter", "packet-loss", "experience-score", "failure-rate",
190 # "ttfb", "atdt", "tcp-rtt", "dns-time", "tls-time", "app-throughput"]
191 # tcp_rtt_threshold: <integer>
192 # tls_time_threshold: <integer>
193 # ttfb_threshold: <integer>
194 # tcp_rtt_threshold: <integer>
195 # tls_time_threshold: <integer>
196 # ttfb_threshold: <integer>
197 '''
198
199 RETURN = '''
200 meta:
201 description: The result of the request.
202 type: dict
203 returned: always
204 contains:
205 request_url:
206 description: The full url requested.
207 returned: always
208 type: str
209 sample: /sys/login/user
210 response_code:
211 description: The status of api request.
212 returned: always
213 type: int
214 sample: 0
215 response_data:
216 description: The api response.
217 type: list
218 returned: always
219 response_message:
220 description: The descriptive message of the api response.
221 type: str
222 returned: always
223 sample: OK.
224 system_information:
225 description: The information of the target system.
226 type: dict
227 returned: always
228 rc:
229 description: The status the request.
230 type: int
231 returned: always
232 sample: 0
233 version_check_warning:
234 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
235 type: list
236 returned: complex
237 '''
238 from ansible.module_utils.basic import AnsibleModule
239 from ansible.module_utils.connection import Connection
240 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
241 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
242
243
244 def main():
245 urls_list = [
246 '/pm/config/adom/{adom}/obj/telemetry-controller/profile/{profile}/application',
247 '/pm/config/global/obj/telemetry-controller/profile/{profile}/application'
248 ]
249 module_arg_spec = {
250 'adom': {'required': True, 'type': 'str'},
251 'profile': {'required': True, 'type': 'str'},
252 'revision_note': {'type': 'str'},
253 'telemetrycontroller_profile_application': {
254 'type': 'dict', 'v_range': [['7.6.3', '']],
255 'options': {
256 'app-name': {'v_range': [['7.6.3', '']], 'type': 'list', 'elements': 'str'},
257 'app-throughput': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
258 'atdt-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
259 'dns-time-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
260 'experience-score-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
261 'failure-rate-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
262 'id': {'v_range': [['7.6.3', '']], 'required': True, 'type': 'int'},
263 'interval': {'v_range': [['7.6.3', '']], 'type': 'int'},
264 'jitter-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
265 'latency-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
266 'monitor': {'v_range': [['7.6.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
267 'packet-loss-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
268 'sla': {
269 'v_range': [['7.6.3', '']],
270 'type': 'dict',
271 'options': {
272 'app-throughput-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
273 'atdt-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
274 'dns-time-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
275 'experience-score-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
276 'failure-rate-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
277 'jitter-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
278 'latency-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
279 'packet-loss-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
280 'sla-factor': {
281 'v_range': [['7.6.3', '']],
282 'type': 'list',
283 'choices': [
284 'latency', 'jitter', 'packet-loss', 'experience-score', 'failure-rate', 'ttfb', 'atdt', 'tcp-rtt', 'dns-time',
285 'tls-time', 'app-throughput'
286 ],
287 'elements': 'str'
288 },
289 'tcp-rtt-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
290 'tls-time-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'},
291 'ttfb-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}
292 }
293 },
294 'tcp-rtt-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
295 'tls-time-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'},
296 'ttfb-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}
297 }
298 }
299 }
300
301 module_option_spec = get_module_arg_spec('full crud')
302 module_arg_spec.update(module_option_spec)
303 check_galaxy_version(module_arg_spec)
304 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'telemetrycontroller_profile_application'),
305 supports_check_mode=True)
306 if not module._socket_path:
307 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
308 connection = Connection(module._socket_path)
309 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
310 'id', 'data', module, connection)
311 fmgr.process_crud()
312 module.exit_json(meta=module.params)
313
314
315 if __name__ == '__main__':
316 main()