Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_antivirus_notification.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_notification
15 short_description: Configure AntiVirus notification lists.
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_notification:
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 name:
42 type: str
43 description: Virus name or prefix
44 prefix:
45 type: str
46 description: Enable prefix matches based on this name
47 choices: ['disable', 'enable']
48 status:
49 type: str
50 description: Enable this entry for notifications
51 choices: ['disable', 'enable']
52 id:
53 type: int
54 description: ID.
55 required: true
56 name:
57 type: str
58 description: Name of table.
59 '''
60
61 EXAMPLES = '''
62 - name: Example playbook
63 hosts: fortimanagers
64 gather_facts: false
65 connection: httpapi
66 vars:
67 ansible_httpapi_use_ssl: true
68 ansible_httpapi_validate_certs: false
69 ansible_httpapi_port: 443
70 tasks:
71 - name: Configure AntiVirus notification lists.
72 fortinet.fortimanager.fmgr_antivirus_notification:
73 adom: FortiCarrier
74 state: present
75 antivirus_notification:
76 entries:
77 - name: "notification-entry"
78 prefix: enable
79 status: enable
80 id: 1
81 name: "notifiction-test"
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 notifications
93 fortinet.fortimanager.fmgr_fact:
94 facts:
95 selector: "antivirus_notification"
96 params:
97 adom: "FortiCarrier" # This is FOC-only object, data will only be returned under FortiCarrier adom
98 notification: "your_value"
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/notification',
149 '/pm/config/global/obj/antivirus/notification'
150 ]
151 module_arg_spec = {
152 'adom': {'required': True, 'type': 'str'},
153 'revision_note': {'type': 'str'},
154 'antivirus_notification': {
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 'name': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
163 'prefix': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], '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_notification'),
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()