Code Duplication    Length = 29-31 lines in 6 locations

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

gvm/protocols/gmpv208/gmpv208.py 4 locations

@@ 2586-2616 (lines=31) @@
2583
        cmd.set_attribute("role_id", role_id)
2584
        return self._send_xml_command(cmd)
2585
2586
    def get_scanners(
2587
        self,
2588
        *,
2589
        filter: Optional[str] = None,
2590
        filter_id: Optional[str] = None,
2591
        trash: Optional[bool] = None,
2592
        details: Optional[bool] = None,
2593
    ) -> Any:
2594
        """Request a list of scanners
2595
2596
        Arguments:
2597
            filter: Filter term to use for the query
2598
            filter_id: UUID of an existing filter to use for the query
2599
            trash: Whether to get the trashcan scanners instead
2600
            details:  Whether to include extra details like tasks using this
2601
                scanner
2602
2603
        Returns:
2604
            The response. See :py:meth:`send_command` for details.
2605
        """
2606
        cmd = XmlCommand("get_scanners")
2607
2608
        add_filter(cmd, filter, filter_id)
2609
2610
        if trash is not None:
2611
            cmd.set_attribute("trash", to_bool(trash))
2612
2613
        if details is not None:
2614
            cmd.set_attribute("details", to_bool(details))
2615
2616
        return self._send_xml_command(cmd)
2617
2618
    def get_scanner(self, scanner_id: str) -> Any:
2619
        """Request a single scanner
@@ 2783-2812 (lines=30) @@
2780
2781
        return self._send_xml_command(cmd)
2782
2783
    def get_tags(
2784
        self,
2785
        *,
2786
        filter: Optional[str] = None,
2787
        filter_id: Optional[str] = None,
2788
        trash: Optional[bool] = None,
2789
        names_only: Optional[bool] = None,
2790
    ) -> Any:
2791
        """Request a list of tags
2792
2793
        Arguments:
2794
            filter: Filter term to use for the query
2795
            filter_id: UUID of an existing filter to use for the query
2796
            trash: Whether to get tags from the trashcan instead
2797
            names_only: Whether to get only distinct tag names
2798
2799
        Returns:
2800
            The response. See :py:meth:`send_command` for details.
2801
        """
2802
        cmd = XmlCommand("get_tags")
2803
2804
        add_filter(cmd, filter, filter_id)
2805
2806
        if trash is not None:
2807
            cmd.set_attribute("trash", to_bool(trash))
2808
2809
        if names_only is not None:
2810
            cmd.set_attribute("names_only", to_bool(names_only))
2811
2812
        return self._send_xml_command(cmd)
2813
2814
    def get_tag(self, tag_id: str) -> Any:
2815
        """Request a single tag
@@ 2640-2669 (lines=30) @@
2637
        cmd.set_attribute("details", "1")
2638
        return self._send_xml_command(cmd)
2639
2640
    def get_schedules(
2641
        self,
2642
        *,
2643
        filter: Optional[str] = None,
2644
        filter_id: Optional[str] = None,
2645
        trash: Optional[bool] = None,
2646
        tasks: Optional[bool] = None,
2647
    ) -> Any:
2648
        """Request a list of schedules
2649
2650
        Arguments:
2651
            filter: Filter term to use for the query
2652
            filter_id: UUID of an existing filter to use for the query
2653
            trash: Whether to get the trashcan schedules instead
2654
            tasks: Whether to include tasks using the schedules
2655
2656
        Returns:
2657
            The response. See :py:meth:`send_command` for details.
2658
        """
2659
        cmd = XmlCommand("get_schedules")
2660
2661
        add_filter(cmd, filter, filter_id)
2662
2663
        if trash is not None:
2664
            cmd.set_attribute("trash", to_bool(trash))
2665
2666
        if tasks is not None:
2667
            cmd.set_attribute("tasks", to_bool(tasks))
2668
2669
        return self._send_xml_command(cmd)
2670
2671
    def get_schedule(
2672
        self, schedule_id: str, *, tasks: Optional[bool] = None
@@ 2264-2293 (lines=30) @@
2261
        """
2262
        return self._send_xml_command(XmlCommand("get_feeds"))
2263
2264
    def get_filters(
2265
        self,
2266
        *,
2267
        filter: Optional[str] = None,
2268
        filter_id: Optional[str] = None,
2269
        trash: Optional[bool] = None,
2270
        alerts: Optional[bool] = None,
2271
    ) -> Any:
2272
        """Request a list of filters
2273
2274
        Arguments:
2275
            filter: Filter term to use for the query
2276
            filter_id: UUID of an existing filter to use for the query
2277
            trash: Whether to get the trashcan filters instead
2278
            alerts: Whether to include list of alerts that use the filter.
2279
2280
        Returns:
2281
            The response. See :py:meth:`send_command` for details.
2282
        """
2283
        cmd = XmlCommand("get_filters")
2284
2285
        add_filter(cmd, filter, filter_id)
2286
2287
        if trash is not None:
2288
            cmd.set_attribute("trash", to_bool(trash))
2289
2290
        if alerts is not None:
2291
            cmd.set_attribute("alerts", to_bool(alerts))
2292
2293
        return self._send_xml_command(cmd)
2294
2295
    def get_filter(
2296
        self, filter_id: str, *, alerts: Optional[bool] = None