Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_sql_customindex.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_sql_customindex
15 short_description: List of SQL index fields.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_sql_customindex:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 case_sensitive:
27 aliases: ['case-sensitive']
28 type: str
29 description:
30 - Disable/Enable case sensitive index.
31 - disable - Build a case insensitive index.
32 - enable - Build a case sensitive index.
33 choices: ['disable', 'enable']
34 device_type:
35 aliases: ['device-type']
36 type: str
37 description:
38 - Device type.
39 - FortiGate - Device type to FortiGate.
40 - FortiManager - Set device type to FortiManager
41 - FortiClient - Set device type to FortiClient
42 - FortiMail - Device type to FortiMail.
43 - FortiWeb - Device type to FortiWeb.
44 - FortiCache - Set device type to FortiCache
45 - FortiSandbox - Set device type to FortiSandbox
46 - FortiDDoS - Set device type to FortiDDoS
47 - FortiAuthenticator - Set device type to FortiAuthenticator
48 - FortiProxy - Set device type to FortiProxy
49 choices: ['FortiGate', 'FortiManager', 'FortiClient', 'FortiMail', 'FortiWeb',
50 'FortiCache', 'FortiSandbox', 'FortiDDoS', 'FortiAuthenticator',
51 'FortiProxy']
52 id:
53 type: int
54 description: Add or Edit log index fields.
55 required: true
56 index_field:
57 aliases: ['index-field']
58 type: str
59 description: Log field name to be indexed.
60 log_type:
61 aliases: ['log-type']
62 type: str
63 description:
64 - Log type.
65 - none - none
66 - app-ctrl
67 - attack
68 - content
69 - dlp
70 - emailfilter
71 - event
72 - generic
73 - history
74 - traffic
75 - virus
76 - voip
77 - webfilter
78 - netscan
79 - fct-event
80 - fct-traffic
81 - fct-netscan
82 - waf
83 - gtp
84 - dns
85 - ssh
86 - ssl
87 choices: ['none', 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event',
88 'generic', 'history', 'traffic', 'virus', 'voip', 'webfilter',
89 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf', 'gtp',
90 'dns', 'ssh', 'ssl', 'file-filter', 'asset', 'protocol', 'siem', 'ztna',
91 'security']
92 '''
93
94 EXAMPLES = '''
95 - name: Example playbook
96 hosts: fortimanagers
97 gather_facts: false
98 connection: httpapi
99 vars:
100 ansible_httpapi_use_ssl: true
101 ansible_httpapi_validate_certs: false
102 ansible_httpapi_port: 443
103 tasks:
104 - name: List of SQL index fields.
105 fortinet.fortimanager.fmgr_system_sql_customindex:
106 bypass_validation: false
107 state: present
108 system_sql_customindex:
109 case_sensitive: disable
110 device_type: FortiGate # <value in [FortiGate, FortiManager, FortiClient, ...]>
111 id: 1
112 index_field: srcip
113 log_type: attack # <value in [none, app-ctrl, attack, ...]>
114
115 - name: Gathering fortimanager facts
116 hosts: fortimanagers
117 gather_facts: false
118 connection: httpapi
119 vars:
120 ansible_httpapi_use_ssl: true
121 ansible_httpapi_validate_certs: false
122 ansible_httpapi_port: 443
123 tasks:
124 - name: Retrieve all the SQL index fields
125 fortinet.fortimanager.fmgr_fact:
126 facts:
127 selector: "system_sql_customindex"
128 params:
129 custom_index: "your_value"
130 '''
131
132 RETURN = '''
133 meta:
134 description: The result of the request.
135 type: dict
136 returned: always
137 contains:
138 request_url:
139 description: The full url requested.
140 returned: always
141 type: str
142 sample: /sys/login/user
143 response_code:
144 description: The status of api request.
145 returned: always
146 type: int
147 sample: 0
148 response_data:
149 description: The api response.
150 type: list
151 returned: always
152 response_message:
153 description: The descriptive message of the api response.
154 type: str
155 returned: always
156 sample: OK.
157 system_information:
158 description: The information of the target system.
159 type: dict
160 returned: always
161 rc:
162 description: The status the request.
163 type: int
164 returned: always
165 sample: 0
166 version_check_warning:
167 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
168 type: list
169 returned: complex
170 '''
171 from ansible.module_utils.basic import AnsibleModule
172 from ansible.module_utils.connection import Connection
173 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
174 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
175
176
177 def main():
178 urls_list = [
179 '/cli/global/system/sql/custom-index'
180 ]
181 module_arg_spec = {
182 'system_sql_customindex': {
183 'type': 'dict', 'v_range': [['6.0.0', '']],
184 'options': {
185 'case-sensitive': {'choices': ['disable', 'enable'], 'type': 'str'},
186 'device-type': {
187 'choices': [
188 'FortiGate', 'FortiManager', 'FortiClient', 'FortiMail', 'FortiWeb', 'FortiCache', 'FortiSandbox', 'FortiDDoS',
189 'FortiAuthenticator', 'FortiProxy'
190 ],
191 'type': 'str'
192 },
193 'id': {'required': True, 'type': 'int'},
194 'index-field': {'type': 'str'},
195 'log-type': {
196 'choices': [
197 'none', 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event', 'generic', 'history', 'traffic', 'virus', 'voip',
198 'webfilter', 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf', 'gtp', 'dns', 'ssh', 'ssl', 'file-filter', 'asset',
199 'protocol', 'siem', 'ztna', 'security'
200 ],
201 'type': 'str'
202 }
203 }
204 }
205 }
206
207 module_option_spec = get_module_arg_spec('full crud')
208 module_arg_spec.update(module_option_spec)
209 check_galaxy_version(module_arg_spec)
210 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_sql_customindex'),
211 supports_check_mode=True)
212 if not module._socket_path:
213 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
214 connection = Connection(module._socket_path)
215 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
216 'id', 'data', module, connection)
217 fmgr.process_crud()
218 module.exit_json(meta=module.params)
219
220
221 if __name__ == '__main__':
222 main()