Code Duplication    Length = 29-31 lines in 6 locations

gvm/protocols/gmpv208/gmpv208.py 4 locations

@@ 3515-3545 (lines=31) @@
3512
        cmd.set_attribute("role_id", role_id)
3513
        return self._send_xml_command(cmd)
3514
3515
    def get_scanners(
3516
        self,
3517
        *,
3518
        filter: Optional[str] = None,
3519
        filter_id: Optional[str] = None,
3520
        trash: Optional[bool] = None,
3521
        details: Optional[bool] = None,
3522
    ) -> Any:
3523
        """Request a list of scanners
3524
3525
        Arguments:
3526
            filter: Filter term to use for the query
3527
            filter_id: UUID of an existing filter to use for the query
3528
            trash: Whether to get the trashcan scanners instead
3529
            details:  Whether to include extra details like tasks using this
3530
                scanner
3531
3532
        Returns:
3533
            The response. See :py:meth:`send_command` for details.
3534
        """
3535
        cmd = XmlCommand("get_scanners")
3536
3537
        add_filter(cmd, filter, filter_id)
3538
3539
        if trash is not None:
3540
            cmd.set_attribute("trash", to_bool(trash))
3541
3542
        if details is not None:
3543
            cmd.set_attribute("details", to_bool(details))
3544
3545
        return self._send_xml_command(cmd)
3546
3547
    def get_scanner(self, scanner_id: str) -> Any:
3548
        """Request a single scanner
@@ 3712-3741 (lines=30) @@
3709
3710
        return self._send_xml_command(cmd)
3711
3712
    def get_tags(
3713
        self,
3714
        *,
3715
        filter: Optional[str] = None,
3716
        filter_id: Optional[str] = None,
3717
        trash: Optional[bool] = None,
3718
        names_only: Optional[bool] = None,
3719
    ) -> Any:
3720
        """Request a list of tags
3721
3722
        Arguments:
3723
            filter: Filter term to use for the query
3724
            filter_id: UUID of an existing filter to use for the query
3725
            trash: Whether to get tags from the trashcan instead
3726
            names_only: Whether to get only distinct tag names
3727
3728
        Returns:
3729
            The response. See :py:meth:`send_command` for details.
3730
        """
3731
        cmd = XmlCommand("get_tags")
3732
3733
        add_filter(cmd, filter, filter_id)
3734
3735
        if trash is not None:
3736
            cmd.set_attribute("trash", to_bool(trash))
3737
3738
        if names_only is not None:
3739
            cmd.set_attribute("names_only", to_bool(names_only))
3740
3741
        return self._send_xml_command(cmd)
3742
3743
    def get_tag(self, tag_id: str) -> Any:
3744
        """Request a single tag
@@ 3569-3598 (lines=30) @@
3566
        cmd.set_attribute("details", "1")
3567
        return self._send_xml_command(cmd)
3568
3569
    def get_schedules(
3570
        self,
3571
        *,
3572
        filter: Optional[str] = None,
3573
        filter_id: Optional[str] = None,
3574
        trash: Optional[bool] = None,
3575
        tasks: Optional[bool] = None,
3576
    ) -> Any:
3577
        """Request a list of schedules
3578
3579
        Arguments:
3580
            filter: Filter term to use for the query
3581
            filter_id: UUID of an existing filter to use for the query
3582
            trash: Whether to get the trashcan schedules instead
3583
            tasks: Whether to include tasks using the schedules
3584
3585
        Returns:
3586
            The response. See :py:meth:`send_command` for details.
3587
        """
3588
        cmd = XmlCommand("get_schedules")
3589
3590
        add_filter(cmd, filter, filter_id)
3591
3592
        if trash is not None:
3593
            cmd.set_attribute("trash", to_bool(trash))
3594
3595
        if tasks is not None:
3596
            cmd.set_attribute("tasks", to_bool(tasks))
3597
3598
        return self._send_xml_command(cmd)
3599
3600
    def get_schedule(
3601
        self, schedule_id: str, *, tasks: Optional[bool] = None
@@ 3193-3222 (lines=30) @@
3190
        """
3191
        return self._send_xml_command(XmlCommand("get_feeds"))
3192
3193
    def get_filters(
3194
        self,
3195
        *,
3196
        filter: Optional[str] = None,
3197
        filter_id: Optional[str] = None,
3198
        trash: Optional[bool] = None,
3199
        alerts: Optional[bool] = None,
3200
    ) -> Any:
3201
        """Request a list of filters
3202
3203
        Arguments:
3204
            filter: Filter term to use for the query
3205
            filter_id: UUID of an existing filter to use for the query
3206
            trash: Whether to get the trashcan filters instead
3207
            alerts: Whether to include list of alerts that use the filter.
3208
3209
        Returns:
3210
            The response. See :py:meth:`send_command` for details.
3211
        """
3212
        cmd = XmlCommand("get_filters")
3213
3214
        add_filter(cmd, filter, filter_id)
3215
3216
        if trash is not None:
3217
            cmd.set_attribute("trash", to_bool(trash))
3218
3219
        if alerts is not None:
3220
            cmd.set_attribute("alerts", to_bool(alerts))
3221
3222
        return self._send_xml_command(cmd)
3223
3224
    def get_filter(
3225
        self, filter_id: str, *, alerts: Optional[bool] = None

gvm/protocols/gmpv208/entities/targets.py 1 location

@@ 254-283 (lines=30) @@
251
252
        return self._send_xml_command(cmd)
253
254
    def get_targets(
255
        self,
256
        *,
257
        filter: Optional[str] = None,
258
        filter_id: Optional[str] = None,
259
        trash: Optional[bool] = None,
260
        tasks: Optional[bool] = None,
261
    ) -> Any:
262
        """Request a list of targets
263
264
        Arguments:
265
            filter: Filter term to use for the query
266
            filter_id: UUID of an existing filter to use for the query
267
            trash: Whether to get the trashcan targets instead
268
            tasks: Whether to include list of tasks that use the target
269
270
        Returns:
271
            The response. See :py:meth:`send_command` for details.
272
        """
273
        cmd = XmlCommand("get_targets")
274
275
        add_filter(cmd, filter, filter_id)
276
277
        if trash is not None:
278
            cmd.set_attribute("trash", to_bool(trash))
279
280
        if tasks is not None:
281
            cmd.set_attribute("tasks", to_bool(tasks))
282
283
        return self._send_xml_command(cmd)
284
285
    def modify_target(
286
        self,

gvm/protocols/gmpv208/entities/alerts.py 1 location

@@ 360-388 (lines=29) @@
357
358
        return self._send_xml_command(cmd)
359
360
    def get_alerts(
361
        self,
362
        *,
363
        filter: Optional[str] = None,
364
        filter_id: Optional[str] = None,
365
        trash: Optional[bool] = None,
366
        tasks: Optional[bool] = None,
367
    ) -> Any:
368
        """Request a list of alerts
369
370
        Arguments:
371
            filter: Filter term to use for the query
372
            filter_id: UUID of an existing filter to use for the query
373
            trash: True to request the alerts in the trashcan
374
            tasks: Whether to include the tasks using the alerts
375
        Returns:
376
            The response. See :py:meth:`send_command` for details.
377
        """
378
        cmd = XmlCommand("get_alerts")
379
380
        add_filter(cmd, filter, filter_id)
381
382
        if trash is not None:
383
            cmd.set_attribute("trash", to_bool(trash))
384
385
        if tasks is not None:
386
            cmd.set_attribute("tasks", to_bool(tasks))
387
388
        return self._send_xml_command(cmd)
389
390
    def get_alert(self, alert_id: str, *, tasks: Optional[bool] = None) -> Any:
391
        """Request a single alert