Code Duplication    Length = 66-66 lines in 2 locations

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

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

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