Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_mmsprofile_flood.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_firewall_mmsprofile_flood
15 short_description: Flood configuration.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_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 mms-profile:
29 description: Deprecated, please use "mms_profile"
30 type: str
31 mms_profile:
32 description: The parameter (mms-profile) in requested url.
33 type: str
34 firewall_mmsprofile_flood:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 action1:
40 type: list
41 elements: str
42 description: Action to take when threshold reached.
43 choices: ['log', 'archive', 'intercept', 'block', 'archive-first', 'alert-notif']
44 action2:
45 type: list
46 elements: str
47 description: Action to take when threshold reached.
48 choices: ['log', 'archive', 'intercept', 'block', 'archive-first', 'alert-notif']
49 action3:
50 type: list
51 elements: str
52 description: Action to take when threshold reached.
53 choices: ['log', 'archive', 'intercept', 'block', 'archive-first', 'alert-notif']
54 block_time1:
55 aliases: ['block-time1']
56 type: int
57 description: Duration for which action takes effect
58 block_time2:
59 aliases: ['block-time2']
60 type: int
61 description: Duration for which action takes effect
62 block_time3:
63 aliases: ['block-time3']
64 type: int
65 description: Duration action takes effect
66 limit1:
67 type: int
68 description: Maximum number of messages allowed.
69 limit2:
70 type: int
71 description: Maximum number of messages allowed.
72 limit3:
73 type: int
74 description: Maximum number of messages allowed.
75 protocol:
76 type: str
77 description: Protocol.
78 status1:
79 type: str
80 description: Enable/disable status1 detection.
81 choices: ['disable', 'enable']
82 status2:
83 type: str
84 description: Enable/disable status2 detection.
85 choices: ['disable', 'enable']
86 status3:
87 type: str
88 description: Enable/disable status3 detection.
89 choices: ['disable', 'enable']
90 window1:
91 type: int
92 description: Window to count messages over
93 window2:
94 type: int
95 description: Window to count messages over
96 window3:
97 type: int
98 description: Window to count messages over
99 '''
100
101 EXAMPLES = '''
102 - name: Example playbook (generated based on argument schema)
103 hosts: fortimanagers
104 connection: httpapi
105 gather_facts: false
106 tasks:
107 - name: Flood configuration.
108 fortinet.fortimanager.fmgr_firewall_mmsprofile_flood:
109 # workspace_locking_adom: <global or your adom name>
110 adom: <your own value>
111 mms_profile: <your own value>
112 firewall_mmsprofile_flood:
113 # action1: ["log", "archive", "intercept", "block", "archive-first", "alert-notif"]
114 # action2: ["log", "archive", "intercept", "block", "archive-first", "alert-notif"]
115 # action3: ["log", "archive", "intercept", "block", "archive-first", "alert-notif"]
116 # block_time1: <integer>
117 # block_time2: <integer>
118 # block_time3: <integer>
119 # limit1: <integer>
120 # limit2: <integer>
121 # limit3: <integer>
122 # protocol: <string>
123 # status1: <value in [disable, enable]>
124 # status2: <value in [disable, enable]>
125 # status3: <value in [disable, enable]>
126 # window1: <integer>
127 # window2: <integer>
128 # window3: <integer>
129 '''
130
131 RETURN = '''
132 meta:
133 description: The result of the request.
134 type: dict
135 returned: always
136 contains:
137 request_url:
138 description: The full url requested.
139 returned: always
140 type: str
141 sample: /sys/login/user
142 response_code:
143 description: The status of api request.
144 returned: always
145 type: int
146 sample: 0
147 response_data:
148 description: The api response.
149 type: list
150 returned: always
151 response_message:
152 description: The descriptive message of the api response.
153 type: str
154 returned: always
155 sample: OK.
156 system_information:
157 description: The information of the target system.
158 type: dict
159 returned: always
160 rc:
161 description: The status the request.
162 type: int
163 returned: always
164 sample: 0
165 version_check_warning:
166 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
167 type: list
168 returned: complex
169 '''
170 from ansible.module_utils.basic import AnsibleModule
171 from ansible.module_utils.connection import Connection
172 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
173 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
174
175
176 def main():
177 urls_list = [
178 '/pm/config/adom/{adom}/obj/firewall/mms-profile/{mms-profile}/flood',
179 '/pm/config/global/obj/firewall/mms-profile/{mms-profile}/flood'
180 ]
181 module_arg_spec = {
182 'adom': {'required': True, 'type': 'str'},
183 'mms-profile': {'type': 'str', 'api_name': 'mms_profile'},
184 'mms_profile': {'type': 'str'},
185 'revision_note': {'type': 'str'},
186 'firewall_mmsprofile_flood': {
187 'type': 'dict', 'v_range': [['6.0.0', '7.6.2']],
188 'options': {
189 'action1': {
190 'v_range': [['6.0.0', '7.6.2']],
191 'type': 'list',
192 'choices': ['log', 'archive', 'intercept', 'block', 'archive-first', 'alert-notif'],
193 'elements': 'str'
194 },
195 'action2': {
196 'v_range': [['6.0.0', '7.6.2']],
197 'type': 'list',
198 'choices': ['log', 'archive', 'intercept', 'block', 'archive-first', 'alert-notif'],
199 'elements': 'str'
200 },
201 'action3': {
202 'v_range': [['6.0.0', '7.6.2']],
203 'type': 'list',
204 'choices': ['log', 'archive', 'intercept', 'block', 'archive-first', 'alert-notif'],
205 'elements': 'str'
206 },
207 'block-time1': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
208 'block-time2': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
209 'block-time3': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
210 'limit1': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
211 'limit2': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
212 'limit3': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
213 'protocol': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
214 'status1': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
215 'status2': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
216 'status3': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
217 'window1': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
218 'window2': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'},
219 'window3': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'}
220 }
221 }
222 }
223
224 module_option_spec = get_module_arg_spec('partial crud')
225 module_arg_spec.update(module_option_spec)
226 check_galaxy_version(module_arg_spec)
227 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_mmsprofile_flood'),
228 supports_check_mode=True)
229 if not module._socket_path:
230 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
231 connection = Connection(module._socket_path)
232 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
233 None, 'data', module, connection)
234 fmgr.process_partial_crud()
235 module.exit_json(meta=module.params)
236
237
238 if __name__ == '__main__':
239 main()