@@ -85,6 +85,7 @@ def __init__(self):
8585 CERTIFICATE_STATUS = CERTIFICATE_REQUESTS + "/{}"
8686 CERTIFICATE_RETRIEVE = API_BASE_PATH + "certificates/{}/contents"
8787 CERTIFICATE_SEARCH = API_BASE_PATH + "certificatesearch"
88+ CERTIFICATE_RETIRE = API_BASE_PATH + "certificates/retirement"
8889 APPLICATIONS = API_BASE_PATH + "applications"
8990 APP_BY_ID = APPLICATIONS + "/{}"
9091 CERTIFICATE_TEMPLATE_BY_ID = APP_BY_ID + "/certificateissuingtemplates/{}"
@@ -477,6 +478,39 @@ def revoke_cert(self, request):
477478 # not supported in Venafi Cloud
478479 raise NotImplementedError
479480
481+ def retire_cert (self , request ):
482+ cert_id = None
483+ if not request .id and not request .thumbprint :
484+ log .error ("prev_cert_id or thumbprint or manage_id must be specified for renewing certificate" )
485+ raise ClientBadData
486+
487+ if request .thumbprint :
488+ response = self .search_by_thumbprint (request .thumbprint )
489+ cert_id = response .id
490+
491+ if request .id :
492+ cert_id = request .id
493+
494+ retire_data = {
495+ 'certificateIds' : [
496+ cert_id
497+ ]
498+ }
499+
500+ status , data = self ._post (URLS .CERTIFICATE_RETIRE , retire_data )
501+ if status == HTTPStatus .OK :
502+ if len (data ) == 0 :
503+ log .error (f"certificate retirement was not successful for { cert_id } " )
504+ raise VenafiError
505+ else :
506+ return True
507+ elif status == HTTPStatus .BAD_REQUEST or status == HTTPStatus .PRECONDITION_FAILED :
508+ log .error ("bad request for certificate retirement" )
509+ raise ClientBadData
510+ else :
511+ log .error ("unexpected status returned" )
512+ raise ServerUnexptedBehavior
513+
480514 def renew_cert (self , request , reuse_key = False ):
481515 cert_request_id = None
482516 if not request .id and not request .thumbprint :
0 commit comments