Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_antivirus_mmschecksum.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_antivirus_mmschecksum
15 short_description: Configure MMS content checksum list.
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 antivirus_mmschecksum:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Optional comments.
36 entries:
37 type: list
38 elements: dict
39 description: Entries.
40 suboptions:
41 checksum:
42 type: str
43 description: MMS attachment checksum value
44 name:
45 type: str
46 description: Entry name, for administrator reference
47 status:
48 type: str
49 description: Apply this entry during attachment inspection
50 choices: ['disable', 'enable']
51 id:
52 type: int
53 description: ID.
54 required: true
55 name:
56 type: str
57 description: Name of table.
58 '''
59
60 EXAMPLES = '''
61 - name: Example playbook
62 hosts: fortimanagers
63 gather_facts: false
64 connection: httpapi
65 vars:
66 ansible_httpapi_use_ssl: true
67 ansible_httpapi_validate_certs: false
68 ansible_httpapi_port: 443
69 tasks:
70 - name: Configure MMS content checksum list.
71 fortinet.fortimanager.fmgr_antivirus_mmschecksum:
72 adom: "FortiCarrier"
73 state: present
74 antivirus_mmschecksum:
75 comment: "test-comment"
76 entries:
77 - checksum: "test_checksum"
78 name: "entries-name"
79 status: disable
80 id: 1
81 name: "checksum-name"
82
83 - name: Gathering fortimanager facts
84 hosts: fortimanagers
85 gather_facts: false
86 connection: httpapi
87 vars:
88 ansible_httpapi_use_ssl: true
89 ansible_httpapi_validate_certs: false
90 ansible_httpapi_port: 443
91 tasks:
92 - name: Retrieve all the mms-checksums
93 fortinet.fortimanager.fmgr_fact:
94 facts:
95 selector: "antivirus_mmschecksum"
96 params:
97 adom: "FortiCarrier" # This is FOC-only object, data will only be returned under FortiCarrier adom
98 mms_checksum: ""
99 '''
100
101 RETURN = '''
102 meta:
103 description: The result of the request.
104 type: dict
105 returned: always
106 contains:
107 request_url:
108 description: The full url requested.
109 returned: always
110 type: str
111 sample: /sys/login/user
112 response_code:
113 description: The status of api request.
114 returned: always
115 type: int
116 sample: 0
117 response_data:
118 description: The api response.
119 type: list
120 returned: always
121 response_message:
122 description: The descriptive message of the api response.
123 type: str
124 returned: always
125 sample: OK.
126 system_information:
127 description: The information of the target system.
128 type: dict
129 returned: always
130 rc:
131 description: The status the request.
132 type: int
133 returned: always
134 sample: 0
135 version_check_warning:
136 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
137 type: list
138 returned: complex
139 '''
140 from ansible.module_utils.basic import AnsibleModule
141 from ansible.module_utils.connection import Connection
142 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
143 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
144
145
146 def main():
147 urls_list = [
148 '/pm/config/adom/{adom}/obj/antivirus/mms-checksum',
149 '/pm/config/global/obj/antivirus/mms-checksum'
150 ]
151 module_arg_spec = {
152 'adom': {'required': True, 'type': 'str'},
153 'revision_note': {'type': 'str'},
154 'antivirus_mmschecksum': {
155 'type': 'dict', 'v_range': [['6.0.0', '7.6.2']],
156 'options': {
157 'comment': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
158 'entries': {
159 'v_range': [['6.0.0', '7.6.2']],
160 'type': 'list',
161 'options': {
162 'checksum': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
163 'name': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
164 'status': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'}
165 },
166 'elements': 'dict'
167 },
168 'id': {'v_range': [['6.0.0', '7.6.2']], 'required': True, 'type': 'int'},
169 'name': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'}
170 }
171 }
172 }
173
174 module_option_spec = get_module_arg_spec('full crud')
175 module_arg_spec.update(module_option_spec)
176 check_galaxy_version(module_arg_spec)
177 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'antivirus_mmschecksum'),
178 supports_check_mode=True)
179 if not module._socket_path:
180 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
181 connection = Connection(module._socket_path)
182 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
183 'id', 'data', module, connection)
184 fmgr.process_crud()
185 module.exit_json(meta=module.params)
186
187
188 if __name__ == '__main__':
189 main()