Skip to content

Commit

Permalink
add function to get credential revocation status
Browse files Browse the repository at this point in the history
  • Loading branch information
cl0ete committed Feb 1, 2024
1 parent c590d65 commit ebbfc69
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions app/services/revocation_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,64 @@ async def clear_pending_revocations(
bound_logger.warning("The result of clearing pending revocations is: '{}'.", result)
bound_logger.info("Successfully cleared pending revocations.")
return result

async def get_credential_revocation_record(
controller: AcaPyClient,
credential_exchange_id: str,
credential_revocation_id: str,
revocation_registry_id: str,
) -> IssuerCredRevRecord:
"""
Get the revocation status for a credential
Args:
controller (AcaPyClient): aca-py client
credential_exchange_id (str): The credential exchange ID.
credential_revocation_id (str): The credential revocation ID.
revocation_registry_id (str): The revocation registry ID.
Raises:
Exception: When failed to get revocation status.
"""
bound_logger = logger.bind(
body={
"credential_exchange_id": credential_exchange_id,
"credential_revocation_id": credential_revocation_id,
"revocation_registry_id": revocation_registry_id,
}
)
bound_logger.info("Fetching the revocation status for a credential exchange")

try:
result = await controller.revocation.get_revocation_status(
cred_ex_id=credential_exchange_id if credential_exchange_id else None,
cred_rev_id=credential_revocation_id if credential_revocation_id else None,
rev_reg_id=revocation_registry_id if revocation_registry_id else None,
)
except ApiException as e:
bound_logger.exception(
"An ApiException was caught while getting revocation status. The error message is: '{}'.",
e.reason,
)
raise CloudApiException(
f"Failed to get revocation status: {e.reason}.", e.status
) from e

if not isinstance(result, CredRevRecordResult):
bound_logger.error(
"Unexpected type returned from get_revocation_status: `{}`.", result
)
raise CloudApiException(
f"Error retrieving revocation status for credential exchange ID `{credential_exchange_id}`."
)
else:
result = result.result

bound_logger.info("Successfully retrieved revocation status.")
return result


async def endorser_revoke():
listener = SseListener(topic="endorsements", wallet_id="admin")
try:
Expand Down

0 comments on commit ebbfc69

Please sign in to comment.