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

Implement JSON Patch for multiples devices #2039

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbtrystram
Copy link
Contributor

allows to update parts of multiples devices registration data, using the json patch format.

It allows the device registry implementation to override it, as some more features might be needed (such as transaction operations on database, atomic changes etc...).

I had to add a dependency on eclipse Glassfish, as Vert.x does not support Json Patch.

Here is how it works, assuming devices 4711 exist (but not 4713) :

 curl --insecure -X PATCH -i -H 'Content-Type: application/json-patch' http://localhost:28080/v1/devices/DEFAULT_TENANT -d '{             
    "id" : ["4711", "4713"],
    "patch": [
    {
        "op": "add",
        "path": "/enabled",
        "value": true
    },
    {
        "op": "add",
        "path": "/ext",
        "value": {
            "key": "value"
        }
    }
]
}'

And the result would be :

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
content-length: 234

{"4711":{"status":204,"resource-version":"1d8fe6ab-311e-4f9d-95b3-832bc90e35fa"},"4713":{"status":404,"error-message":"device '4713' cannot be retrieved"}}              

This is a draft as I still need to update the doc and add some unit tests.

Some resources :
http://jsonpatch.com/
https://json-patch-builder-online.github.io/

Signed-off-by: Jean-Baptiste Trystram [email protected]

@jbtrystram jbtrystram marked this pull request as draft June 19, 2020 06:59
@dejanb
Copy link
Contributor

dejanb commented Jun 19, 2020

Looks good to me so far. Note that build fails atm for some checkstyles.

@jbtrystram jbtrystram marked this pull request as ready for review July 1, 2020 08:41
…compliant with RFC 6902, allowing to apply the patch to multiples devices.

Signed-off-by: Jean-Baptiste Trystram <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants