Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_managedswitch_snmpuser.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_managedswitch_snmpuser
15 short_description: Configuration method to edit Simple Network Management Protocol
16 version_added: "2.1.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 managed-switch:
29 description: Deprecated, please use "managed_switch"
30 type: str
31 managed_switch:
32 description: The parameter (managed-switch) in requested url.
33 type: str
34 switchcontroller_managedswitch_snmpuser:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 auth_proto:
40 aliases: ['auth-proto']
41 type: str
42 description: Authentication protocol.
43 choices: ['md5', 'sha']
44 auth_pwd:
45 aliases: ['auth-pwd']
46 type: raw
47 description: (list) Password for authentication protocol.
48 name:
49 type: str
50 description: SNMP user name.
51 required: true
52 priv_proto:
53 aliases: ['priv-proto']
54 type: str
55 description: Privacy
56 choices: ['des', 'aes']
57 priv_pwd:
58 aliases: ['priv-pwd']
59 type: raw
60 description: (list) Password for privacy
61 queries:
62 type: str
63 description: Enable/disable SNMP queries for this user.
64 choices: ['disable', 'enable']
65 query_port:
66 aliases: ['query-port']
67 type: int
68 description: SNMPv3 query port
69 security_level:
70 aliases: ['security-level']
71 type: str
72 description: Security level for message authentication and encryption.
73 choices: ['no-auth-no-priv', 'auth-no-priv', 'auth-priv']
74 '''
75
76 EXAMPLES = '''
77 - name: Example playbook (generated based on argument schema)
78 hosts: fortimanagers
79 connection: httpapi
80 gather_facts: false
81 tasks:
82 - name: Configuration method to edit Simple Network Management Protocol
83 fortinet.fortimanager.fmgr_switchcontroller_managedswitch_snmpuser:
84 # workspace_locking_adom: <global or your adom name>
85 adom: <your own value>
86 managed_switch: <your own value>
87 state: present # <value in [present, absent]>
88 switchcontroller_managedswitch_snmpuser:
89 name: "your value" # Required variable, string
90 # auth_proto: <value in [md5, sha]>
91 # auth_pwd: <list or string>
92 # priv_proto: <value in [des, aes]>
93 # priv_pwd: <list or string>
94 # queries: <value in [disable, enable]>
95 # query_port: <integer>
96 # security_level: <value in [no-auth-no-priv, auth-no-priv, auth-priv]>
97 '''
98
99 RETURN = '''
100 meta:
101 description: The result of the request.
102 type: dict
103 returned: always
104 contains:
105 request_url:
106 description: The full url requested.
107 returned: always
108 type: str
109 sample: /sys/login/user
110 response_code:
111 description: The status of api request.
112 returned: always
113 type: int
114 sample: 0
115 response_data:
116 description: The api response.
117 type: list
118 returned: always
119 response_message:
120 description: The descriptive message of the api response.
121 type: str
122 returned: always
123 sample: OK.
124 system_information:
125 description: The information of the target system.
126 type: dict
127 returned: always
128 rc:
129 description: The status the request.
130 type: int
131 returned: always
132 sample: 0
133 version_check_warning:
134 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
135 type: list
136 returned: complex
137 '''
138 from ansible.module_utils.basic import AnsibleModule
139 from ansible.module_utils.connection import Connection
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
142
143
144 def main():
145 urls_list = [
146 '/pm/config/adom/{adom}/obj/switch-controller/managed-switch/{managed-switch}/snmp-user',
147 '/pm/config/global/obj/switch-controller/managed-switch/{managed-switch}/snmp-user'
148 ]
149 module_arg_spec = {
150 'adom': {'required': True, 'type': 'str'},
151 'managed-switch': {'type': 'str', 'api_name': 'managed_switch'},
152 'managed_switch': {'type': 'str'},
153 'revision_note': {'type': 'str'},
154 'switchcontroller_managedswitch_snmpuser': {
155 'type': 'dict', 'v_range': [['6.2.1', '6.2.3']],
156 'options': {
157 'auth-proto': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['md5', 'sha'], 'type': 'str'},
158 'auth-pwd': {'v_range': [['6.2.1', '6.2.3']], 'type': 'raw'},
159 'name': {'v_range': [['6.2.1', '6.2.3']], 'required': True, 'type': 'str'},
160 'priv-proto': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['des', 'aes'], 'type': 'str'},
161 'priv-pwd': {'v_range': [['6.2.1', '6.2.3']], 'type': 'raw'},
162 'queries': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'},
163 'query-port': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
164 'security-level': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['no-auth-no-priv', 'auth-no-priv', 'auth-priv'], 'type': 'str'}
165 }
166 }
167 }
168
169 module_option_spec = get_module_arg_spec('full crud')
170 module_arg_spec.update(module_option_spec)
171 check_galaxy_version(module_arg_spec)
172 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_managedswitch_snmpuser'),
173 supports_check_mode=True)
174 if not module._socket_path:
175 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
176 connection = Connection(module._socket_path)
177 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
178 'name', 'data', module, connection)
179 fmgr.process_crud()
180 module.exit_json(meta=module.params)
181
182
183 if __name__ == '__main__':
184 main()