Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_meta_sysmetafields.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_sysmetafields
15 short_description: System meta sys meta fields
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 meta:
29 description: The parameter (meta) in requested url.
30 type: str
31 required: true
32 system_meta_sysmetafields:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 fieldlength:
38 type: int
39 description: Fieldlength.
40 importance:
41 type: str
42 description: Importance.
43 choices: ['optional', 'required']
44 name:
45 type: str
46 description: Name.
47 required: true
48 '''
49
50 EXAMPLES = '''
51 - name: Example playbook
52 hosts: fortimanagers
53 gather_facts: false
54 connection: httpapi
55 vars:
56 ansible_httpapi_use_ssl: true
57 ansible_httpapi_validate_certs: false
58 ansible_httpapi_port: 443
59 tasks:
60 - name: Configure meta fields
61 fortinet.fortimanager.fmgr_system_meta_sysmetafields:
62 bypass_validation: false
63 adom: ansible
64 meta: ansible-test-meta # name
65 state: present
66 system_meta_sysmetafields:
67 fieldlength: 50
68 importance: optional # <value in [optional, required]>
69 name: ansible-test-fields
70
71 - name: Gathering fortimanager facts
72 hosts: fortimanagers
73 gather_facts: false
74 connection: httpapi
75 vars:
76 ansible_httpapi_use_ssl: true
77 ansible_httpapi_validate_certs: false
78 ansible_httpapi_port: 443
79 tasks:
80 - name: Retrieve all the meta fields
81 fortinet.fortimanager.fmgr_fact:
82 facts:
83 selector: "system_meta_sysmetafields"
84 params:
85 adom: "ansible"
86 meta: "ansible-test-meta" # name
87 sys_meta_fields: "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/{meta}/sys_meta_fields',
138 '/pm/config/global/obj/system/meta/{meta}/sys_meta_fields'
139 ]
140 module_arg_spec = {
141 'adom': {'required': True, 'type': 'str'},
142 'meta': {'required': True, 'type': 'str'},
143 'revision_note': {'type': 'str'},
144 'system_meta_sysmetafields': {
145 'type': 'dict', 'v_range': [['6.0.0', '']],
146 'options': {
147 'fieldlength': {'type': 'int'},
148 'importance': {'choices': ['optional', 'required'], 'type': 'str'},
149 'name': {'required': True, 'type': 'str'}
150 }
151 }
152 }
153
154 module_option_spec = get_module_arg_spec('full crud')
155 module_arg_spec.update(module_option_spec)
156 check_galaxy_version(module_arg_spec)
157 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_meta_sysmetafields'),
158 supports_check_mode=True)
159 if not module._socket_path:
160 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
161 connection = Connection(module._socket_path)
162 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
163 'name', 'data', module, connection)
164 fmgr.process_crud()
165 module.exit_json(meta=module.params)
166
167
168 if __name__ == '__main__':
169 main()