Code Duplication    Length = 59-59 lines in 2 locations

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

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 7289-7347 (lines=59) @@
7286
7287
        return self._send_xml_command(cmd)
7288
7289
    def trigger_alert(
7290
        self,
7291
        alert_id: str,
7292
        report_id: str,
7293
        *,
7294
        filter: Optional[str] = None,
7295
        filter_id: Optional[str] = None,
7296
        report_format_id: Optional[Union[str, ReportFormatType]] = None,
7297
        delta_report_id: Optional[str] = None,
7298
    ) -> Any:
7299
        """Run an alert by ignoring its event and conditions
7300
7301
        The alert is triggered to run immediately with the provided filtered
7302
        report by ignoring the even and condition settings.
7303
7304
        Arguments:
7305
            alert_id: UUID of the alert to be run
7306
            report_id: UUID of the report to be provided to the alert
7307
            filter: Filter term to use to filter results in the report
7308
            filter_id: UUID of filter to use to filter results in the report
7309
            report_format_id: UUID of report format to use
7310
                              or ReportFormatType (enum)
7311
            delta_report_id: UUID of an existing report to compare report to.
7312
7313
        Returns:
7314
            The response. See :py:meth:`send_command` for details.
7315
        """
7316
        if not alert_id:
7317
            raise RequiredArgument(
7318
                function=self.trigger_alert.__name__,
7319
                argument='alert_id argument',
7320
            )
7321
7322
        if not report_id:
7323
            raise RequiredArgument(
7324
                function=self.trigger_alert.__name__,
7325
                argument='report_id argument',
7326
            )
7327
7328
        cmd = XmlCommand("get_reports")
7329
        cmd.set_attribute("report_id", report_id)
7330
        cmd.set_attribute("alert_id", alert_id)
7331
7332
        if filter:
7333
            cmd.set_attribute("filter", filter)
7334
7335
        if filter_id:
7336
            cmd.set_attribute("filt_id", filter_id)
7337
7338
        if report_format_id:
7339
            if isinstance(report_format_id, ReportFormatType):
7340
                report_format_id = report_format_id.value
7341
7342
            cmd.set_attribute("format_id", report_format_id)
7343
7344
        if delta_report_id:
7345
            cmd.set_attribute("delta_report_id", delta_report_id)
7346
7347
        return self._send_xml_command(cmd)
7348
7349
    def verify_report_format(
7350
        self, report_format_id: Union[str, ReportFormatType]