Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_device_dynamicmapping.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_user_device_dynamicmapping
15 short_description: Configure devices.
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 device:
29 description: The parameter (device) in requested url.
30 type: str
31 required: true
32 user_device_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 avatar:
49 type: str
50 description: Avatar.
51 category:
52 type: str
53 description: Category.
54 choices: ['none', 'android-device', 'blackberry-device', 'fortinet-device',
55 'ios-device', 'windows-device', 'amazon-device']
56 comment:
57 type: str
58 description: Comment.
59 mac:
60 type: str
61 description: Mac.
62 master_device:
63 aliases: ['master-device']
64 type: str
65 description: Master device.
66 tags:
67 type: raw
68 description: (list or str) Tags.
69 type:
70 type: str
71 description: Type.
72 choices: ['ipad', 'iphone', 'gaming-console', 'blackberry-phone',
73 'blackberry-playbook', 'linux-pc', 'mac', 'windows-pc', 'android-phone',
74 'android-tablet', 'media-streaming', 'windows-phone', 'fortinet-device',
75 'ip-phone', 'router-nat-device', 'other-network-device',
76 'windows-tablet', 'printer', 'forticam', 'fortifone', 'unknown']
77 user:
78 type: str
79 description: User.
80 family:
81 type: str
82 description: Family.
83 hardware_vendor:
84 aliases: ['hardware-vendor']
85 type: str
86 description: Hardware vendor.
87 hardware_version:
88 aliases: ['hardware-version']
89 type: str
90 description: Hardware version.
91 os:
92 type: str
93 description: Os.
94 software_version:
95 aliases: ['software-version']
96 type: str
97 description: Software version.
98 '''
99
100 EXAMPLES = '''
101 - name: Example playbook
102 hosts: fortimanagers
103 gather_facts: false
104 connection: httpapi
105 vars:
106 ansible_httpapi_use_ssl: true
107 ansible_httpapi_validate_certs: false
108 ansible_httpapi_port: 443
109 tasks:
110 - name: Configure dynamic mappings
111 fortinet.fortimanager.fmgr_user_device_dynamicmapping:
112 bypass_validation: false
113 adom: ansible
114 device: ansible-test-device # alias
115 state: present
116 user_device_dynamicmapping:
117 _scope:
118 - name: FGT_AWS # need a valid device name
119 vdom: root # need a valid vdom name under the device
120 category: none # <value in [none, android-device, blackberry-device, ...]>
121 comment: ansible-comment
122 mac: "00:11:22:33:44:55"
123 type: iphone # <value in [ipad, iphone, gaming-console, ...]>
124
125 - name: Gathering fortimanager facts
126 hosts: fortimanagers
127 gather_facts: false
128 connection: httpapi
129 vars:
130 ansible_httpapi_use_ssl: true
131 ansible_httpapi_validate_certs: false
132 ansible_httpapi_port: 443
133 tasks:
134 - name: Retrieve all the dynamic mappings
135 fortinet.fortimanager.fmgr_fact:
136 facts:
137 selector: "user_device_dynamicmapping"
138 params:
139 adom: "ansible"
140 device: "ansible-test-device" # alias
141 dynamic_mapping: "your_value"
142 '''
143
144 RETURN = '''
145 meta:
146 description: The result of the request.
147 type: dict
148 returned: always
149 contains:
150 request_url:
151 description: The full url requested.
152 returned: always
153 type: str
154 sample: /sys/login/user
155 response_code:
156 description: The status of api request.
157 returned: always
158 type: int
159 sample: 0
160 response_data:
161 description: The api response.
162 type: list
163 returned: always
164 response_message:
165 description: The descriptive message of the api response.
166 type: str
167 returned: always
168 sample: OK.
169 system_information:
170 description: The information of the target system.
171 type: dict
172 returned: always
173 rc:
174 description: The status the request.
175 type: int
176 returned: always
177 sample: 0
178 version_check_warning:
179 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
180 type: list
181 returned: complex
182 '''
183 from ansible.module_utils.basic import AnsibleModule
184 from ansible.module_utils.connection import Connection
185 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
186 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
187
188
189 def main():
190 urls_list = [
191 '/pm/config/adom/{adom}/obj/user/device/{device}/dynamic_mapping',
192 '/pm/config/global/obj/user/device/{device}/dynamic_mapping'
193 ]
194 module_arg_spec = {
195 'adom': {'required': True, 'type': 'str'},
196 'device': {'required': True, 'type': 'str'},
197 'revision_note': {'type': 'str'},
198 'user_device_dynamicmapping': {
199 'type': 'dict', 'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']],
200 'options': {
201 '_scope': {
202 'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']],
203 'type': 'list',
204 'options': {
205 'name': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
206 'vdom': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'}
207 },
208 'elements': 'dict'
209 },
210 'avatar': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
211 'category': {
212 'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']],
213 'choices': ['none', 'android-device', 'blackberry-device', 'fortinet-device', 'ios-device', 'windows-device', 'amazon-device'],
214 'type': 'str'
215 },
216 'comment': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
217 'mac': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
218 'master-device': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
219 'tags': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'},
220 'type': {
221 'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']],
222 'choices': [
223 'ipad', 'iphone', 'gaming-console', 'blackberry-phone', 'blackberry-playbook', 'linux-pc', 'mac', 'windows-pc', 'android-phone',
224 'android-tablet', 'media-streaming', 'windows-phone', 'fortinet-device', 'ip-phone', 'router-nat-device', 'other-network-device',
225 'windows-tablet', 'printer', 'forticam', 'fortifone', 'unknown'
226 ],
227 'type': 'str'
228 },
229 'user': {'v_range': [['6.0.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
230 'family': {'v_range': [['6.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
231 'hardware-vendor': {'v_range': [['6.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
232 'hardware-version': {'v_range': [['6.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
233 'os': {'v_range': [['6.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'},
234 'software-version': {'v_range': [['6.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'str'}
235 }
236 }
237 }
238
239 module_option_spec = get_module_arg_spec('full crud')
240 module_arg_spec.update(module_option_spec)
241 check_galaxy_version(module_arg_spec)
242 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_device_dynamicmapping'),
243 supports_check_mode=True)
244 if not module._socket_path:
245 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
246 connection = Connection(module._socket_path)
247 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
248 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
249 fmgr.process_crud()
250 module.exit_json(meta=module.params)
251
252
253 if __name__ == '__main__':
254 main()