Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_adgrp.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_adgrp
15 short_description: Configure FSSO 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_adgrp:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 name:
34 type: str
35 description: Name.
36 server_name:
37 aliases: ['server-name']
38 type: str
39 description: FSSO agent name.
40 id:
41 type: int
42 description: Id.
43 required: true
44 polling_id:
45 aliases: ['polling-id']
46 type: str
47 description: FSSO polling ID.
48 connector_source:
49 aliases: ['connector-source']
50 type: str
51 description: FSSO connector source.
52 '''
53
54 EXAMPLES = '''
55 - name: Example playbook
56 hosts: fortimanagers
57 gather_facts: false
58 connection: httpapi
59 vars:
60 ansible_httpapi_use_ssl: true
61 ansible_httpapi_validate_certs: false
62 ansible_httpapi_port: 443
63 tasks:
64 - name: Configure FSSO groups via fmgr_generic module.
65 fortinet.fortimanager.fmgr_generic:
66 method: "set"
67 params:
68 - url: "/pm/config/adom/ansible/obj/user/adgrp"
69 data:
70 - name: "ansible-test-adgrp"
71
72 - name: Configure FSSO groups.
73 when: false
74 fortinet.fortimanager.fmgr_user_adgrp:
75 bypass_validation: true
76 adom: ansible
77 state: present
78 user_adgrp:
79 name: ansible-test-adgrp
80 server_name: ansible-fsso # need a valid server name
81
82 - name: Gathering fortimanager facts
83 hosts: fortimanagers
84 gather_facts: false
85 connection: httpapi
86 vars:
87 ansible_httpapi_use_ssl: true
88 ansible_httpapi_validate_certs: false
89 ansible_httpapi_port: 443
90 tasks:
91 - name: Retrieve all the FSSO groups
92 fortinet.fortimanager.fmgr_fact:
93 facts:
94 selector: "user_adgrp"
95 params:
96 adom: "ansible"
97 adgrp: "your_value"
98 '''
99
100 RETURN = '''
101 meta:
102 description: The result of the request.
103 type: dict
104 returned: always
105 contains:
106 request_url:
107 description: The full url requested.
108 returned: always
109 type: str
110 sample: /sys/login/user
111 response_code:
112 description: The status of api request.
113 returned: always
114 type: int
115 sample: 0
116 response_data:
117 description: The api response.
118 type: list
119 returned: always
120 response_message:
121 description: The descriptive message of the api response.
122 type: str
123 returned: always
124 sample: OK.
125 system_information:
126 description: The information of the target system.
127 type: dict
128 returned: always
129 rc:
130 description: The status the request.
131 type: int
132 returned: always
133 sample: 0
134 version_check_warning:
135 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
136 type: list
137 returned: complex
138 '''
139 from ansible.module_utils.basic import AnsibleModule
140 from ansible.module_utils.connection import Connection
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
142 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
143
144
145 def main():
146 urls_list = [
147 '/pm/config/adom/{adom}/obj/user/adgrp',
148 '/pm/config/global/obj/user/adgrp'
149 ]
150 module_arg_spec = {
151 'adom': {'required': True, 'type': 'str'},
152 'revision_note': {'type': 'str'},
153 'user_adgrp': {
154 'type': 'dict', 'v_range': [['6.0.0', '']],
155 'options': {
156 'name': {'type': 'str'},
157 'server-name': {'type': 'str'},
158 'id': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'int'},
159 'polling-id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'},
160 'connector-source': {'v_range': [['6.4.0', '']], 'type': 'str'}
161 }
162 }
163 }
164
165 module_option_spec = get_module_arg_spec('full crud')
166 module_arg_spec.update(module_option_spec)
167 check_galaxy_version(module_arg_spec)
168 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_adgrp'),
169 supports_check_mode=True)
170 if not module._socket_path:
171 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
172 connection = Connection(module._socket_path)
173 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
174 'id', 'data', module, connection)
175 fmgr.process_crud()
176 module.exit_json(meta=module.params)
177
178
179 if __name__ == '__main__':
180 main()