Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_qos_qospolicy.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_qos_qospolicy
15 short_description: Configure FortiSwitch QoS policy.
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 switchcontroller_qos_qospolicy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 default_cos:
34 aliases: ['default-cos']
35 type: int
36 description: Default cos queue for untagged packets.
37 name:
38 type: str
39 description: QoS policy name.
40 required: true
41 queue_policy:
42 aliases: ['queue-policy']
43 type: str
44 description: QoS egress queue policy.
45 trust_dot1p_map:
46 aliases: ['trust-dot1p-map']
47 type: str
48 description: QoS trust 802.
49 trust_ip_dscp_map:
50 aliases: ['trust-ip-dscp-map']
51 type: str
52 description: QoS trust ip dscp map.
53 '''
54
55 EXAMPLES = '''
56 - name: Example playbook (generated based on argument schema)
57 hosts: fortimanagers
58 connection: httpapi
59 gather_facts: false
60 tasks:
61 - name: Configure FortiSwitch QoS policy.
62 fortinet.fortimanager.fmgr_switchcontroller_qos_qospolicy:
63 # workspace_locking_adom: <global or your adom name>
64 adom: <your own value>
65 state: present # <value in [present, absent]>
66 switchcontroller_qos_qospolicy:
67 name: "your value" # Required variable, string
68 # default_cos: <integer>
69 # queue_policy: <string>
70 # trust_dot1p_map: <string>
71 # trust_ip_dscp_map: <string>
72 '''
73
74 RETURN = '''
75 meta:
76 description: The result of the request.
77 type: dict
78 returned: always
79 contains:
80 request_url:
81 description: The full url requested.
82 returned: always
83 type: str
84 sample: /sys/login/user
85 response_code:
86 description: The status of api request.
87 returned: always
88 type: int
89 sample: 0
90 response_data:
91 description: The api response.
92 type: list
93 returned: always
94 response_message:
95 description: The descriptive message of the api response.
96 type: str
97 returned: always
98 sample: OK.
99 system_information:
100 description: The information of the target system.
101 type: dict
102 returned: always
103 rc:
104 description: The status the request.
105 type: int
106 returned: always
107 sample: 0
108 version_check_warning:
109 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
110 type: list
111 returned: complex
112 '''
113 from ansible.module_utils.basic import AnsibleModule
114 from ansible.module_utils.connection import Connection
115 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
116 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
117
118
119 def main():
120 urls_list = [
121 '/pm/config/adom/{adom}/obj/switch-controller/qos/qos-policy',
122 '/pm/config/global/obj/switch-controller/qos/qos-policy'
123 ]
124 module_arg_spec = {
125 'adom': {'required': True, 'type': 'str'},
126 'revision_note': {'type': 'str'},
127 'switchcontroller_qos_qospolicy': {
128 'type': 'dict', 'v_range': [['6.0.0', '']],
129 'options': {
130 'default-cos': {'type': 'int'},
131 'name': {'required': True, 'type': 'str'},
132 'queue-policy': {'type': 'str'},
133 'trust-dot1p-map': {'type': 'str'},
134 'trust-ip-dscp-map': {'type': 'str'}
135 }
136 }
137 }
138
139 module_option_spec = get_module_arg_spec('full crud')
140 module_arg_spec.update(module_option_spec)
141 check_galaxy_version(module_arg_spec)
142 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_qos_qospolicy'),
143 supports_check_mode=True)
144 if not module._socket_path:
145 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
146 connection = Connection(module._socket_path)
147 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
148 'name', 'data', module, connection)
149 fmgr.process_crud()
150 module.exit_json(meta=module.params)
151
152
153 if __name__ == '__main__':
154 main()