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/gmpv208.py 4 locations

@@ 3073-3103 (lines=31) @@
3070
        cmd.set_attribute("role_id", role_id)
3071
        return self._send_xml_command(cmd)
3072
3073
    def get_scanners(
3074
        self,
3075
        *,
3076
        filter: Optional[str] = None,
3077
        filter_id: Optional[str] = None,
3078
        trash: Optional[bool] = None,
3079
        details: Optional[bool] = None,
3080
    ) -> Any:
3081
        """Request a list of scanners
3082
3083
        Arguments:
3084
            filter: Filter term to use for the query
3085
            filter_id: UUID of an existing filter to use for the query
3086
            trash: Whether to get the trashcan scanners instead
3087
            details:  Whether to include extra details like tasks using this
3088
                scanner
3089
3090
        Returns:
3091
            The response. See :py:meth:`send_command` for details.
3092
        """
3093
        cmd = XmlCommand("get_scanners")
3094
3095
        add_filter(cmd, filter, filter_id)
3096
3097
        if trash is not None:
3098
            cmd.set_attribute("trash", to_bool(trash))
3099
3100
        if details is not None:
3101
            cmd.set_attribute("details", to_bool(details))
3102
3103
        return self._send_xml_command(cmd)
3104
3105
    def get_scanner(self, scanner_id: str) -> Any:
3106
        """Request a single scanner
@@ 3270-3299 (lines=30) @@
3267
3268
        return self._send_xml_command(cmd)
3269
3270
    def get_tags(
3271
        self,
3272
        *,
3273
        filter: Optional[str] = None,
3274
        filter_id: Optional[str] = None,
3275
        trash: Optional[bool] = None,
3276
        names_only: Optional[bool] = None,
3277
    ) -> Any:
3278
        """Request a list of tags
3279
3280
        Arguments:
3281
            filter: Filter term to use for the query
3282
            filter_id: UUID of an existing filter to use for the query
3283
            trash: Whether to get tags from the trashcan instead
3284
            names_only: Whether to get only distinct tag names
3285
3286
        Returns:
3287
            The response. See :py:meth:`send_command` for details.
3288
        """
3289
        cmd = XmlCommand("get_tags")
3290
3291
        add_filter(cmd, filter, filter_id)
3292
3293
        if trash is not None:
3294
            cmd.set_attribute("trash", to_bool(trash))
3295
3296
        if names_only is not None:
3297
            cmd.set_attribute("names_only", to_bool(names_only))
3298
3299
        return self._send_xml_command(cmd)
3300
3301
    def get_tag(self, tag_id: str) -> Any:
3302
        """Request a single tag
@@ 3127-3156 (lines=30) @@
3124
        cmd.set_attribute("details", "1")
3125
        return self._send_xml_command(cmd)
3126
3127
    def get_schedules(
3128
        self,
3129
        *,
3130
        filter: Optional[str] = None,
3131
        filter_id: Optional[str] = None,
3132
        trash: Optional[bool] = None,
3133
        tasks: Optional[bool] = None,
3134
    ) -> Any:
3135
        """Request a list of schedules
3136
3137
        Arguments:
3138
            filter: Filter term to use for the query
3139
            filter_id: UUID of an existing filter to use for the query
3140
            trash: Whether to get the trashcan schedules instead
3141
            tasks: Whether to include tasks using the schedules
3142
3143
        Returns:
3144
            The response. See :py:meth:`send_command` for details.
3145
        """
3146
        cmd = XmlCommand("get_schedules")
3147
3148
        add_filter(cmd, filter, filter_id)
3149
3150
        if trash is not None:
3151
            cmd.set_attribute("trash", to_bool(trash))
3152
3153
        if tasks is not None:
3154
            cmd.set_attribute("tasks", to_bool(tasks))
3155
3156
        return self._send_xml_command(cmd)
3157
3158
    def get_schedule(
3159
        self, schedule_id: str, *, tasks: Optional[bool] = None
@@ 2751-2780 (lines=30) @@
2748
        """
2749
        return self._send_xml_command(XmlCommand("get_feeds"))
2750
2751
    def get_filters(
2752
        self,
2753
        *,
2754
        filter: Optional[str] = None,
2755
        filter_id: Optional[str] = None,
2756
        trash: Optional[bool] = None,
2757
        alerts: Optional[bool] = None,
2758
    ) -> Any:
2759
        """Request a list of filters
2760
2761
        Arguments:
2762
            filter: Filter term to use for the query
2763
            filter_id: UUID of an existing filter to use for the query
2764
            trash: Whether to get the trashcan filters instead
2765
            alerts: Whether to include list of alerts that use the filter.
2766
2767
        Returns:
2768
            The response. See :py:meth:`send_command` for details.
2769
        """
2770
        cmd = XmlCommand("get_filters")
2771
2772
        add_filter(cmd, filter, filter_id)
2773
2774
        if trash is not None:
2775
            cmd.set_attribute("trash", to_bool(trash))
2776
2777
        if alerts is not None:
2778
            cmd.set_attribute("alerts", to_bool(alerts))
2779
2780
        return self._send_xml_command(cmd)
2781
2782
    def get_filter(
2783
        self, filter_id: str, *, alerts: Optional[bool] = None

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