Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_group_guest.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_group_guest
15 short_description: Guest User.
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 group:
29 description: The parameter (group) in requested url.
30 type: str
31 required: true
32 user_group_guest:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 comment:
38 type: str
39 description: Comment.
40 company:
41 type: str
42 description: Set the action for the company guest user field.
43 email:
44 type: str
45 description: Email.
46 expiration:
47 type: str
48 description: Expire time.
49 mobile_phone:
50 aliases: ['mobile-phone']
51 type: str
52 description: Mobile phone.
53 name:
54 type: str
55 description: Guest name.
56 password:
57 type: raw
58 description: (list) Guest password.
59 sponsor:
60 type: str
61 description: Set the action for the sponsor guest user field.
62 user_id:
63 aliases: ['user-id']
64 type: str
65 description: Guest ID.
66 required: true
67 group:
68 type: str
69 description: Guest name.
70 id:
71 type: int
72 description: Guest ID.
73 '''
74
75 EXAMPLES = '''
76 - name: Example playbook
77 hosts: fortimanagers
78 gather_facts: false
79 connection: httpapi
80 vars:
81 ansible_httpapi_use_ssl: true
82 ansible_httpapi_validate_certs: false
83 ansible_httpapi_port: 443
84 tasks:
85 - name: Guest User.
86 fortinet.fortimanager.fmgr_user_group_guest:
87 bypass_validation: false
88 adom: FortiCarrier
89 group: ansible-test-group # name
90 state: present
91 user_group_guest:
92 comment: ansible-comment
93 email: [email protected]
94 name: ansible-test-guest
95 password: fortinet
96 user_id: Email
97
98 - name: Gathering fortimanager facts
99 hosts: fortimanagers
100 gather_facts: false
101 connection: httpapi
102 vars:
103 ansible_httpapi_use_ssl: true
104 ansible_httpapi_validate_certs: false
105 ansible_httpapi_port: 443
106 tasks:
107 - name: Retrieve all the guest users
108 fortinet.fortimanager.fmgr_fact:
109 facts:
110 selector: "user_group_guest" # Note: this session will been shown only if the Type parameter in User Grup is 'GUEST'
111 params:
112 adom: "FortiCarrier"
113 group: "ansible-test-group" # name
114 guest: "your_value"
115 '''
116
117 RETURN = '''
118 meta:
119 description: The result of the request.
120 type: dict
121 returned: always
122 contains:
123 request_url:
124 description: The full url requested.
125 returned: always
126 type: str
127 sample: /sys/login/user
128 response_code:
129 description: The status of api request.
130 returned: always
131 type: int
132 sample: 0
133 response_data:
134 description: The api response.
135 type: list
136 returned: always
137 response_message:
138 description: The descriptive message of the api response.
139 type: str
140 returned: always
141 sample: OK.
142 system_information:
143 description: The information of the target system.
144 type: dict
145 returned: always
146 rc:
147 description: The status the request.
148 type: int
149 returned: always
150 sample: 0
151 version_check_warning:
152 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
153 type: list
154 returned: complex
155 '''
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible.module_utils.connection import Connection
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
160
161
162 def main():
163 urls_list = [
164 '/pm/config/adom/{adom}/obj/user/group/{group}/guest',
165 '/pm/config/global/obj/user/group/{group}/guest'
166 ]
167 module_arg_spec = {
168 'adom': {'required': True, 'type': 'str'},
169 'group': {'required': True, 'type': 'str'},
170 'revision_note': {'type': 'str'},
171 'user_group_guest': {
172 'type': 'dict', 'v_range': [['6.0.0', '']],
173 'options': {
174 'comment': {'type': 'str'},
175 'company': {'type': 'str'},
176 'email': {'type': 'str'},
177 'expiration': {'type': 'str'},
178 'mobile-phone': {'type': 'str'},
179 'name': {'type': 'str'},
180 'password': {'no_log': True, 'type': 'raw'},
181 'sponsor': {'type': 'str'},
182 'user-id': {'required': True, 'type': 'str'},
183 'group': {'v_range': [['6.2.0', '6.2.13']], 'type': 'str'},
184 'id': {'v_range': [['6.2.3', '']], 'type': 'int'}
185 }
186 }
187 }
188
189 module_option_spec = get_module_arg_spec('full crud')
190 module_arg_spec.update(module_option_spec)
191 check_galaxy_version(module_arg_spec)
192 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_group_guest'),
193 supports_check_mode=True)
194 if not module._socket_path:
195 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
196 connection = Connection(module._socket_path)
197 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
198 'user-id', 'data', module, connection)
199 fmgr.process_crud()
200 module.exit_json(meta=module.params)
201
202
203 if __name__ == '__main__':
204 main()