From 85fde08821bae3286f11971f8772d7e46737ea24 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Tue, 21 May 2024 14:27:44 +0200 Subject: [PATCH 01/25] update wallet credentials docstrings --- app/routes/wallet/credentials.py | 219 ++++++++++++++++++++++++++----- 1 file changed, 188 insertions(+), 31 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 4bd785045..27ddfceec 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -21,14 +21,45 @@ router = APIRouter(prefix="/v1/wallet/credentials", tags=["wallet"]) -@router.get("", response_model=CredInfoList) +@router.get( + "", + response_model=CredInfoList, + summary="Fetch a list of credentials from the wallet", +) async def list_credentials( count: Optional[str] = None, start: Optional[str] = None, wql: Optional[str] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredInfoList: - """Fetch a list of credentials from the wallet.""" + """ + Fetch a list of credentials from the wallet. + --- + + The WQL or wallet query language parameter can be used to filter credentials returned from the wallet. + The WQL query is a string that can be used to filter records based on the attributes name and value of the record. + + The following string will look for the credential with the attribute `age` with value `21`: + + {"attr::age::value": "21"} + + See more on WQL queries [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html). + + Parameters: + --- + count: Optional[str] + The number of records to return. + start: Optional[str] + The number of records to skip before starting to return records. + wql: Optional[str] + A WQL query to filter records. + + Returns: + --- + CredInfoList + A list of credential records. + + """ logger.debug("GET request received: List credentials") async with client_from_auth(auth) as aries_controller: @@ -45,12 +76,29 @@ async def list_credentials( return results -@router.get("/{credential_id}", response_model=IndyCredInfo) +@router.get( + "/{referent}", response_model=IndyCredInfo, summary="Fetch a credential by ID" +) async def get_credential_record( - credential_id: str, + referent: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> IndyCredInfo: - """Fetch a specific credential by ID.""" + """ + Fetch a specific credential by referent. + --- + + The referent is the ID of the credential to fetch. + + Parameters: + --- + referent: str + The ID of the credential to fetch. + + Returns: + --- + IndyCredInfo + The credential record. + """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("GET request received: Fetch specific credential by ID") @@ -59,20 +107,35 @@ async def get_credential_record( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_record, - credential_id=credential_id, + credential_id=referent, ) bound_logger.debug("Successfully fetched credential.") return result -@router.delete("/{credential_id}", status_code=204) +@router.delete("/{referent}", status_code=204, summary="Delete a credential by ID") async def delete_credential( - credential_id: str, + referent: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: - """Remove a specific credential from the wallet by ID.""" - bound_logger = logger.bind(credential_id=credential_id) + """ + Remove a specific credential from the wallet by ID. + --- + + The referent is the ID of the credential to delete. + + Parameters: + --- + referent: str + The ID of the credential to delete. + + Returns: + --- + status_code: 204 + + """ + bound_logger = logger.bind(referent=referent) bound_logger.debug("DELETE request received: Remove specific credential by ID") async with client_from_auth(auth) as aries_controller: @@ -80,19 +143,37 @@ async def delete_credential( await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.delete_record, - credential_id=credential_id, + credential_id=referent, ) bound_logger.debug("Successfully deleted credential.") -@router.get("/{credential_id}/mime-types", response_model=AttributeMimeTypesResult) +@router.get( + "/{referent}/mime-types", + response_model=AttributeMimeTypesResult, + summary="Retrieve attribute MIME types of a credential", +) async def get_credential_mime_types( - credential_id: str, + referent: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> AttributeMimeTypesResult: - """Retrieve attribute MIME types of a specific credential by ID.""" - bound_logger = logger.bind(credential_id=credential_id) + """ + Retrieve attribute MIME types of a specific credential by ID. + --- + + Parameters: + --- + referent: str + The ID of the credential to fetch attribute MIME types for. + + Returns: + --- + AttributeMimeTypesResult + The attribute MIME types of the credential. + + """ + bound_logger = logger.bind(referent=referent) bound_logger.debug( "GET request received: Retrieve attribute MIME types for a specific credential" ) @@ -102,22 +183,47 @@ async def get_credential_mime_types( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_credential_mime_types, - credential_id=credential_id, + credential_id=referent, ) bound_logger.debug("Successfully fetched attribute MIME types.") return result -@router.get("/{credential_id}/revocation-status", response_model=CredRevokedResult) +@router.get( + "/{referent}/revocation-status", + response_model=CredRevokedResult, + summary="Get revocation status of a credential", +) async def get_credential_revocation_status( - credential_id: str, + referent: str, from_: Optional[str] = None, to: Optional[str] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredRevokedResult: - """Query the revocation status of a specific credential by ID.""" - bound_logger = logger.bind(credential_id=credential_id) + """ + Query the revocation status of a specific credential by ID. + --- + + The status can be check on a specific time range by providing the `from_` and `to` parameters. + Pass the seconds, since Unix epoch, to the `from_` and `to` parameters to query the revocation status for a specific time range. + + Parameters: + --- + referent: str + The ID of the credential to query revocation status for. + from_: Optional[str] + The timestamp to start the query from. + to: Optional[str] + The timestamp to end the query at. + + Returns: + --- + CredRevokedResult + The revocation status of the credential. + + """ + bound_logger = logger.bind(referent=referent) bound_logger.debug( "GET request received: Query revocation status for a specific credential" ) @@ -127,7 +233,7 @@ async def get_credential_revocation_status( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_revocation_status, - credential_id=credential_id, + credential_id=referent, var_from=from_, to=to, ) @@ -136,7 +242,11 @@ async def get_credential_revocation_status( return result -@router.get("/w3c", response_model=VCRecordList) +@router.get( + "/w3c", + response_model=VCRecordList, + summary="Fetch a list of W3C credentials from the wallet", +) async def list_w3c_credentials( count: Optional[str] = None, start: Optional[str] = None, @@ -144,7 +254,26 @@ async def list_w3c_credentials( body: Optional[W3CCredentialsListRequest] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: - """Fetch a list of W3C credentials from the wallet.""" + """ + Fetch a list of W3C credentials from the wallet. + --- + + Parameters: + --- + count: Optional[str] + The number of records to return. + start: Optional[str] + The number of records to skip before starting to return records. + wql: Optional[str] + A WQL query to filter records. + body: Optional[W3CCredentialsListRequest] <-- TODO what is this? + A request body to filter records. + + Returns: + --- + VCRecordList + A list of W3C credential records. + """ logger.debug("GET request received: List W3C credentials") async with client_from_auth(auth) as aries_controller: @@ -162,12 +291,28 @@ async def list_w3c_credentials( return results -@router.get("/w3c/{credential_id}", response_model=VCRecord) +@router.get( + "/w3c/{referent}", response_model=VCRecord, summary="Fetch a W3C credential by ID" +) async def get_w3c_credential( - credential_id: str, + referent: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecord: - """Fetch a specific W3C credential by ID.""" + """ + Fetch a specific W3C credential by ID. + --- + + Parameters: + --- + referent: str + The ID of the W3C credential to fetch. + + Returns: + --- + VCRecord + The W3C credential. + + """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("GET request received: Fetch specific W3C credential by ID") @@ -176,19 +321,31 @@ async def get_w3c_credential( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_w3c_credential, - credential_id=credential_id, + credential_id=referent, ) bound_logger.debug("Successfully fetched W3C credential.") return result -@router.delete("/w3c/{credential_id}", status_code=204) +@router.delete("/w3c/{referent}", status_code=204, summary="Delete W3C credential") async def delete_w3c_credential( - credential_id: str, + referent: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: - """Remove a specific W3C credential from the wallet by ID.""" + """ + Remove a specific W3C credential from the wallet by ID. + --- + + Parameters: + --- + referent: str + The ID of the W3C credential to delete. + + Returns: + --- + status_code: 204 + """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("DELETE request received: Remove specific W3C credential by ID") @@ -197,7 +354,7 @@ async def delete_w3c_credential( await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.delete_w3c_credential, - credential_id=credential_id, + credential_id=referent, ) bound_logger.debug("Successfully deleted W3C credential.") From 211f525250127ca3371cd6bc3cf812ed0e931e84 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 22 May 2024 10:49:38 +0200 Subject: [PATCH 02/25] make endpoint POST has a body --- app/routes/wallet/credentials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 27ddfceec..fc430d62c 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -242,7 +242,7 @@ async def get_credential_revocation_status( return result -@router.get( +@router.post( "/w3c", response_model=VCRecordList, summary="Fetch a list of W3C credentials from the wallet", From 6a387ee8853d8a3dbf9db922748e2908e2ba38ca Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 22 May 2024 10:50:26 +0200 Subject: [PATCH 03/25] remove wql,count,start not used in agent --- app/routes/wallet/credentials.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index fc430d62c..576f03e2c 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -248,9 +248,6 @@ async def get_credential_revocation_status( summary="Fetch a list of W3C credentials from the wallet", ) async def list_w3c_credentials( - count: Optional[str] = None, - start: Optional[str] = None, - wql: Optional[str] = None, body: Optional[W3CCredentialsListRequest] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: @@ -281,9 +278,6 @@ async def list_w3c_credentials( results = await handle_acapy_call( logger=logger, acapy_call=aries_controller.credentials.get_w3c_credentials, - count=count, - start=start, - wql=wql, body=body, ) From fd145183d79827bc9b2e44bf88d97a1971466920 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 22 May 2024 10:51:20 +0200 Subject: [PATCH 04/25] rename to record_id as it is in the credential --- app/routes/wallet/credentials.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 576f03e2c..7eecd2586 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -286,10 +286,10 @@ async def list_w3c_credentials( @router.get( - "/w3c/{referent}", response_model=VCRecord, summary="Fetch a W3C credential by ID" + "/w3c/{record_id}", response_model=VCRecord, summary="Fetch a W3C credential by ID" ) async def get_w3c_credential( - referent: str, + record_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecord: """ @@ -298,7 +298,7 @@ async def get_w3c_credential( Parameters: --- - referent: str + record_id: str The ID of the W3C credential to fetch. Returns: @@ -307,7 +307,7 @@ async def get_w3c_credential( The W3C credential. """ - bound_logger = logger.bind(credential_id=credential_id) + bound_logger = logger.bind(record_id=record_id) bound_logger.debug("GET request received: Fetch specific W3C credential by ID") async with client_from_auth(auth) as aries_controller: @@ -315,16 +315,16 @@ async def get_w3c_credential( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_w3c_credential, - credential_id=referent, + credential_id=record_id, ) bound_logger.debug("Successfully fetched W3C credential.") return result -@router.delete("/w3c/{referent}", status_code=204, summary="Delete W3C credential") +@router.delete("/w3c/{record_id}", status_code=204, summary="Delete W3C credential") async def delete_w3c_credential( - referent: str, + record_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ @@ -333,14 +333,14 @@ async def delete_w3c_credential( Parameters: --- - referent: str + record_id: str The ID of the W3C credential to delete. Returns: --- status_code: 204 """ - bound_logger = logger.bind(credential_id=credential_id) + bound_logger = logger.bind(record_id=record_id) bound_logger.debug("DELETE request received: Remove specific W3C credential by ID") async with client_from_auth(auth) as aries_controller: @@ -348,7 +348,7 @@ async def delete_w3c_credential( await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.delete_w3c_credential, - credential_id=referent, + credential_id=record_id, ) bound_logger.debug("Successfully deleted W3C credential.") From 38c8dbc87d00edb256dda658838ac30f12cb3b59 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 22 May 2024 10:51:34 +0200 Subject: [PATCH 05/25] update docstrings --- app/routes/wallet/credentials.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 7eecd2586..c884894cf 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -255,16 +255,22 @@ async def list_w3c_credentials( Fetch a list of W3C credentials from the wallet. --- - Parameters: + The W3C credentials list request body can be used to filter credentials returned from the wallet. + All the fields in the request body are optional. If no fields are provided, all credentials will be returned. + + Request body: --- - count: Optional[str] - The number of records to return. - start: Optional[str] - The number of records to skip before starting to return records. - wql: Optional[str] - A WQL query to filter records. - body: Optional[W3CCredentialsListRequest] <-- TODO what is this? + body: Optional[W3CCredentialsListRequest] A request body to filter records. + contexts: List[str] + types: List[str] + schema_ids: List[str] + issuer_id: str + subject_ids: List[str] + given_id: str + proof_types: List[str] + tag_query: str + max_results: int Returns: --- From 41d37e13df2428add9ad2d2680e12c7e9b4edeca Mon Sep 17 00:00:00 2001 From: cl0ete Date: Thu, 23 May 2024 16:22:06 +0200 Subject: [PATCH 06/25] update docstrings and revert back to credential_id --- app/routes/wallet/credentials.py | 127 ++++++++++++++++++------------- 1 file changed, 76 insertions(+), 51 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index c884894cf..b76ad04b1 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -1,19 +1,23 @@ -from typing import Optional +from typing import List, Optional -from aries_cloudcontroller import ( +from aries_cloudcontroller import ( # CredInfoList,; VCRecordList, AttributeMimeTypesResult, - CredInfoList, CredRevokedResult, IndyCredInfo, VCRecord, - VCRecordList, W3CCredentialsListRequest, ) -from fastapi import APIRouter, Depends +from fastapi import APIRouter, Depends, Query from app.dependencies.acapy_clients import client_from_auth from app.dependencies.auth import AcaPyAuth, acapy_auth_from_header from app.exceptions import handle_acapy_call +from app.models.wallet import ( + CredInfoList, + ExtendedIndyCredInfo, + ExtendedVCRecord, + VCRecordList, +) from shared.log_config import get_logger logger = get_logger(__name__) @@ -77,12 +81,14 @@ async def list_credentials( @router.get( - "/{referent}", response_model=IndyCredInfo, summary="Fetch a credential by ID" + "/{credential_id}", + response_model=ExtendedIndyCredInfo, + summary="Fetch a credential by ID", ) async def get_credential_record( referent: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), -) -> IndyCredInfo: +) -> ExtendedIndyCredInfo: """ Fetch a specific credential by referent. --- @@ -114,20 +120,20 @@ async def get_credential_record( return result -@router.delete("/{referent}", status_code=204, summary="Delete a credential by ID") +@router.delete("/{credential_id}", status_code=204, summary="Delete a credential by ID") async def delete_credential( - referent: str, + credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ Remove a specific credential from the wallet by ID. --- - The referent is the ID of the credential to delete. + The credential_id is the ID of the credential to delete. Parameters: --- - referent: str + credential_id: str The ID of the credential to delete. Returns: @@ -135,7 +141,7 @@ async def delete_credential( status_code: 204 """ - bound_logger = logger.bind(referent=referent) + bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("DELETE request received: Remove specific credential by ID") async with client_from_auth(auth) as aries_controller: @@ -143,19 +149,19 @@ async def delete_credential( await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.delete_record, - credential_id=referent, + credential_id=credential_id, ) bound_logger.debug("Successfully deleted credential.") @router.get( - "/{referent}/mime-types", + "/{credential_id}/mime-types", response_model=AttributeMimeTypesResult, summary="Retrieve attribute MIME types of a credential", ) async def get_credential_mime_types( - referent: str, + credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> AttributeMimeTypesResult: """ @@ -164,7 +170,7 @@ async def get_credential_mime_types( Parameters: --- - referent: str + credential_id: str The ID of the credential to fetch attribute MIME types for. Returns: @@ -173,7 +179,7 @@ async def get_credential_mime_types( The attribute MIME types of the credential. """ - bound_logger = logger.bind(referent=referent) + bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug( "GET request received: Retrieve attribute MIME types for a specific credential" ) @@ -183,7 +189,7 @@ async def get_credential_mime_types( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_credential_mime_types, - credential_id=referent, + credential_id=credential_id, ) bound_logger.debug("Successfully fetched attribute MIME types.") @@ -191,12 +197,12 @@ async def get_credential_mime_types( @router.get( - "/{referent}/revocation-status", + "/{credential_id}/revocation-status", response_model=CredRevokedResult, summary="Get revocation status of a credential", ) async def get_credential_revocation_status( - referent: str, + credential_id: str, from_: Optional[str] = None, to: Optional[str] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), @@ -210,7 +216,7 @@ async def get_credential_revocation_status( Parameters: --- - referent: str + credential_id: str The ID of the credential to query revocation status for. from_: Optional[str] The timestamp to start the query from. @@ -223,7 +229,7 @@ async def get_credential_revocation_status( The revocation status of the credential. """ - bound_logger = logger.bind(referent=referent) + bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug( "GET request received: Query revocation status for a specific credential" ) @@ -233,7 +239,7 @@ async def get_credential_revocation_status( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_revocation_status, - credential_id=referent, + credential_id=credential_id, var_from=from_, to=to, ) @@ -242,35 +248,40 @@ async def get_credential_revocation_status( return result -@router.post( - "/w3c", +@router.get( + "/w3c/stuff", response_model=VCRecordList, summary="Fetch a list of W3C credentials from the wallet", ) async def list_w3c_credentials( - body: Optional[W3CCredentialsListRequest] = None, + contexts: Optional[List[str]] = Query(None), + types: Optional[List[str]] = Query(None), + schema_ids: Optional[List[str]] = Query(None), + subject_ids: Optional[List[str]] = Query(None), + proof_types: Optional[List[str]] = Query(None), + issuer_id: Optional[str] = Query(None), + given_id: Optional[str] = Query(None), + tag_query: Optional[str] = Query(None), + max_results: Optional[int] = Query(None), auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: """ Fetch a list of W3C credentials from the wallet. --- - The W3C credentials list request body can be used to filter credentials returned from the wallet. - All the fields in the request body are optional. If no fields are provided, all credentials will be returned. + The W3C credentials can be filtered by the parameters provided. - Request body: + Parameters: --- - body: Optional[W3CCredentialsListRequest] - A request body to filter records. - contexts: List[str] - types: List[str] - schema_ids: List[str] - issuer_id: str - subject_ids: List[str] - given_id: str - proof_types: List[str] - tag_query: str - max_results: int + contexts: Optional[List[str]] + types: Optional[List[str]] + schema_ids: Optional[List[str]] + issuer_id: Optional[str] + subject_ids: Optional[List[str]] + given_id: Optional[str] + proof_types: Optional[List[str]] + tag_query: Optional[str] + max_results: Optional[int] Returns: --- @@ -279,6 +290,18 @@ async def list_w3c_credentials( """ logger.debug("GET request received: List W3C credentials") + body = W3CCredentialsListRequest( + contexts=contexts, + types=types, + schema_ids=schema_ids, + issuer_id=issuer_id, + subject_ids=subject_ids, + given_id=given_id, + proof_types=proof_types, + tag_query=tag_query, + max_results=max_results, + ) + async with client_from_auth(auth) as aries_controller: logger.debug("Fetching W3C credentials") results = await handle_acapy_call( @@ -292,19 +315,21 @@ async def list_w3c_credentials( @router.get( - "/w3c/{record_id}", response_model=VCRecord, summary="Fetch a W3C credential by ID" + "/w3c/{credential_id}", + response_model=ExtendedVCRecord, + summary="Fetch a W3C credential by ID", ) async def get_w3c_credential( - record_id: str, + credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), -) -> VCRecord: +) -> ExtendedVCRecord: """ Fetch a specific W3C credential by ID. --- Parameters: --- - record_id: str + credential_id: str The ID of the W3C credential to fetch. Returns: @@ -313,7 +338,7 @@ async def get_w3c_credential( The W3C credential. """ - bound_logger = logger.bind(record_id=record_id) + bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("GET request received: Fetch specific W3C credential by ID") async with client_from_auth(auth) as aries_controller: @@ -321,16 +346,16 @@ async def get_w3c_credential( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_w3c_credential, - credential_id=record_id, + credential_id=credential_id, ) bound_logger.debug("Successfully fetched W3C credential.") return result -@router.delete("/w3c/{record_id}", status_code=204, summary="Delete W3C credential") +@router.delete("/w3c/{credential_id}", status_code=204, summary="Delete W3C credential") async def delete_w3c_credential( - record_id: str, + credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ @@ -339,14 +364,14 @@ async def delete_w3c_credential( Parameters: --- - record_id: str + credential_id: str The ID of the W3C credential to delete. Returns: --- status_code: 204 """ - bound_logger = logger.bind(record_id=record_id) + bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("DELETE request received: Remove specific W3C credential by ID") async with client_from_auth(auth) as aries_controller: @@ -354,7 +379,7 @@ async def delete_w3c_credential( await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.delete_w3c_credential, - credential_id=record_id, + credential_id=credential_id, ) bound_logger.debug("Successfully deleted W3C credential.") From 9b1d96f02ebf1bedcff47efb6a4321d3a0b4e47f Mon Sep 17 00:00:00 2001 From: cl0ete Date: Thu, 23 May 2024 16:22:47 +0200 Subject: [PATCH 07/25] extend models and add credential_id field --- app/models/wallet.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/models/wallet.py b/app/models/wallet.py index c5771e290..5663d16ff 100644 --- a/app/models/wallet.py +++ b/app/models/wallet.py @@ -1,5 +1,27 @@ +from typing import List, Optional + +from aries_cloudcontroller.models.indy_cred_info import IndyCredInfo +from aries_cloudcontroller.models.vc_record import VCRecord from pydantic import BaseModel, Field class SetDidEndpointRequest(BaseModel): endpoint: str = Field(...) + + +class ExtendedVCRecord(VCRecord): + credential_id: str = Field(..., alias="record_id") + record_id: str = Field(..., alias="credential_id") + + +class VCRecordList(BaseModel): + results: Optional[List[ExtendedVCRecord]] = None + + +class ExtendedIndyCredInfo(IndyCredInfo): + credential_id: str = Field(..., alias="referent") + referent: str = Field(..., alias="credential_id") + + +class CredInfoList(BaseModel): + results: Optional[List[ExtendedIndyCredInfo]] = None From b2a14fef057ddc8fef549539029b77d28b24a932 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Fri, 24 May 2024 10:16:21 +0200 Subject: [PATCH 08/25] remove unused imports --- app/routes/wallet/credentials.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index b76ad04b1..0bc9d6074 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -1,10 +1,8 @@ from typing import List, Optional -from aries_cloudcontroller import ( # CredInfoList,; VCRecordList, +from aries_cloudcontroller import ( AttributeMimeTypesResult, CredRevokedResult, - IndyCredInfo, - VCRecord, W3CCredentialsListRequest, ) from fastapi import APIRouter, Depends, Query From 10d844748bcfd72fd8a0591f0204f64613ac2e86 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Fri, 24 May 2024 10:20:40 +0200 Subject: [PATCH 09/25] route classes with get indy credential by id --- app/routes/wallet/credentials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 0bc9d6074..129933313 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -247,7 +247,7 @@ async def get_credential_revocation_status( @router.get( - "/w3c/stuff", + "/list/w3c", response_model=VCRecordList, summary="Fetch a list of W3C credentials from the wallet", ) From 2d691066c0a1739a03a5892ce33c56aca161530e Mon Sep 17 00:00:00 2001 From: cl0ete Date: Fri, 24 May 2024 10:21:28 +0200 Subject: [PATCH 10/25] update docstrings and revert back to credential_id --- app/routes/wallet/credentials.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 129933313..3501e213f 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -45,7 +45,8 @@ async def list_credentials( {"attr::age::value": "21"} - See more on WQL queries [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html). + See more on WQL queries + [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html). Parameters: --- @@ -84,18 +85,18 @@ async def list_credentials( summary="Fetch a credential by ID", ) async def get_credential_record( - referent: str, + credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> ExtendedIndyCredInfo: """ - Fetch a specific credential by referent. + Fetch a specific credential by credential ID. --- - The referent is the ID of the credential to fetch. + The referent and credential_id are the duplicates of each other. Parameters: --- - referent: str + credential_id: str The ID of the credential to fetch. Returns: @@ -111,7 +112,7 @@ async def get_credential_record( result = await handle_acapy_call( logger=bound_logger, acapy_call=aries_controller.credentials.get_record, - credential_id=referent, + credential_id=credential_id, ) bound_logger.debug("Successfully fetched credential.") @@ -124,11 +125,9 @@ async def delete_credential( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ - Remove a specific credential from the wallet by ID. + Remove a specific indy credential from the wallet by ID. --- - The credential_id is the ID of the credential to delete. - Parameters: --- credential_id: str @@ -210,7 +209,8 @@ async def get_credential_revocation_status( --- The status can be check on a specific time range by providing the `from_` and `to` parameters. - Pass the seconds, since Unix epoch, to the `from_` and `to` parameters to query the revocation status for a specific time range. + Pass the seconds, since Unix epoch, to the `from_` and `to` parameters to query the revocation + status for a specific time range. Parameters: --- @@ -266,7 +266,7 @@ async def list_w3c_credentials( """ Fetch a list of W3C credentials from the wallet. --- - + Credential_id and record_id are duplicates of each other. The W3C credentials can be filtered by the parameters provided. Parameters: From 40c0118d1006b284303360e24e8eaa53aaea501e Mon Sep 17 00:00:00 2001 From: cl0ete Date: Fri, 24 May 2024 10:22:43 +0200 Subject: [PATCH 11/25] formatting --- app/routes/wallet/credentials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 3501e213f..1aa5d7f4a 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -1,6 +1,6 @@ from typing import List, Optional -from aries_cloudcontroller import ( +from aries_cloudcontroller import ( AttributeMimeTypesResult, CredRevokedResult, W3CCredentialsListRequest, From 3def895ea2a9a71189a9e3aa74aed8b795cd52e1 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Mon, 3 Jun 2024 15:42:39 +0200 Subject: [PATCH 12/25] remove full stop --- app/routes/wallet/credentials.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 1aa5d7f4a..31acc6ce8 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -35,7 +35,7 @@ async def list_credentials( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredInfoList: """ - Fetch a list of credentials from the wallet. + Fetch a list of credentials from the wallet --- The WQL or wallet query language parameter can be used to filter credentials returned from the wallet. @@ -46,7 +46,7 @@ async def list_credentials( {"attr::age::value": "21"} See more on WQL queries - [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html). + [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html) Parameters: --- @@ -89,7 +89,7 @@ async def get_credential_record( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> ExtendedIndyCredInfo: """ - Fetch a specific credential by credential ID. + Fetch a specific credential by credential ID --- The referent and credential_id are the duplicates of each other. @@ -125,7 +125,7 @@ async def delete_credential( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ - Remove a specific indy credential from the wallet by ID. + Remove a specific indy credential from the wallet by ID --- Parameters: @@ -162,7 +162,7 @@ async def get_credential_mime_types( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> AttributeMimeTypesResult: """ - Retrieve attribute MIME types of a specific credential by ID. + Retrieve attribute MIME types of a specific credential by ID --- Parameters: @@ -205,7 +205,7 @@ async def get_credential_revocation_status( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredRevokedResult: """ - Query the revocation status of a specific credential by ID. + Query the revocation status of a specific credential by ID --- The status can be check on a specific time range by providing the `from_` and `to` parameters. @@ -264,7 +264,7 @@ async def list_w3c_credentials( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: """ - Fetch a list of W3C credentials from the wallet. + Fetch a list of W3C credentials from the wallet --- Credential_id and record_id are duplicates of each other. The W3C credentials can be filtered by the parameters provided. @@ -322,7 +322,7 @@ async def get_w3c_credential( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> ExtendedVCRecord: """ - Fetch a specific W3C credential by ID. + Fetch a specific W3C credential by ID --- Parameters: @@ -357,7 +357,7 @@ async def delete_w3c_credential( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ - Remove a specific W3C credential from the wallet by ID. + Remove a specific W3C credential from the wallet by ID --- Parameters: From 81d85cf741e10425772fa05cc874590b786689c5 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Tue, 11 Jun 2024 10:48:49 +0200 Subject: [PATCH 13/25] rename models --- app/models/wallet.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/wallet.py b/app/models/wallet.py index 5663d16ff..e8e9683b9 100644 --- a/app/models/wallet.py +++ b/app/models/wallet.py @@ -1,7 +1,7 @@ from typing import List, Optional -from aries_cloudcontroller.models.indy_cred_info import IndyCredInfo -from aries_cloudcontroller.models.vc_record import VCRecord +from aries_cloudcontroller.models.indy_cred_info import IndyCredInfo as IndyCredInfoAcaPy +from aries_cloudcontroller.models.vc_record import VCRecord as VCRecordAcaPy from pydantic import BaseModel, Field @@ -9,19 +9,19 @@ class SetDidEndpointRequest(BaseModel): endpoint: str = Field(...) -class ExtendedVCRecord(VCRecord): +class VCRecord(VCRecordAcaPy): credential_id: str = Field(..., alias="record_id") record_id: str = Field(..., alias="credential_id") class VCRecordList(BaseModel): - results: Optional[List[ExtendedVCRecord]] = None + results: Optional[List[VCRecord]] = None -class ExtendedIndyCredInfo(IndyCredInfo): +class IndyCredInfo(IndyCredInfoAcaPy): credential_id: str = Field(..., alias="referent") referent: str = Field(..., alias="credential_id") class CredInfoList(BaseModel): - results: Optional[List[ExtendedIndyCredInfo]] = None + results: Optional[List[IndyCredInfo]] = None From c20bf9318aff0f4eed3ec2212be5e1cedda304ec Mon Sep 17 00:00:00 2001 From: cl0ete Date: Tue, 11 Jun 2024 10:49:41 +0200 Subject: [PATCH 14/25] formatting --- app/models/wallet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/wallet.py b/app/models/wallet.py index e8e9683b9..00243a93d 100644 --- a/app/models/wallet.py +++ b/app/models/wallet.py @@ -1,6 +1,8 @@ from typing import List, Optional -from aries_cloudcontroller.models.indy_cred_info import IndyCredInfo as IndyCredInfoAcaPy +from aries_cloudcontroller.models.indy_cred_info import ( + IndyCredInfo as IndyCredInfoAcaPy, +) from aries_cloudcontroller.models.vc_record import VCRecord as VCRecordAcaPy from pydantic import BaseModel, Field From d68c97ef4e7df5988f190bd11fd644db21ea6315 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Tue, 11 Jun 2024 10:50:19 +0200 Subject: [PATCH 15/25] update models --- app/routes/wallet/credentials.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 31acc6ce8..a3ecbb7b3 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -12,8 +12,8 @@ from app.exceptions import handle_acapy_call from app.models.wallet import ( CredInfoList, - ExtendedIndyCredInfo, - ExtendedVCRecord, + IndyCredInfo, + VCRecord, VCRecordList, ) from shared.log_config import get_logger @@ -81,13 +81,13 @@ async def list_credentials( @router.get( "/{credential_id}", - response_model=ExtendedIndyCredInfo, + response_model=IndyCredInfo, summary="Fetch a credential by ID", ) async def get_credential_record( credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), -) -> ExtendedIndyCredInfo: +) -> IndyCredInfo: """ Fetch a specific credential by credential ID --- @@ -314,13 +314,13 @@ async def list_w3c_credentials( @router.get( "/w3c/{credential_id}", - response_model=ExtendedVCRecord, + response_model=VCRecord, summary="Fetch a W3C credential by ID", ) async def get_w3c_credential( credential_id: str, auth: AcaPyAuth = Depends(acapy_auth_from_header), -) -> ExtendedVCRecord: +) -> VCRecord: """ Fetch a specific W3C credential by ID --- From a3bedd81837e55b104cbcd52864e93deca2a625e Mon Sep 17 00:00:00 2001 From: cl0ete Date: Tue, 11 Jun 2024 10:50:35 +0200 Subject: [PATCH 16/25] update docstrings --- app/routes/wallet/credentials.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index a3ecbb7b3..ad60539a5 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -38,8 +38,9 @@ async def list_credentials( Fetch a list of credentials from the wallet --- - The WQL or wallet query language parameter can be used to filter credentials returned from the wallet. - The WQL query is a string that can be used to filter records based on the attributes name and value of the record. + The WQL (or, wallet query language) parameter can be used to filter credentials returned from the wallet. + The `wql` query parameter is a string that can be used to filter records based + on the attributes name and value of the record. The following string will look for the credential with the attribute `age` with value `21`: @@ -269,17 +270,17 @@ async def list_w3c_credentials( Credential_id and record_id are duplicates of each other. The W3C credentials can be filtered by the parameters provided. - Parameters: + Optional Parameters: --- - contexts: Optional[List[str]] - types: Optional[List[str]] - schema_ids: Optional[List[str]] - issuer_id: Optional[str] - subject_ids: Optional[List[str]] - given_id: Optional[str] - proof_types: Optional[List[str]] - tag_query: Optional[str] - max_results: Optional[int] + contexts: List[str] + types: List[str] + schema_ids: List[str] + issuer_id: str + subject_ids: List[str] + given_id: str + proof_types: List[str] + tag_query: str + max_results: int Returns: --- From d955446edb39ef31a777aafa4815ff15882f8027 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Tue, 11 Jun 2024 10:51:12 +0200 Subject: [PATCH 17/25] formatting --- app/routes/wallet/credentials.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index ad60539a5..0a1681c7c 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -10,12 +10,7 @@ from app.dependencies.acapy_clients import client_from_auth from app.dependencies.auth import AcaPyAuth, acapy_auth_from_header from app.exceptions import handle_acapy_call -from app.models.wallet import ( - CredInfoList, - IndyCredInfo, - VCRecord, - VCRecordList, -) +from app.models.wallet import CredInfoList, IndyCredInfo, VCRecord, VCRecordList from shared.log_config import get_logger logger = get_logger(__name__) From bb849fe353ea9167eede795b7231c3b4b874969d Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 12 Jun 2024 11:57:55 +0200 Subject: [PATCH 18/25] add description to models --- app/models/wallet.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/wallet.py b/app/models/wallet.py index 00243a93d..1a668fbfa 100644 --- a/app/models/wallet.py +++ b/app/models/wallet.py @@ -12,8 +12,12 @@ class SetDidEndpointRequest(BaseModel): class VCRecord(VCRecordAcaPy): - credential_id: str = Field(..., alias="record_id") - record_id: str = Field(..., alias="credential_id") + credential_id: str = Field( + ..., alias="record_id", description="Rename record_id to credential_id" + ) + record_id: str = Field( + ..., alias="credential_id", description="For backwards compatibility" + ) class VCRecordList(BaseModel): @@ -21,8 +25,12 @@ class VCRecordList(BaseModel): class IndyCredInfo(IndyCredInfoAcaPy): - credential_id: str = Field(..., alias="referent") - referent: str = Field(..., alias="credential_id") + credential_id: str = Field( + ..., alias="referent", description="Rename referent to credential_id" + ) + referent: str = Field( + ..., alias="credential_id", description="For backwards compatibility" + ) class CredInfoList(BaseModel): From e0f76a5b2bc806f710e1f29b0a50b48f00f9a03f Mon Sep 17 00:00:00 2001 From: cl0ete Date: Wed, 12 Jun 2024 11:58:26 +0200 Subject: [PATCH 19/25] update docstrings --- app/routes/wallet/credentials.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 0a1681c7c..22b594791 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -33,9 +33,7 @@ async def list_credentials( Fetch a list of credentials from the wallet --- - The WQL (or, wallet query language) parameter can be used to filter credentials returned from the wallet. - The `wql` query parameter is a string that can be used to filter records based - on the attributes name and value of the record. + The `wql` (Wallet Query Language) parameter can be used to filter credentials returned from the wallet. The following string will look for the credential with the attribute `age` with value `21`: @@ -44,13 +42,13 @@ async def list_credentials( See more on WQL queries [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html) - Parameters: + Optional Parameters: --- - count: Optional[str] + count: str The number of records to return. - start: Optional[str] + start: str The number of records to skip before starting to return records. - wql: Optional[str] + wql: str A WQL query to filter records. Returns: @@ -88,8 +86,6 @@ async def get_credential_record( Fetch a specific credential by credential ID --- - The referent and credential_id are the duplicates of each other. - Parameters: --- credential_id: str @@ -204,9 +200,9 @@ async def get_credential_revocation_status( Query the revocation status of a specific credential by ID --- - The status can be check on a specific time range by providing the `from_` and `to` parameters. - Pass the seconds, since Unix epoch, to the `from_` and `to` parameters to query the revocation - status for a specific time range. + The revocation status of a credential can be queried over a specific time range + by passing unix timestamps to the `from_` and `to` parameters. + Leaving these parameters blank will return the current revocation status. Parameters: --- @@ -262,7 +258,7 @@ async def list_w3c_credentials( """ Fetch a list of W3C credentials from the wallet --- - Credential_id and record_id are duplicates of each other. + The W3C credentials can be filtered by the parameters provided. Optional Parameters: From ce041c4841d8865c6866bf1b0c51b58006304225 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Mon, 15 Jul 2024 15:00:35 +0200 Subject: [PATCH 20/25] remove link from docstrings --- app/routes/wallet/credentials.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 22b594791..a2810f7ca 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -39,9 +39,6 @@ async def list_credentials( {"attr::age::value": "21"} - See more on WQL queries - [here](https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/design/011-wallet-query-language/README.html) - Optional Parameters: --- count: str From 75f7749e540864f24eb773fabe308bc2614f5288 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Fri, 25 Oct 2024 07:15:47 +0200 Subject: [PATCH 21/25] minor updates to docstrings --- app/routes/wallet/credentials.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index a2810f7ca..cb91c7a1c 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -24,8 +24,8 @@ summary="Fetch a list of credentials from the wallet", ) async def list_credentials( - count: Optional[str] = None, - start: Optional[str] = None, + limit: Optional[str] = None, + offset: Optional[str] = None, wql: Optional[str] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredInfoList: @@ -61,8 +61,8 @@ async def list_credentials( results = await handle_acapy_call( logger=logger, acapy_call=aries_controller.credentials.get_records, - count=count, - start=start, + count=limit, + start=offset, wql=wql, ) @@ -241,14 +241,8 @@ async def get_credential_revocation_status( summary="Fetch a list of W3C credentials from the wallet", ) async def list_w3c_credentials( - contexts: Optional[List[str]] = Query(None), - types: Optional[List[str]] = Query(None), schema_ids: Optional[List[str]] = Query(None), - subject_ids: Optional[List[str]] = Query(None), - proof_types: Optional[List[str]] = Query(None), issuer_id: Optional[str] = Query(None), - given_id: Optional[str] = Query(None), - tag_query: Optional[str] = Query(None), max_results: Optional[int] = Query(None), auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: @@ -260,14 +254,8 @@ async def list_w3c_credentials( Optional Parameters: --- - contexts: List[str] - types: List[str] schema_ids: List[str] issuer_id: str - subject_ids: List[str] - given_id: str - proof_types: List[str] - tag_query: str max_results: int Returns: @@ -278,14 +266,8 @@ async def list_w3c_credentials( logger.debug("GET request received: List W3C credentials") body = W3CCredentialsListRequest( - contexts=contexts, - types=types, schema_ids=schema_ids, issuer_id=issuer_id, - subject_ids=subject_ids, - given_id=given_id, - proof_types=proof_types, - tag_query=tag_query, max_results=max_results, ) From 4fae28328eb7d9d0bce9f79da4031f257a2ee740 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Mon, 28 Oct 2024 15:15:10 +0200 Subject: [PATCH 22/25] reduce and rename --- app/routes/wallet/credentials.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index cb91c7a1c..db778ee5f 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -24,8 +24,8 @@ summary="Fetch a list of credentials from the wallet", ) async def list_credentials( - limit: Optional[str] = None, - offset: Optional[str] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, wql: Optional[str] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredInfoList: @@ -242,8 +242,8 @@ async def get_credential_revocation_status( ) async def list_w3c_credentials( schema_ids: Optional[List[str]] = Query(None), - issuer_id: Optional[str] = Query(None), - max_results: Optional[int] = Query(None), + issuer_did: Optional[str] = Query(None), + limit: Optional[int] = Query(None), auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: """ @@ -255,8 +255,11 @@ async def list_w3c_credentials( Optional Parameters: --- schema_ids: List[str] - issuer_id: str - max_results: int + Schema identifiers, all of which to match + issuer_did: str + Credential issuer identifier to match + Limit: int + Maximum number of results to return Returns: --- @@ -267,8 +270,8 @@ async def list_w3c_credentials( body = W3CCredentialsListRequest( schema_ids=schema_ids, - issuer_id=issuer_id, - max_results=max_results, + issuer_id=issuer_did, + max_results=limit, ) async with client_from_auth(auth) as aries_controller: From c85e74f1357b6e36f181caec2a3b3906e8a0a3b0 Mon Sep 17 00:00:00 2001 From: cl0ete Date: Mon, 28 Oct 2024 15:40:25 +0200 Subject: [PATCH 23/25] add deprecated and change description --- app/models/wallet.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/wallet.py b/app/models/wallet.py index 1a668fbfa..53c017b20 100644 --- a/app/models/wallet.py +++ b/app/models/wallet.py @@ -13,10 +13,13 @@ class SetDidEndpointRequest(BaseModel): class VCRecord(VCRecordAcaPy): credential_id: str = Field( - ..., alias="record_id", description="Rename record_id to credential_id" + ..., alias="record_id", description="Credential/Record identifier" ) record_id: str = Field( - ..., alias="credential_id", description="For backwards compatibility" + ..., + alias="credential_id", + description="(deprecated - renamed to credential_id) Credential/record identifier", + deprecated=True, ) @@ -26,10 +29,13 @@ class VCRecordList(BaseModel): class IndyCredInfo(IndyCredInfoAcaPy): credential_id: str = Field( - ..., alias="referent", description="Rename referent to credential_id" + ..., alias="referent", description="Credential identifier" ) referent: str = Field( - ..., alias="credential_id", description="For backwards compatibility" + ..., + alias="credential_id", + description="(deprecated - renamed to credential_id) Credential identifier", + deprecated=True, ) From ad18eb8d94cae51d6bdadbf65ebe48610f8b2093 Mon Sep 17 00:00:00 2001 From: ff137 Date: Mon, 4 Nov 2024 14:12:22 +0200 Subject: [PATCH 24/25] :art: --- app/models/wallet.py | 4 ++-- app/routes/wallet/credentials.py | 31 +++++++++++++------------------ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/app/models/wallet.py b/app/models/wallet.py index 53c017b20..b514d80b2 100644 --- a/app/models/wallet.py +++ b/app/models/wallet.py @@ -13,12 +13,12 @@ class SetDidEndpointRequest(BaseModel): class VCRecord(VCRecordAcaPy): credential_id: str = Field( - ..., alias="record_id", description="Credential/Record identifier" + ..., alias="record_id", description="Credential identifier" ) record_id: str = Field( ..., alias="credential_id", - description="(deprecated - renamed to credential_id) Credential/record identifier", + description="(deprecated - renamed to credential_id) Credential identifier", deprecated=True, ) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index db778ee5f..46541dc3c 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -5,7 +5,7 @@ CredRevokedResult, W3CCredentialsListRequest, ) -from fastapi import APIRouter, Depends, Query +from fastapi import APIRouter, Depends from app.dependencies.acapy_clients import client_from_auth from app.dependencies.auth import AcaPyAuth, acapy_auth_from_header @@ -41,9 +41,9 @@ async def list_credentials( Optional Parameters: --- - count: str + limit: int The number of records to return. - start: str + offset: int The number of records to skip before starting to return records. wql: str A WQL query to filter records. @@ -52,7 +52,6 @@ async def list_credentials( --- CredInfoList A list of credential records. - """ logger.debug("GET request received: List credentials") @@ -61,8 +60,8 @@ async def list_credentials( results = await handle_acapy_call( logger=logger, acapy_call=aries_controller.credentials.get_records, - count=limit, - start=offset, + count=str(limit), + start=str(offset), wql=wql, ) @@ -80,7 +79,7 @@ async def get_credential_record( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> IndyCredInfo: """ - Fetch a specific credential by credential ID + Fetch a specific credential by ID --- Parameters: @@ -114,7 +113,7 @@ async def delete_credential( auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> None: """ - Remove a specific indy credential from the wallet by ID + Remove a specific credential from the wallet by ID --- Parameters: @@ -125,7 +124,6 @@ async def delete_credential( Returns: --- status_code: 204 - """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("DELETE request received: Remove specific credential by ID") @@ -163,7 +161,6 @@ async def get_credential_mime_types( --- AttributeMimeTypesResult The attribute MIME types of the credential. - """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug( @@ -214,7 +211,6 @@ async def get_credential_revocation_status( --- CredRevokedResult The revocation status of the credential. - """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug( @@ -241,9 +237,9 @@ async def get_credential_revocation_status( summary="Fetch a list of W3C credentials from the wallet", ) async def list_w3c_credentials( - schema_ids: Optional[List[str]] = Query(None), - issuer_did: Optional[str] = Query(None), - limit: Optional[int] = Query(None), + schema_ids: Optional[List[str]] = None, + issuer_did: Optional[str] = None, + limit: Optional[int] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> VCRecordList: """ @@ -255,10 +251,10 @@ async def list_w3c_credentials( Optional Parameters: --- schema_ids: List[str] - Schema identifiers, all of which to match + Schema identifiers to match issuer_did: str - Credential issuer identifier to match - Limit: int + Credential issuer did to match + limit: int Maximum number of results to return Returns: @@ -308,7 +304,6 @@ async def get_w3c_credential( --- VCRecord The W3C credential. - """ bound_logger = logger.bind(credential_id=credential_id) bound_logger.debug("GET request received: Fetch specific W3C credential by ID") From c23ec5f1e85d36cf548ec709056f4c4a8510ba1f Mon Sep 17 00:00:00 2001 From: ff137 Date: Mon, 4 Nov 2024 14:36:42 +0200 Subject: [PATCH 25/25] :art: use limit/offset query params with defaults --- app/routes/wallet/credentials.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/routes/wallet/credentials.py b/app/routes/wallet/credentials.py index 46541dc3c..b0af2c1d3 100644 --- a/app/routes/wallet/credentials.py +++ b/app/routes/wallet/credentials.py @@ -11,6 +11,7 @@ from app.dependencies.auth import AcaPyAuth, acapy_auth_from_header from app.exceptions import handle_acapy_call from app.models.wallet import CredInfoList, IndyCredInfo, VCRecord, VCRecordList +from app.util.pagination import limit_query_parameter, offset_query_parameter from shared.log_config import get_logger logger = get_logger(__name__) @@ -24,8 +25,8 @@ summary="Fetch a list of credentials from the wallet", ) async def list_credentials( - limit: Optional[int] = None, - offset: Optional[int] = None, + limit: Optional[int] = limit_query_parameter, + offset: Optional[int] = offset_query_parameter, wql: Optional[str] = None, auth: AcaPyAuth = Depends(acapy_auth_from_header), ) -> CredInfoList: