Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_shaper_peripshaper.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_shaper_peripshaper
15 short_description: Configure per-IP traffic shaper.
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_shaper_peripshaper:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 bandwidth_unit:
34 aliases: ['bandwidth-unit']
35 type: str
36 description: Unit of measurement for maximum bandwidth for this shaper
37 choices: ['kbps', 'mbps', 'gbps']
38 diffserv_forward:
39 aliases: ['diffserv-forward']
40 type: str
41 description: Enable/disable changing the Forward
42 choices: ['disable', 'enable']
43 diffserv_reverse:
44 aliases: ['diffserv-reverse']
45 type: str
46 description: Enable/disable changing the Reverse
47 choices: ['disable', 'enable']
48 diffservcode_forward:
49 aliases: ['diffservcode-forward']
50 type: str
51 description: Forward
52 diffservcode_rev:
53 aliases: ['diffservcode-rev']
54 type: str
55 description: Reverse
56 max_bandwidth:
57 aliases: ['max-bandwidth']
58 type: int
59 description: Upper bandwidth limit enforced by this shaper
60 max_concurrent_session:
61 aliases: ['max-concurrent-session']
62 type: int
63 description: Maximum number of concurrent sessions allowed by this shaper
64 name:
65 type: str
66 description: Traffic shaper name.
67 required: true
68 max_concurrent_tcp_session:
69 aliases: ['max-concurrent-tcp-session']
70 type: int
71 description: Maximum number of concurrent TCP sessions allowed by this shaper
72 max_concurrent_udp_session:
73 aliases: ['max-concurrent-udp-session']
74 type: int
75 description: Maximum number of concurrent UDP sessions allowed by this shaper
76 '''
77
78 EXAMPLES = '''
79 - name: Example playbook
80 hosts: fortimanagers
81 gather_facts: false
82 connection: httpapi
83 vars:
84 ansible_httpapi_use_ssl: true
85 ansible_httpapi_validate_certs: false
86 ansible_httpapi_port: 443
87 tasks:
88 - name: Configure per-IP traffic shaper.
89 fortinet.fortimanager.fmgr_firewall_shaper_peripshaper:
90 bypass_validation: false
91 adom: ansible
92 state: present
93 firewall_shaper_peripshaper:
94 bandwidth_unit: mbps # <value in [kbps, mbps, gbps]>
95 diffserv_forward: enable
96 diffserv_reverse: disable
97 name: "ansible-test"
98
99 - name: Gathering fortimanager facts
100 hosts: fortimanagers
101 gather_facts: false
102 connection: httpapi
103 vars:
104 ansible_httpapi_use_ssl: true
105 ansible_httpapi_validate_certs: false
106 ansible_httpapi_port: 443
107 tasks:
108 - name: Retrieve all the per-IP traffic shapers
109 fortinet.fortimanager.fmgr_fact:
110 facts:
111 selector: "firewall_shaper_peripshaper"
112 params:
113 adom: "ansible"
114 per_ip_shaper: "your_value"
115 '''
116
117 RETURN = '''
118 meta:
119 description: The result of the request.
120 type: dict
121 returned: always
122 contains:
123 request_url:
124 description: The full url requested.
125 returned: always
126 type: str
127 sample: /sys/login/user
128 response_code:
129 description: The status of api request.
130 returned: always
131 type: int
132 sample: 0
133 response_data:
134 description: The api response.
135 type: list
136 returned: always
137 response_message:
138 description: The descriptive message of the api response.
139 type: str
140 returned: always
141 sample: OK.
142 system_information:
143 description: The information of the target system.
144 type: dict
145 returned: always
146 rc:
147 description: The status the request.
148 type: int
149 returned: always
150 sample: 0
151 version_check_warning:
152 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
153 type: list
154 returned: complex
155 '''
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible.module_utils.connection import Connection
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
160
161
162 def main():
163 urls_list = [
164 '/pm/config/adom/{adom}/obj/firewall/shaper/per-ip-shaper',
165 '/pm/config/global/obj/firewall/shaper/per-ip-shaper'
166 ]
167 module_arg_spec = {
168 'adom': {'required': True, 'type': 'str'},
169 'revision_note': {'type': 'str'},
170 'firewall_shaper_peripshaper': {
171 'type': 'dict', 'v_range': [['6.0.0', '']],
172 'options': {
173 'bandwidth-unit': {'choices': ['kbps', 'mbps', 'gbps'], 'type': 'str'},
174 'diffserv-forward': {'choices': ['disable', 'enable'], 'type': 'str'},
175 'diffserv-reverse': {'choices': ['disable', 'enable'], 'type': 'str'},
176 'diffservcode-forward': {'type': 'str'},
177 'diffservcode-rev': {'type': 'str'},
178 'max-bandwidth': {'type': 'int'},
179 'max-concurrent-session': {'type': 'int'},
180 'name': {'required': True, 'type': 'str'},
181 'max-concurrent-tcp-session': {'v_range': [['7.0.0', '']], 'type': 'int'},
182 'max-concurrent-udp-session': {'v_range': [['7.0.0', '']], 'type': 'int'}
183 }
184 }
185 }
186
187 module_option_spec = get_module_arg_spec('full crud')
188 module_arg_spec.update(module_option_spec)
189 check_galaxy_version(module_arg_spec)
190 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_shaper_peripshaper'),
191 supports_check_mode=True)
192 if not module._socket_path:
193 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
194 connection = Connection(module._socket_path)
195 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
196 'name', 'data', module, connection)
197 fmgr.process_crud()
198 module.exit_json(meta=module.params)
199
200
201 if __name__ == '__main__':
202 main()