OpenFabrics / sunfish_library_reference

The core Sunfish implementation
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Update patch implementation to allow only selected properties to be updated #11

Closed mgazz closed 4 months ago

mgazz commented 5 months ago

Currently the patch takes as input only the payload of the request. However, the json specified in the payload might not contain a Id of the resource that we would like to update.

I propose we update the current implementation by changing the patch_object signature as following

    def patch_object(self, path,payload):

This way, a server leveraging the sunfish_library_reference receives a PATCH request with a minimal payload will be able to pass a reference to the resource to be updated.

Example

PATCH /redfish/v1/EventService/Subscriptions/SunfishServer

with json

{"Context": "abc123"}

In this case, a simple server implementation will be able to handle the PATCH operation as following:

def patch(resource):
    try:
        data = request.json
        resp = sunfish_core.patch_object('/'+resource, data)
        return resp, 200
    except ResourceNotFound as e:
        return e.message, 404
christian-pinto commented 4 months ago

Feature merged.