Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_metadata_admins.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_system_metadata_admins
15 short_description: Configure admins.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_metadata_admins:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 fieldlength:
27 type: str
28 description:
29 - Field length.
30 - 20 - Field length of 20.
31 - 50 - Field length of 50.
32 - 255 - Field length of 255.
33 choices: ['20', '50', '255']
34 fieldname:
35 type: str
36 description: Field name.
37 required: true
38 importance:
39 type: str
40 description:
41 - Field importance.
42 - optional - This field is optional.
43 - required - This field is required.
44 choices: ['optional', 'required']
45 status:
46 type: str
47 description:
48 - Field status.
49 - disabled - This field is disabled.
50 - enabled - This field is enabled.
51 choices: ['disabled', 'enabled']
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 admins.
65 fortinet.fortimanager.fmgr_system_metadata_admins:
66 bypass_validation: false
67 state: present
68 system_metadata_admins:
69 fieldlength: 50 # <value in [20, 50, 255]>
70 fieldname: "ansible test"
71 importance: optional # <value in [optional, required]>
72 status: enabled
73
74 - name: Gathering fortimanager facts
75 hosts: fortimanagers
76 gather_facts: false
77 connection: httpapi
78 vars:
79 ansible_httpapi_use_ssl: true
80 ansible_httpapi_validate_certs: false
81 ansible_httpapi_port: 443
82 tasks:
83 - name: Retrieve all the admins
84 fortinet.fortimanager.fmgr_fact:
85 facts:
86 selector: "system_metadata_admins"
87 params:
88 admins: "your_value"
89 '''
90
91 RETURN = '''
92 meta:
93 description: The result of the request.
94 type: dict
95 returned: always
96 contains:
97 request_url:
98 description: The full url requested.
99 returned: always
100 type: str
101 sample: /sys/login/user
102 response_code:
103 description: The status of api request.
104 returned: always
105 type: int
106 sample: 0
107 response_data:
108 description: The api response.
109 type: list
110 returned: always
111 response_message:
112 description: The descriptive message of the api response.
113 type: str
114 returned: always
115 sample: OK.
116 system_information:
117 description: The information of the target system.
118 type: dict
119 returned: always
120 rc:
121 description: The status the request.
122 type: int
123 returned: always
124 sample: 0
125 version_check_warning:
126 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
127 type: list
128 returned: complex
129 '''
130 from ansible.module_utils.basic import AnsibleModule
131 from ansible.module_utils.connection import Connection
132 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
133 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
134
135
136 def main():
137 urls_list = [
138 '/cli/global/system/metadata/admins'
139 ]
140 module_arg_spec = {
141 'system_metadata_admins': {
142 'type': 'dict', 'v_range': [['6.0.0', '']],
143 'options': {
144 'fieldlength': {'choices': ['20', '50', '255'], 'type': 'str'},
145 'fieldname': {'required': True, 'type': 'str'},
146 'importance': {'choices': ['optional', 'required'], 'type': 'str'},
147 'status': {'choices': ['disabled', 'enabled'], 'type': 'str'}
148 }
149 }
150 }
151
152 module_option_spec = get_module_arg_spec('full crud')
153 module_arg_spec.update(module_option_spec)
154 check_galaxy_version(module_arg_spec)
155 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_metadata_admins'),
156 supports_check_mode=True)
157 if not module._socket_path:
158 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
159 connection = Connection(module._socket_path)
160 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
161 'fieldname', 'data', module, connection)
162 fmgr.process_crud()
163 module.exit_json(meta=module.params)
164
165
166 if __name__ == '__main__':
167 main()