Code Duplication    Length = 59-59 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 7257-7315 (lines=59) @@
7254
7255
        return self._send_xml_command(cmd)
7256
7257
    def trigger_alert(
7258
        self,
7259
        alert_id: str,
7260
        report_id: str,
7261
        *,
7262
        filter: Optional[str] = None,
7263
        filter_id: Optional[str] = None,
7264
        report_format_id: Optional[Union[str, ReportFormatType]] = None,
7265
        delta_report_id: Optional[str] = None,
7266
    ) -> Any:
7267
        """Run an alert by ignoring its event and conditions
7268
7269
        The alert is triggered to run immediately with the provided filtered
7270
        report by ignoring the even and condition settings.
7271
7272
        Arguments:
7273
            alert_id: UUID of the alert to be run
7274
            report_id: UUID of the report to be provided to the alert
7275
            filter: Filter term to use to filter results in the report
7276
            filter_id: UUID of filter to use to filter results in the report
7277
            report_format_id: UUID of report format to use
7278
                              or ReportFormatType (enum)
7279
            delta_report_id: UUID of an existing report to compare report to.
7280
7281
        Returns:
7282
            The response. See :py:meth:`send_command` for details.
7283
        """
7284
        if not alert_id:
7285
            raise RequiredArgument(
7286
                function=self.trigger_alert.__name__,
7287
                argument='alert_id argument',
7288
            )
7289
7290
        if not report_id:
7291
            raise RequiredArgument(
7292
                function=self.trigger_alert.__name__,
7293
                argument='report_id argument',
7294
            )
7295
7296
        cmd = XmlCommand("get_reports")
7297
        cmd.set_attribute("report_id", report_id)
7298
        cmd.set_attribute("alert_id", alert_id)
7299
7300
        if filter:
7301
            cmd.set_attribute("filter", filter)
7302
7303
        if filter_id:
7304
            cmd.set_attribute("filt_id", filter_id)
7305
7306
        if report_format_id:
7307
            if isinstance(report_format_id, ReportFormatType):
7308
                report_format_id = report_format_id.value
7309
7310
            cmd.set_attribute("format_id", report_format_id)
7311
7312
        if delta_report_id:
7313
            cmd.set_attribute("delta_report_id", delta_report_id)
7314
7315
        return self._send_xml_command(cmd)
7316
7317
    def verify_report_format(
7318
        self, report_format_id: Union[str, ReportFormatType]

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 6328-6386 (lines=59) @@
6325
6326
        return self._send_xml_command(cmd)
6327
6328
    def trigger_alert(
6329
        self,
6330
        alert_id: str,
6331
        report_id: str,
6332
        *,
6333
        filter: Optional[str] = None,
6334
        filter_id: Optional[str] = None,
6335
        report_format_id: Optional[Union[str, ReportFormatType]] = None,
6336
        delta_report_id: Optional[str] = None,
6337
    ) -> Any:
6338
        """Run an alert by ignoring its event and conditions
6339
6340
        The alert is triggered to run immediately with the provided filtered
6341
        report by ignoring the even and condition settings.
6342
6343
        Arguments:
6344
            alert_id: UUID of the alert to be run
6345
            report_id: UUID of the report to be provided to the alert
6346
            filter: Filter term to use to filter results in the report
6347
            filter_id: UUID of filter to use to filter results in the report
6348
            report_format_id: UUID of report format to use
6349
                              or ReportFormatType (enum)
6350
            delta_report_id: UUID of an existing report to compare report to.
6351
6352
        Returns:
6353
            The response. See :py:meth:`send_command` for details.
6354
        """
6355
        if not alert_id:
6356
            raise RequiredArgument(
6357
                function=self.trigger_alert.__name__,
6358
                argument='alert_id argument',
6359
            )
6360
6361
        if not report_id:
6362
            raise RequiredArgument(
6363
                function=self.trigger_alert.__name__,
6364
                argument='report_id argument',
6365
            )
6366
6367
        cmd = XmlCommand("get_reports")
6368
        cmd.set_attribute("report_id", report_id)
6369
        cmd.set_attribute("alert_id", alert_id)
6370
6371
        if filter:
6372
            cmd.set_attribute("filter", filter)
6373
6374
        if filter_id:
6375
            cmd.set_attribute("filt_id", filter_id)
6376
6377
        if report_format_id:
6378
            if isinstance(report_format_id, ReportFormatType):
6379
                report_format_id = report_format_id.value
6380
6381
            cmd.set_attribute("format_id", report_format_id)
6382
6383
        if delta_report_id:
6384
            cmd.set_attribute("delta_report_id", delta_report_id)
6385
6386
        return self._send_xml_command(cmd)
6387
6388
    def verify_agent(self, agent_id: str) -> Any:
6389
        """Verify an existing agent