Skip to content

Commit

Permalink
add function to validate rev_reg_id
Browse files Browse the repository at this point in the history
  • Loading branch information
cl0ete committed Feb 5, 2024
1 parent b523b16 commit ced638e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions app/services/revocation_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,50 @@ async def get_credential_definition_id_from_exchange_id(
"Successfully obtained cred definition id from the cred exchange id."
)
return credential_definition_id


async def validate_rev_reg_ids(
controller: AcaPyClient, request: dict
):
"""
Validate revocation registry ids
Args:
controller (AcaPyClient): aca-py client
request (dict): The request body.
Raises:
Exception: When the revocation registry ids are invalid.
"""
bound_logger = logger.bind(body=request)
bound_logger.info("Validating revocation registry ids")
rev_reg_id_list = list(request.keys())

if len(rev_reg_id_list) > 0:
try:
for key in rev_reg_id_list:
result_count = (
await controller.revocation.get_registry_issued_credentials_count(
rev_reg_id=key
)
)
bound_logger.debug(result_count)
except ApiException as e:

if e.status == 404:
bound_logger.info(
"The rev_reg_id does not exist '{}'.",
e.reason,
)
raise CloudApiException(
f"The rev_reg_id does not exist: {e.reason}.", e.status
) from e
else:
bound_logger.error(
"An ApiException was caught while validating rev_reg_id. The error message is: '{}'.",
e.reason,
)
raise CloudApiException(f"{e.reason}.", e.status) from e

bound_logger.info("Successfully validated revocation registry ids.")

0 comments on commit ced638e

Please sign in to comment.