def put()

in lemur/certificates/views.py [0:0]


    def put(self, certificate_id, data=None):
        """
        .. http:put:: /certificates/1/revoke

           Revoke a certificate

           **Example request**:

           .. sourcecode:: http

              POST /certificates/1/revoke HTTP/1.1
              Host: example.com
              Accept: application/json, text/javascript

              {
                "crlReason": "affiliationChanged",
                "comments": "Additional details if any"
              }

           **Example response**:

           .. sourcecode:: http

              HTTP/1.1 200 OK
              Vary: Accept
              Content-Type: text/javascript

              {
                "id": 1
              }

           :reqheader Authorization: OAuth token to authenticate
           :statuscode 200: no error
           :statuscode 403: unauthenticated or cert attached to LB
           :statuscode 400: encountered error, more details in error message

        """
        cert = service.get(certificate_id)

        if not cert:
            return dict(message="Cannot find specified certificate"), 404

        # allow creators
        if g.current_user != cert.user:
            owner_role = role_service.get_by_name(cert.owner)
            permission = CertificatePermission(owner_role, [x.name for x in cert.roles])

            if not permission.can():
                return (
                    dict(message="You are not authorized to revoke this certificate."),
                    403,
                )

        if not cert.external_id:
            return dict(message="Cannot revoke certificate. No external id found."), 400

        if cert.endpoints:
            for endpoint in cert.endpoints:
                if service.is_attached_to_endpoint(cert.name, endpoint.name):
                    return (
                        dict(
                            message="Cannot revoke certificate. Endpoints are deployed with the given certificate."
                        ),
                        403,
                    )

        try:
            error_message = service.revoke(cert, data)
            log_service.create(g.current_user, "revoke_cert", certificate=cert)

            if error_message:
                return dict(message=f"Certificate (id:{cert.id}) is revoked - {error_message}"), 400
            return dict(id=cert.id)
        except NotImplementedError as ne:
            return dict(message="Revoke is not implemented for issuer of this certificate"), 400
        except Exception as e:
            sentry.captureException()
            return dict(message=f"Failed to revoke: {str(e)}"), 400