Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_antivirus_notification_entries.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_entries
15 short_description: modify this antivirus notification 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 notification:
29 description: The parameter (notification) in requested url.
30 type: str
31 required: true
32 antivirus_notification_entries:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 name:
38 type: str
39 description: Virus name or prefix
40 required: true
41 prefix:
42 type: str
43 description: Enable prefix matches based on this name
44 choices: ['disable', 'enable']
45 status:
46 type: str
47 description: Enable this entry for notifications
48 choices: ['disable', 'enable']
49 '''
50
51 EXAMPLES = '''
52 - name: Example playbook
53 hosts: fortimanagers
54 gather_facts: false
55 connection: httpapi
56 vars:
57 ansible_httpapi_use_ssl: true
58 ansible_httpapi_validate_certs: false
59 ansible_httpapi_port: 443
60 tasks:
61 - name: Modify this antivirus notification list
62 fortinet.fortimanager.fmgr_antivirus_notification_entries:
63 adom: FortiCarrier
64 notification: "1" # id
65 state: present
66 antivirus_notification_entries:
67 name: "notification-entry"
68 prefix: disable
69 status: disable
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 scripts
81 fortinet.fortimanager.fmgr_fact:
82 facts:
83 selector: "antivirus_notification_entries"
84 params:
85 adom: "FortiCarrier" # This is FOC-only object, data will only be returned under FortiCarrier adom
86 entries: "your_value"
87 notification: "1" # id
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/antivirus/notification/{notification}/entries',
138 '/pm/config/global/obj/antivirus/notification/{notification}/entries'
139 ]
140 module_arg_spec = {
141 'adom': {'required': True, 'type': 'str'},
142 'notification': {'required': True, 'type': 'str'},
143 'revision_note': {'type': 'str'},
144 'antivirus_notification_entries': {
145 'type': 'dict', 'v_range': [['6.0.0', '7.6.2']],
146 'options': {
147 'name': {'v_range': [['6.0.0', '7.6.2']], 'required': True, 'type': 'str'},
148 'prefix': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
149 'status': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], '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, 'antivirus_notification_entries'),
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()