Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_devicegroup.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_devicegroup
15 short_description: Configure device groups.
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 user_devicegroup:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 _if_unmanaged:
34 type: int
35 description: If unmanaged.
36 comment:
37 type: str
38 description: Comment.
39 dynamic_mapping:
40 type: list
41 elements: dict
42 description: Dynamic mapping.
43 suboptions:
44 _if_unmanaged:
45 type: int
46 description: If unmanaged.
47 _scope:
48 type: list
49 elements: dict
50 description: Scope.
51 suboptions:
52 name:
53 type: str
54 description: Name.
55 vdom:
56 type: str
57 description: Vdom.
58 comment:
59 type: str
60 description: Comment.
61 member:
62 type: list
63 elements: str
64 description: Member.
65 member:
66 type: list
67 elements: str
68 description: Device group member.
69 name:
70 type: str
71 description: Device group name.
72 required: true
73 tagging:
74 type: list
75 elements: dict
76 description: Tagging.
77 suboptions:
78 category:
79 type: str
80 description: Tag category.
81 name:
82 type: str
83 description: Tagging entry name.
84 tags:
85 type: raw
86 description: (list) Tags.
87 '''
88
89 EXAMPLES = '''
90 - name: Example playbook
91 hosts: fortimanagers
92 gather_facts: false
93 connection: httpapi
94 vars:
95 ansible_httpapi_use_ssl: true
96 ansible_httpapi_validate_certs: false
97 ansible_httpapi_port: 443
98 tasks:
99 - name: Create User Device Group
100 fortinet.fortimanager.fmgr_user_devicegroup:
101 adom: ansible
102 state: "present"
103 user_devicegroup:
104 name: ansible-test
105
106 - name: Configure dynamic mappings of device group
107 fortinet.fortimanager.fmgr_user_devicegroup_dynamicmapping:
108 bypass_validation: false
109 adom: ansible
110 device_group: ansible-test # name
111 state: present
112 user_devicegroup_dynamicmapping:
113 _if_unmanaged: 10
114 _scope:
115 - name: FGT_AWS # need a valid device name
116 vdom: root # need a valid vdom name under the device
117 comment: ansible-comment
118 member: ios-device
119 '''
120
121 RETURN = '''
122 meta:
123 description: The result of the request.
124 type: dict
125 returned: always
126 contains:
127 request_url:
128 description: The full url requested.
129 returned: always
130 type: str
131 sample: /sys/login/user
132 response_code:
133 description: The status of api request.
134 returned: always
135 type: int
136 sample: 0
137 response_data:
138 description: The api response.
139 type: list
140 returned: always
141 response_message:
142 description: The descriptive message of the api response.
143 type: str
144 returned: always
145 sample: OK.
146 system_information:
147 description: The information of the target system.
148 type: dict
149 returned: always
150 rc:
151 description: The status the request.
152 type: int
153 returned: always
154 sample: 0
155 version_check_warning:
156 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
157 type: list
158 returned: complex
159 '''
160 from ansible.module_utils.basic import AnsibleModule
161 from ansible.module_utils.connection import Connection
162 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
163 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
164
165
166 def main():
167 urls_list = [
168 '/pm/config/adom/{adom}/obj/user/device-group',
169 '/pm/config/global/obj/user/device-group'
170 ]
171 module_arg_spec = {
172 'adom': {'required': True, 'type': 'str'},
173 'revision_note': {'type': 'str'},
174 'user_devicegroup': {
175 'type': 'dict', 'v_range': [['6.0.0', '7.2.1']],
176 'options': {
177 '_if_unmanaged': {'v_range': [['6.0.0', '7.2.1']], 'type': 'int'},
178 'comment': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
179 'dynamic_mapping': {
180 'v_range': [['6.0.0', '7.2.1']],
181 'type': 'list',
182 'options': {
183 '_if_unmanaged': {'v_range': [['6.0.0', '7.2.1']], 'type': 'int'},
184 '_scope': {
185 'v_range': [['6.0.0', '7.2.1']],
186 'type': 'list',
187 'options': {
188 'name': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
189 'vdom': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'}
190 },
191 'elements': 'dict'
192 },
193 'comment': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
194 'member': {'v_range': [['6.0.0', '7.2.1']], 'type': 'list', 'elements': 'str'}
195 },
196 'elements': 'dict'
197 },
198 'member': {'v_range': [['6.0.0', '7.2.1']], 'type': 'list', 'elements': 'str'},
199 'name': {'v_range': [['6.0.0', '7.2.1']], 'required': True, 'type': 'str'},
200 'tagging': {
201 'v_range': [['6.0.0', '7.2.1']],
202 'type': 'list',
203 'options': {
204 'category': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
205 'name': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
206 'tags': {'v_range': [['6.0.0', '7.2.1']], 'type': 'raw'}
207 },
208 'elements': 'dict'
209 }
210 }
211 }
212 }
213
214 module_option_spec = get_module_arg_spec('full crud')
215 module_arg_spec.update(module_option_spec)
216 check_galaxy_version(module_arg_spec)
217 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_devicegroup'),
218 supports_check_mode=True)
219 if not module._socket_path:
220 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
221 connection = Connection(module._socket_path)
222 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
223 'name', 'data', module, connection)
224 fmgr.process_crud()
225 module.exit_json(meta=module.params)
226
227
228 if __name__ == '__main__':
229 main()