Project

General

Profile

Cleanup #47071

Feature #40907: mgr/dashboard: REST API improvements

mgr/dashboard/api: review PUT methods

Added by Ernesto Puerta about 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
General - Back-end
Target version:
-
% Done:

0%

Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

Many ceph-dashboard endpoints support PUT method, but in most cases it's used to perform partial updates, which breaks RESTful architecture, as it may result in PUT no longer being idempotent.

Partial updates would require either POST (which could be suitable for Collection-like endpoints), or PATCH (which is optimal for single resource or multiple resource partial update).

HTTP does not specify any syntax for the PATCH body, so several proposals have arised:

  • JSON Patch (http://jsonpatch.com): rather than a data structure, the body defines a sequence of operations (add, remove, replace, copy, move and test) to be performed on the existing resource JSON representation. To address JSON fields, it uses JSON pointers. Llibraries exist for Python and JS ([1], [2], ...).
  • JSON Merge Patch is a simpler and more pragmatic approach, when no complex actions are required.
Examples of endpoints requiring fix:
  • /cluster_conf: alternative, PUT /cluster_conf/{option}
  • /host/{id}: the PUT method only updates labels, so it's a partial update... Alternative approach: /host/{id}/labels
  • /mgr/module/{id}: ...

History

#1 Updated by Ernesto Puerta about 2 years ago

  • Parent task set to #40907

#2 Updated by Nizamudeen A almost 2 years ago

  • Assignee set to Nizamudeen A

#3 Updated by Ernesto Puerta over 1 year ago

  • Project changed from mgr to Dashboard
  • Category changed from 146 to General - Back-end

#4 Updated by Nizamudeen A over 1 year ago

  • Assignee deleted (Nizamudeen A)

Also available in: Atom PDF