Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_shapingprofile_shapingentries.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_shapingprofile_shapingentries
15 short_description: Define shaping entries of this shaping profile.
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 shaping-profile:
29 description: Deprecated, please use "shaping_profile"
30 type: str
31 shaping_profile:
32 description: The parameter (shaping-profile) in requested url.
33 type: str
34 firewall_shapingprofile_shapingentries:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 class_id:
40 aliases: ['class-id']
41 type: raw
42 description: (int or str) Class ID.
43 guaranteed_bandwidth_percentage:
44 aliases: ['guaranteed-bandwidth-percentage']
45 type: int
46 description: Guaranteed bandwith in percentage.
47 id:
48 type: int
49 description: ID number.
50 required: true
51 maximum_bandwidth_percentage:
52 aliases: ['maximum-bandwidth-percentage']
53 type: int
54 description: Maximum bandwith in percentage.
55 priority:
56 type: str
57 description: Priority.
58 choices: ['low', 'medium', 'high', 'critical', 'top']
59 burst_in_msec:
60 aliases: ['burst-in-msec']
61 type: int
62 description: Number of bytes that can be burst at maximum-bandwidth speed.
63 cburst_in_msec:
64 aliases: ['cburst-in-msec']
65 type: int
66 description: Number of bytes that can be burst as fast as the interface can transmit.
67 limit:
68 type: int
69 description: Hard limit on the real queue size in packets.
70 max:
71 type: int
72 description: Average queue size in packets at which RED drop probability is maximal.
73 min:
74 type: int
75 description: Average queue size in packets at which RED drop becomes a possibility.
76 red_probability:
77 aliases: ['red-probability']
78 type: int
79 description: Maximum probability
80 '''
81
82 EXAMPLES = '''
83 - name: Example playbook
84 hosts: fortimanagers
85 gather_facts: false
86 connection: httpapi
87 vars:
88 ansible_httpapi_use_ssl: true
89 ansible_httpapi_validate_certs: false
90 ansible_httpapi_port: 443
91 tasks:
92 - name: Define shaping entries of this shaping profile.
93 fortinet.fortimanager.fmgr_firewall_shapingprofile_shapingentries:
94 bypass_validation: false
95 adom: ansible
96 shaping_profile: "ansible-test" # profile-name
97 state: present
98 firewall_shapingprofile_shapingentries:
99 guaranteed_bandwidth_percentage: 50
100 id: 1
101 maximum_bandwidth_percentage: 70
102 priority: medium # <value in [low, medium, high]>
103
104 - name: Gathering fortimanager facts
105 hosts: fortimanagers
106 gather_facts: false
107 connection: httpapi
108 vars:
109 ansible_httpapi_use_ssl: true
110 ansible_httpapi_validate_certs: false
111 ansible_httpapi_port: 443
112 tasks:
113 - name: Retrieve all the shaping entries of this shaping profile
114 fortinet.fortimanager.fmgr_fact:
115 facts:
116 selector: "firewall_shapingprofile_shapingentries"
117 params:
118 adom: "ansible"
119 shaping_profile: "ansible-test" # profile-name
120 shaping_entries: "your_value"
121 '''
122
123 RETURN = '''
124 meta:
125 description: The result of the request.
126 type: dict
127 returned: always
128 contains:
129 request_url:
130 description: The full url requested.
131 returned: always
132 type: str
133 sample: /sys/login/user
134 response_code:
135 description: The status of api request.
136 returned: always
137 type: int
138 sample: 0
139 response_data:
140 description: The api response.
141 type: list
142 returned: always
143 response_message:
144 description: The descriptive message of the api response.
145 type: str
146 returned: always
147 sample: OK.
148 system_information:
149 description: The information of the target system.
150 type: dict
151 returned: always
152 rc:
153 description: The status the request.
154 type: int
155 returned: always
156 sample: 0
157 version_check_warning:
158 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
159 type: list
160 returned: complex
161 '''
162 from ansible.module_utils.basic import AnsibleModule
163 from ansible.module_utils.connection import Connection
164 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
165 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
166
167
168 def main():
169 urls_list = [
170 '/pm/config/adom/{adom}/obj/firewall/shaping-profile/{shaping-profile}/shaping-entries',
171 '/pm/config/global/obj/firewall/shaping-profile/{shaping-profile}/shaping-entries'
172 ]
173 module_arg_spec = {
174 'adom': {'required': True, 'type': 'str'},
175 'shaping-profile': {'type': 'str', 'api_name': 'shaping_profile'},
176 'shaping_profile': {'type': 'str'},
177 'revision_note': {'type': 'str'},
178 'firewall_shapingprofile_shapingentries': {
179 'type': 'dict', 'v_range': [['6.0.0', '']],
180 'options': {
181 'class-id': {'type': 'raw'},
182 'guaranteed-bandwidth-percentage': {'type': 'int'},
183 'id': {'required': True, 'type': 'int'},
184 'maximum-bandwidth-percentage': {'type': 'int'},
185 'priority': {'choices': ['low', 'medium', 'high', 'critical', 'top'], 'type': 'str'},
186 'burst-in-msec': {'v_range': [['6.2.1', '']], 'type': 'int'},
187 'cburst-in-msec': {'v_range': [['6.2.1', '']], 'type': 'int'},
188 'limit': {'v_range': [['6.2.1', '']], 'type': 'int'},
189 'max': {'v_range': [['6.2.1', '']], 'type': 'int'},
190 'min': {'v_range': [['6.2.1', '']], 'type': 'int'},
191 'red-probability': {'v_range': [['6.2.1', '']], 'type': 'int'}
192 }
193 }
194 }
195
196 module_option_spec = get_module_arg_spec('full crud')
197 module_arg_spec.update(module_option_spec)
198 check_galaxy_version(module_arg_spec)
199 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_shapingprofile_shapingentries'),
200 supports_check_mode=True)
201 if not module._socket_path:
202 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
203 connection = Connection(module._socket_path)
204 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
205 'id', 'data', module, connection)
206 fmgr.process_crud()
207 module.exit_json(meta=module.params)
208
209
210 if __name__ == '__main__':
211 main()