| @@ 302-339 (lines=38) @@ | ||
| 299 | cmd.set_attribute("include_certificate_data", "1") |
|
| 300 | return self._send_xml_command(cmd) |
|
| 301 | ||
| 302 | def modify_tls_certificate( |
|
| 303 | self, |
|
| 304 | tls_certificate_id: str, |
|
| 305 | *, |
|
| 306 | name: Optional[str] = None, |
|
| 307 | comment: Optional[str] = None, |
|
| 308 | trust: Optional[bool] = None |
|
| 309 | ) -> Any: |
|
| 310 | """Modifies an existing TLS certificate. |
|
| 311 | ||
| 312 | Arguments: |
|
| 313 | tls_certificate_id: UUID of the TLS certificate to be modified. |
|
| 314 | name: Name of the TLS certificate, defaulting to the MD5 fingerprint |
|
| 315 | comment: Comment for the TLS certificate. |
|
| 316 | trust: Whether the certificate is trusted. |
|
| 317 | ||
| 318 | Returns: |
|
| 319 | The response. See :py:meth:`send_command` for details. |
|
| 320 | """ |
|
| 321 | if not tls_certificate_id: |
|
| 322 | raise RequiredArgument( |
|
| 323 | function=self.modify_tls_certificate.__name__, |
|
| 324 | argument='tls_certificate_id', |
|
| 325 | ) |
|
| 326 | ||
| 327 | cmd = XmlCommand("modify_tls_certificate") |
|
| 328 | cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) |
|
| 329 | ||
| 330 | if comment: |
|
| 331 | cmd.add_element("comment", comment) |
|
| 332 | ||
| 333 | if name: |
|
| 334 | cmd.add_element("name", name) |
|
| 335 | ||
| 336 | if trust: |
|
| 337 | cmd.add_element("trust", _to_bool(trust)) |
|
| 338 | ||
| 339 | return self._send_xml_command(cmd) |
|
| 340 | ||
| 341 | def clone_tls_certificate(self, tls_certificate_id: str) -> Any: |
|
| 342 | """Modifies an existing TLS certificate. |
|
| @@ 207-248 (lines=42) @@ | ||
| 204 | preferences=preferences, |
|
| 205 | ) |
|
| 206 | ||
| 207 | def create_tls_certificate( |
|
| 208 | self, |
|
| 209 | name: str, |
|
| 210 | certificate: str, |
|
| 211 | *, |
|
| 212 | comment: Optional[str] = None, |
|
| 213 | trust: Optional[bool] = None |
|
| 214 | ) -> Any: |
|
| 215 | """Create a new TLS certificate |
|
| 216 | ||
| 217 | Arguments: |
|
| 218 | name: Name of the TLS certificate, defaulting to the MD5 |
|
| 219 | fingerprint. |
|
| 220 | certificate: The Base64 encoded certificate data (x.509 DER or PEM). |
|
| 221 | comment: Comment for the TLS certificate. |
|
| 222 | trust: Whether the certificate is trusted. |
|
| 223 | ||
| 224 | Returns: |
|
| 225 | The response. See :py:meth:`send_command` for details. |
|
| 226 | """ |
|
| 227 | if not name: |
|
| 228 | raise RequiredArgument( |
|
| 229 | function=self.create_tls_certificate.__name__, argument='name' |
|
| 230 | ) |
|
| 231 | if not certificate: |
|
| 232 | raise RequiredArgument( |
|
| 233 | function=self.create_tls_certificate.__name__, |
|
| 234 | argument='certificate', |
|
| 235 | ) |
|
| 236 | ||
| 237 | cmd = XmlCommand("create_tls_certificate") |
|
| 238 | ||
| 239 | if comment: |
|
| 240 | cmd.add_element("comment", comment) |
|
| 241 | ||
| 242 | cmd.add_element("name", name) |
|
| 243 | cmd.add_element("certificate", certificate) |
|
| 244 | ||
| 245 | if trust: |
|
| 246 | cmd.add_element("trust", _to_bool(trust)) |
|
| 247 | ||
| 248 | return self._send_xml_command(cmd) |
|
| 249 | ||
| 250 | def get_tls_certificates( |
|
| 251 | self, |
|