Debian Codegraph @

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