Code Duplication    Length = 66-66 lines in 2 locations

gvm/protocols/gmpv214/entities/scanners.py 1 location

@@ 157-222 (lines=66) @@
154
155
        return self._send_xml_command(cmd)
156
157
    def modify_scanner(
158
        self,
159
        scanner_id: str,
160
        *,
161
        scanner_type: Optional[ScannerType] = None,
162
        host: Optional[str] = None,
163
        port: Optional[int] = None,
164
        comment: Optional[str] = None,
165
        name: Optional[str] = None,
166
        ca_pub: Optional[str] = None,
167
        credential_id: Optional[str] = None,
168
    ) -> Any:
169
        """Modifies an existing scanner.
170
171
        Arguments:
172
            scanner_id: UUID of scanner to modify.
173
            scanner_type: New type of the Scanner.
174
            host: Host of the scanner.
175
            port: Port of the scanner.
176
            comment: Comment on scanner.
177
            name: Name of scanner.
178
            ca_pub: Certificate of CA to verify scanner's certificate.
179
            credential_id: UUID of the client certificate credential for the
180
                Scanner.
181
182
        Returns:
183
            The response. See :py:meth:`send_command` for details.
184
        """
185
        if not scanner_id:
186
            raise RequiredArgument(
187
                function=self.modify_scanner.__name__,
188
                argument='scanner_id argument',
189
            )
190
191
        cmd = XmlCommand("modify_scanner")
192
        cmd.set_attribute("scanner_id", scanner_id)
193
194
        if scanner_type is not None:
195
            if not isinstance(scanner_type, ScannerType):
196
                raise InvalidArgumentType(
197
                    function=self.modify_scanner.__name__,
198
                    argument='scanner_type',
199
                    arg_type=ScannerType.__name__,
200
                )
201
202
            cmd.add_element("type", scanner_type.value)
203
204
        if host:
205
            cmd.add_element("host", host)
206
207
        if port:
208
            cmd.add_element("port", str(port))
209
210
        if comment:
211
            cmd.add_element("comment", comment)
212
213
        if name:
214
            cmd.add_element("name", name)
215
216
        if ca_pub:
217
            cmd.add_element("ca_pub", ca_pub)
218
219
        if credential_id:
220
            cmd.add_element("credential", attrs={"id": str(credential_id)})
221
222
        return self._send_xml_command(cmd)
223

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

@@ 251-316 (lines=66) @@
248
        cmd.set_attribute("details", "1")
249
        return self._send_xml_command(cmd)
250
251
    def modify_scanner(
252
        self,
253
        scanner_id: str,
254
        *,
255
        scanner_type: Optional[ScannerType] = None,
256
        host: Optional[str] = None,
257
        port: Optional[int] = None,
258
        comment: Optional[str] = None,
259
        name: Optional[str] = None,
260
        ca_pub: Optional[str] = None,
261
        credential_id: Optional[str] = None,
262
    ) -> Any:
263
        """Modifies an existing scanner.
264
265
        Arguments:
266
            scanner_id: UUID of scanner to modify.
267
            scanner_type: New type of the Scanner.
268
            host: Host of the scanner.
269
            port: Port of the scanner.
270
            comment: Comment on scanner.
271
            name: Name of scanner.
272
            ca_pub: Certificate of CA to verify scanner's certificate.
273
            credential_id: UUID of the client certificate credential for the
274
                Scanner.
275
276
        Returns:
277
            The response. See :py:meth:`send_command` for details.
278
        """
279
        if not scanner_id:
280
            raise RequiredArgument(
281
                function=self.modify_scanner.__name__,
282
                argument='scanner_id argument',
283
            )
284
285
        cmd = XmlCommand("modify_scanner")
286
        cmd.set_attribute("scanner_id", scanner_id)
287
288
        if scanner_type is not None:
289
            if not isinstance(scanner_type, ScannerType):
290
                raise InvalidArgumentType(
291
                    function=self.modify_scanner.__name__,
292
                    argument='scanner_type',
293
                    arg_type=ScannerType.__name__,
294
                )
295
296
            cmd.add_element("type", scanner_type.value)
297
298
        if host:
299
            cmd.add_element("host", host)
300
301
        if port:
302
            cmd.add_element("port", str(port))
303
304
        if comment:
305
            cmd.add_element("comment", comment)
306
307
        if name:
308
            cmd.add_element("name", name)
309
310
        if ca_pub:
311
            cmd.add_element("ca_pub", ca_pub)
312
313
        if credential_id:
314
            cmd.add_element("credential", attrs={"id": str(credential_id)})
315
316
        return self._send_xml_command(cmd)
317
318
    def verify_scanner(self, scanner_id: str) -> Any:
319
        """Verify an existing scanner