Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_shapingprofile_classes.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_classes
15 short_description: Firewall shaping profile classes
16 version_added: "2.12.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_classes:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 class_id:
40 aliases: ['class-id']
41 type: int
42 description: Class ID.
43 guaranteed_bandwidth:
44 aliases: ['guaranteed-bandwidth']
45 type: int
46 description: Guaranteed bandwith in percentage.
47 maximum_bandwidth:
48 aliases: ['maximum-bandwidth']
49 type: int
50 description: Maximum bandwith in percentage.
51 name:
52 type: str
53 description: Class Name.
54 required: true
55 priority:
56 type: str
57 description: Priority.
58 choices: ['top', 'critical', 'high', 'medium', 'low']
59 '''
60
61 EXAMPLES = '''
62 - name: Example playbook (generated based on argument schema)
63 hosts: fortimanagers
64 connection: httpapi
65 gather_facts: false
66 tasks:
67 - name: Firewall shaping profile classes
68 fortinet.fortimanager.fmgr_firewall_shapingprofile_classes:
69 # workspace_locking_adom: <global or your adom name>
70 adom: <your own value>
71 shaping_profile: <your own value>
72 state: present # <value in [present, absent]>
73 firewall_shapingprofile_classes:
74 name: "your value" # Required variable, string
75 # class_id: <integer>
76 # guaranteed_bandwidth: <integer>
77 # maximum_bandwidth: <integer>
78 # priority: <value in [top, critical, high, ...]>
79 '''
80
81 RETURN = '''
82 meta:
83 description: The result of the request.
84 type: dict
85 returned: always
86 contains:
87 request_url:
88 description: The full url requested.
89 returned: always
90 type: str
91 sample: /sys/login/user
92 response_code:
93 description: The status of api request.
94 returned: always
95 type: int
96 sample: 0
97 response_data:
98 description: The api response.
99 type: list
100 returned: always
101 response_message:
102 description: The descriptive message of the api response.
103 type: str
104 returned: always
105 sample: OK.
106 system_information:
107 description: The information of the target system.
108 type: dict
109 returned: always
110 rc:
111 description: The status the request.
112 type: int
113 returned: always
114 sample: 0
115 version_check_warning:
116 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
117 type: list
118 returned: complex
119 '''
120 from ansible.module_utils.basic import AnsibleModule
121 from ansible.module_utils.connection import Connection
122 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
123 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
124
125
126 def main():
127 urls_list = [
128 '/pm/config/adom/{adom}/obj/firewall/shaping-profile/{shaping-profile}/classes',
129 '/pm/config/global/obj/firewall/shaping-profile/{shaping-profile}/classes'
130 ]
131 module_arg_spec = {
132 'adom': {'required': True, 'type': 'str'},
133 'shaping-profile': {'type': 'str', 'api_name': 'shaping_profile'},
134 'shaping_profile': {'type': 'str'},
135 'revision_note': {'type': 'str'},
136 'firewall_shapingprofile_classes': {
137 'type': 'dict', 'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']],
138 'options': {
139 'class-id': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
140 'guaranteed-bandwidth': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
141 'maximum-bandwidth': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'},
142 'name': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'required': True, 'type': 'str'},
143 'priority': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['top', 'critical', 'high', 'medium', 'low'], 'type': 'str'}
144 }
145 }
146 }
147
148 module_option_spec = get_module_arg_spec('full crud')
149 module_arg_spec.update(module_option_spec)
150 check_galaxy_version(module_arg_spec)
151 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_shapingprofile_classes'),
152 supports_check_mode=True)
153 if not module._socket_path:
154 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
155 connection = Connection(module._socket_path)
156 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
157 'name', 'data', module, connection)
158 fmgr.process_crud()
159 module.exit_json(meta=module.params)
160
161
162 if __name__ == '__main__':
163 main()