Code Duplication    Length = 89-89 lines in 2 locations

gvm/protocols/gmpv214/gmpv214.py 2 locations

@@ 302-390 (lines=89) @@
299
300
        return self._send_xml_command(cmd)
301
302
    def modify_override(
303
        self,
304
        override_id: str,
305
        text: str,
306
        *,
307
        days_active: Optional[int] = None,
308
        hosts: Optional[List[str]] = None,
309
        port: Optional[int] = None,
310
        result_id: Optional[str] = None,
311
        severity: Optional[Severity] = None,
312
        new_severity: Optional[Severity] = None,
313
        task_id: Optional[str] = None,
314
        threat: Optional[SeverityLevel] = None,
315
        new_threat: Optional[SeverityLevel] = None
316
    ) -> Any:
317
        """Modifies an existing override.
318
319
        Arguments:
320
            override_id: UUID of override to modify.
321
            text: The text of the override.
322
            days_active: Days override will be active. -1 on always,
323
                0 off.
324
            hosts: A list of host addresses
325
            port: Port to which override applies.
326
            result_id: Result to which override applies.
327
            severity: Severity to which override applies.
328
            new_severity: New severity score for result.
329
            task_id: Task to which override applies.
330
            threat: Threat level to which override applies.
331
                Will be converted to severity.
332
            new_threat: New threat level for results. Will be converted to
333
                new_severity.
334
335
        Returns:
336
            The response. See :py:meth:`send_command` for details.
337
        """
338
        if not override_id:
339
            raise RequiredArgument(
340
                function=self.modify_override.__name__, argument='override_id'
341
            )
342
        if not text:
343
            raise RequiredArgument(
344
                function=self.modify_override.__name__, argument='text'
345
            )
346
347
        cmd = XmlCommand("modify_override")
348
        cmd.set_attribute("override_id", override_id)
349
        cmd.add_element("text", text)
350
351
        if days_active is not None:
352
            cmd.add_element("active", str(days_active))
353
354
        if hosts:
355
            cmd.add_element("hosts", _to_comma_list(hosts))
356
357
        if port:
358
            cmd.add_element("port", str(port))
359
360
        if result_id:
361
            cmd.add_element("result", attrs={"id": result_id})
362
363
        if severity:
364
            cmd.add_element("severity", str(severity))
365
366
        if new_severity:
367
            cmd.add_element("new_severity", str(new_severity))
368
369
        if task_id:
370
            cmd.add_element("task", attrs={"id": task_id})
371
372
        if threat is not None:
373
            deprecation(
374
                "The threat parameter has been removed in GMP"
375
                " version {}{}".format(
376
                    self.get_protocol_version()[0],
377
                    self.get_protocol_version()[1],
378
                )
379
            )
380
381
        if new_threat is not None:
382
            deprecation(
383
                "The new_threat parameter has been removed in GMP"
384
                " version {}{}".format(
385
                    self.get_protocol_version()[0],
386
                    self.get_protocol_version()[1],
387
                )
388
            )
389
390
        return self._send_xml_command(cmd)
391
@@ 139-227 (lines=89) @@
136
137
        return self._send_xml_command(cmd)
138
139
    def create_override(
140
        self,
141
        text: str,
142
        nvt_oid: str,
143
        *,
144
        days_active: Optional[int] = None,
145
        hosts: Optional[List[str]] = None,
146
        port: Optional[int] = None,
147
        result_id: Optional[str] = None,
148
        severity: Optional[Severity] = None,
149
        new_severity: Optional[Severity] = None,
150
        task_id: Optional[str] = None,
151
        threat: Optional[SeverityLevel] = None,
152
        new_threat: Optional[SeverityLevel] = None
153
    ) -> Any:
154
        """Create a new override
155
156
        Arguments:
157
            text: Text of the new override
158
            nvt_id: OID of the nvt to which override applies
159
            days_active: Days override will be active. -1 on always, 0 off
160
            hosts: A list of host addresses
161
            port: Port to which the override applies
162
            result_id: UUID of a result to which override applies
163
            severity: Severity to which override applies
164
            new_severity: New severity for result
165
            task_id: UUID of task to which override applies
166
            threat: Severity level to which override applies. Will be converted
167
                to severity.
168
            new_threat: New severity level for results. Will be converted to
169
                new_severity.
170
171
        Returns:
172
            The response. See :py:meth:`send_command` for details.
173
        """
174
        if not text:
175
            raise RequiredArgument(
176
                function=self.create_override.__name__, argument='text'
177
            )
178
179
        if not nvt_oid:
180
            raise RequiredArgument(
181
                function=self.create_override.__name__, argument='nvt_oid'
182
            )
183
184
        cmd = XmlCommand("create_override")
185
        cmd.add_element("text", text)
186
        cmd.add_element("nvt", attrs={"oid": nvt_oid})
187
188
        if days_active is not None:
189
            cmd.add_element("active", str(days_active))
190
191
        if hosts:
192
            cmd.add_element("hosts", _to_comma_list(hosts))
193
194
        if port:
195
            cmd.add_element("port", str(port))
196
197
        if result_id:
198
            cmd.add_element("result", attrs={"id": result_id})
199
200
        if severity:
201
            cmd.add_element("severity", str(severity))
202
203
        if new_severity:
204
            cmd.add_element("new_severity", str(new_severity))
205
206
        if task_id:
207
            cmd.add_element("task", attrs={"id": task_id})
208
209
        if threat is not None:
210
            deprecation(
211
                "The threat parameter has been removed in GMP"
212
                " version {}{}".format(
213
                    self.get_protocol_version()[0],
214
                    self.get_protocol_version()[1],
215
                )
216
            )
217
218
        if new_threat is not None:
219
            deprecation(
220
                "The new_threat parameter has been removed in GMP"
221
                " version {}{}".format(
222
                    self.get_protocol_version()[0],
223
                    self.get_protocol_version()[1],
224
                )
225
            )
226
227
        return self._send_xml_command(cmd)
228
229
    def modify_note(
230
        self,