Code Duplication    Length = 42-42 lines in 2 locations

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

@@ 382-423 (lines=42) @@
379
380
        return self._send_xml_command(cmd)
381
382
    def modify_scan_config_set_nvt_selection(
383
        self, config_id: str, family: str, nvt_oids: List[str]
384
    ) -> Any:
385
        """Modifies the selected nvts of an existing scan config
386
387
        The manager updates the given family in the config to include only the
388
        given NVTs.
389
390
        Arguments:
391
            config_id: UUID of scan config to modify.
392
            family: Name of the NVT family to include NVTs from
393
            nvt_oids: List of NVTs to select for the family.
394
        """
395
        if not config_id:
396
            raise RequiredArgument(
397
                function=self.modify_scan_config_set_nvt_selection.__name__,
398
                argument='config_id',
399
            )
400
401
        if not family:
402
            raise RequiredArgument(
403
                function=self.modify_scan_config_set_nvt_selection.__name__,
404
                argument='family argument',
405
            )
406
407
        if not is_list_like(nvt_oids):
408
            raise InvalidArgumentType(
409
                function=self.modify_scan_config_set_nvt_selection.__name__,
410
                argument='nvt_oids',
411
                arg_type='list',
412
            )
413
414
        cmd = XmlCommand("modify_config")
415
        cmd.set_attribute("config_id", str(config_id))
416
417
        _xmlnvtsel = cmd.add_element("nvt_selection")
418
        _xmlnvtsel.add_element("family", family)
419
420
        for nvt in nvt_oids:
421
            _xmlnvtsel.add_element("nvt", attrs={"oid": nvt})
422
423
        return self._send_xml_command(cmd)
424
425
    def modify_scan_config_set_family_selection(
426
        self,

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

@@ 315-356 (lines=42) @@
312
313
        return self._send_xml_command(cmd)
314
315
    def modify_policy_set_nvt_selection(
316
        self, policy_id: str, family: str, nvt_oids: List[str]
317
    ) -> Any:
318
        """Modifies the selected nvts of an existing policy
319
320
        The manager updates the given family in the policy to include only the
321
        given NVTs.
322
323
        Arguments:
324
            policy_id: UUID of policy to modify.
325
            family: Name of the NVT family to include NVTs from
326
            nvt_oids: List of NVTs to select for the family.
327
        """
328
        if not policy_id:
329
            raise RequiredArgument(
330
                function=self.modify_policy_set_nvt_selection.__name__,
331
                argument='policy_id',
332
            )
333
334
        if not family:
335
            raise RequiredArgument(
336
                function=self.modify_policy_set_nvt_selection.__name__,
337
                argument='family argument',
338
            )
339
340
        if not is_list_like(nvt_oids):
341
            raise InvalidArgumentType(
342
                function=self.modify_policy_set_nvt_selection.__name__,
343
                argument='nvt_oids',
344
                arg_type='list',
345
            )
346
347
        cmd = XmlCommand("modify_config")
348
        cmd.set_attribute("config_id", str(policy_id))
349
350
        _xmlnvtsel = cmd.add_element("nvt_selection")
351
        _xmlnvtsel.add_element("family", family)
352
353
        for nvt in nvt_oids:
354
            _xmlnvtsel.add_element("nvt", attrs={"oid": nvt})
355
356
        return self._send_xml_command(cmd)
357
358
    def modify_policy_set_family_selection(
359
        self,