Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_trafficpolicy.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_switchcontroller_trafficpolicy
15 short_description: Configure FortiSwitch traffic policy.
16 version_added: "2.2.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 switchcontroller_trafficpolicy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 cos_queue:
34 aliases: ['cos-queue']
35 type: int
36 description: COS queue
37 description:
38 type: str
39 description: Description of the traffic policy.
40 guaranteed_bandwidth:
41 aliases: ['guaranteed-bandwidth']
42 type: int
43 description: Guaranteed bandwidth in kbps
44 guaranteed_burst:
45 aliases: ['guaranteed-burst']
46 type: int
47 description: Guaranteed burst size in bytes
48 id:
49 type: int
50 description: FSW Policer id
51 required: true
52 maximum_burst:
53 aliases: ['maximum-burst']
54 type: int
55 description: Maximum burst size in bytes
56 name:
57 type: str
58 description: Traffic policy name.
59 policer_status:
60 aliases: ['policer-status']
61 type: str
62 description: Enable/disable policer config on the traffic policy.
63 choices: ['disable', 'enable']
64 type:
65 type: str
66 description: Type.
67 choices: ['ingress', 'egress']
68 '''
69
70 EXAMPLES = '''
71 - name: Example playbook (generated based on argument schema)
72 hosts: fortimanagers
73 connection: httpapi
74 gather_facts: false
75 tasks:
76 - name: Configure FortiSwitch traffic policy.
77 fortinet.fortimanager.fmgr_switchcontroller_trafficpolicy:
78 # workspace_locking_adom: <global or your adom name>
79 adom: <your own value>
80 state: present # <value in [present, absent]>
81 switchcontroller_trafficpolicy:
82 id: 0 # Required variable, integer
83 # cos_queue: <integer>
84 # description: <string>
85 # guaranteed_bandwidth: <integer>
86 # guaranteed_burst: <integer>
87 # maximum_burst: <integer>
88 # name: <string>
89 # policer_status: <value in [disable, enable]>
90 # type: <value in [ingress, egress]>
91 '''
92
93 RETURN = '''
94 meta:
95 description: The result of the request.
96 type: dict
97 returned: always
98 contains:
99 request_url:
100 description: The full url requested.
101 returned: always
102 type: str
103 sample: /sys/login/user
104 response_code:
105 description: The status of api request.
106 returned: always
107 type: int
108 sample: 0
109 response_data:
110 description: The api response.
111 type: list
112 returned: always
113 response_message:
114 description: The descriptive message of the api response.
115 type: str
116 returned: always
117 sample: OK.
118 system_information:
119 description: The information of the target system.
120 type: dict
121 returned: always
122 rc:
123 description: The status the request.
124 type: int
125 returned: always
126 sample: 0
127 version_check_warning:
128 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
129 type: list
130 returned: complex
131 '''
132 from ansible.module_utils.basic import AnsibleModule
133 from ansible.module_utils.connection import Connection
134 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
135 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
136
137
138 def main():
139 urls_list = [
140 '/pm/config/adom/{adom}/obj/switch-controller/traffic-policy',
141 '/pm/config/global/obj/switch-controller/traffic-policy'
142 ]
143 module_arg_spec = {
144 'adom': {'required': True, 'type': 'str'},
145 'revision_note': {'type': 'str'},
146 'switchcontroller_trafficpolicy': {
147 'type': 'dict', 'v_range': [['7.2.1', '']],
148 'options': {
149 'cos-queue': {'v_range': [['7.2.1', '']], 'type': 'int'},
150 'description': {'v_range': [['7.2.1', '']], 'type': 'str'},
151 'guaranteed-bandwidth': {'v_range': [['7.2.1', '']], 'type': 'int'},
152 'guaranteed-burst': {'v_range': [['7.2.1', '']], 'type': 'int'},
153 'id': {'v_range': [['7.2.1', '']], 'required': True, 'type': 'int'},
154 'maximum-burst': {'v_range': [['7.2.1', '']], 'type': 'int'},
155 'name': {'v_range': [['7.2.1', '']], 'type': 'str'},
156 'policer-status': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
157 'type': {'v_range': [['7.2.1', '']], 'choices': ['ingress', 'egress'], 'type': 'str'}
158 }
159 }
160 }
161
162 module_option_spec = get_module_arg_spec('full crud')
163 module_arg_spec.update(module_option_spec)
164 check_galaxy_version(module_arg_spec)
165 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_trafficpolicy'),
166 supports_check_mode=True)
167 if not module._socket_path:
168 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
169 connection = Connection(module._socket_path)
170 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
171 'id', 'data', module, connection)
172 fmgr.process_crud()
173 module.exit_json(meta=module.params)
174
175
176 if __name__ == '__main__':
177 main()