Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Create an API for updating VC for an entity #743

Closed
srprasanna opened this issue Jul 6, 2023 · 17 comments
Closed

[FEAT]: Create an API for updating VC for an entity #743

srprasanna opened this issue Jul 6, 2023 · 17 comments
Assignees

Comments

@srprasanna
Copy link
Collaborator

What is the feature request for?

Registry Core

What problem/inconvenience (if any) will this feature solve?

An API to update the VC for a Entity. The older VC should be revoked.

Describe the feature clearly.

Create an API to update the VC for an entity. The older VC should be revoked.

@chopadetejaswini
Copy link

Understanding: I should write API for Update the verfied Credentials for an entity and once VC is updated older VC should be revoked(canceled).

Implementation steps:
Understand the exact concept of VC.
Understand othet API's code related to VC
implement logic for update request of VC
write the functions related to update API in relevent class
Test the code if its working or not
Commit the code once done
Raise the PR

@chopadetejaswini
Copy link

Today I have read about Verified credentials from documentation, refer util/sign API from RegistryUtilsController class and revoke API from RegistryEntityController class, try to create update API for VC but its not completed

@chopadetejaswini
Copy link

@srprasanna I have write @PutMapping API code in RegistryEntityController Class, have created updateExistingVC() in RegistryHelper class and implement that method. Created UPDATED_CREDENTIAL variable in Constants class and UPDATE_VC variable in Response class. there is no runtime or compilation error but whenever I tried to call the API through Postman its showing errormsg -"vc: do not exist". please help me for the same

@chopadetejaswini
Copy link

On today I have changed the code of RegistryControllerClass,

firslty i have change the url and make it as " /api/v1/{entityName}/{entityId}/vc," and http request as POST

I have called revokeExistingCredentials() of class registryHelper .
means the existing credential is deleted means ossigned data will be null so we have to fill this empty signed data with newly
generated signature for that:
called sign() of class SignatureService class in RegistryEntityController.
After created new credential entity should be updated so for that:
called updateEntity() of RegistryService class in RegistryHelper by cretating new function updateExistingVC()
then that new function is called in RegistryEntityController class after sign()

but when I called the method in postman its showing error - "errmsg": "Unable to reach service: 400 Bad Request: [{"error": "Bad Request", "message": Bad request}]"

@chopadetejaswini
Copy link

Today, I have changed the code of the RegistryEntityController class. I have called the f revokeExistingCredentialMethod firstly. Then to call sign() of the SignatureService class i have declared map, got credentialTemplate from definition manager, put entityName as well and then called sign(requestBodyMap). by doing this my new os_signed data is created. just there is the issue with method updateEntity. there is the nullPointerException and error msg :Exception while updating vc for an entity.

@chopadetejaswini
Copy link

Sunbird RC - Working on create Update API for VC- Today I have used revokeAnEntity() instead of revokeExistingCredential() to revoke the existing ossigned data.
then sign() created the new ossigned data. I have made changes for updateEntity. I have used activateShard() of ShardManager instead of getShard(). Now the issue is that whenever i called the PUT API for first time it shows Recordnotfound Exception and when I called the same API for second time it shows response 200 ok.

@chopadetejaswini
Copy link

Today I have created new function updateAnEntity in RegistryHelper class. in which I have passed a variable in which result of sign() is stored. means newly generated ossigned data has passed. and called that Method controller class.
 but while calling API its showing errormsg: Unable to reach service: 400 Bad Request: [{"error": "Bad Request", "message": Bad request

@chopadetejaswini
Copy link

Yesterday I have changed the RegistryEntityController class and sign() removed in RegistryHepler class by creating function updateVc(). So in RegistryHelper updateVc(), is responsible for signing the entity data, adding the cryptographic signature to the JSON data, and then updating the entity in the registry by providing the updated JSON data to the registryService.updateEntity method.but when I calling API its showing error: unable to reach service, 400 bad request

@chopadetejaswini
Copy link

@Sreejit-K I have made chages in updateVC method is used to update the specified entity (identified by entityId) in the database with the new _osSignedData. The method ensures that the data is signed and follows the expected JSON structure before updating the entity. so the error: is solved and
When I calling the API its showing response 200 Ok. But I need to check with you for once that is that correctly working or not

@chopadetejaswini
Copy link

When I calling the API its showing response 200 Ok.but when I called revokeAnEntity() ossigned data is not becoming empty so trying for that so result can be correct

@chopadetejaswini
Copy link

@srprasanna @Sreejit-K @Renuka-S When I calling the API of put its showing response 200 Ok.Verified credential is getting updated , I have checked with get API and database also. Its working perfectly fine with database. But its not going to update in ElasticSearch. So do I need to update it in elasticsearch also? if yes then will work for that also

@chopadetejaswini
Copy link

Now When I call the put API for VC verified credential is getting updated in ES and DB , for that I need to downgrade the ES image as 6.6.0. But as per the discussion with holash he told me that we don't need to create new API for update VC we can make changes in existing API of update with entityId, we tried for that on today but there was several issues so we need to solve them

@chopadetejaswini
Copy link

When I calling the API its showing response 200 Ok.VC get updated in database and in  ElasticSearch also. as per suggested by Holash will tried to use existing update API (using entity id) to update the VC instead of using this new API.and its working now

@chopadetejaswini
Copy link

Raised PR

@chopadetejaswini chopadetejaswini moved this from In Progress to In review in Sunbird RC Roadmap 2023-24 Aug 2, 2023
@chopadetejaswini
Copy link

@srprasanna
Copy link
Collaborator Author

@holashchand can you review and close this after looking at the PR.

@srprasanna srprasanna linked a pull request Jan 16, 2024 that will close this issue
@srprasanna
Copy link
Collaborator Author

Issue is resolved.

@github-project-automation github-project-automation bot moved this from In review to Released in Sunbird RC Roadmap 2023-24 Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

3 participants