MXS-1220: Add support for PATCH

The PATCH method should now be used instead the PUT method to update
resources.  As PUT request bodies should represent complete resources, the
use of PUT to update resources is no longer supported.

Altered tests to use PATCH instead of PUT for updating resources.
This commit is contained in:
Markus Mäkelä
2017-06-05 09:04:58 +03:00
parent d63af9df0b
commit e4a004097e
14 changed files with 48 additions and 36 deletions

View File

@ -111,10 +111,16 @@ Credentials for authentication.
#### Content-Type
All PUT and POST requests must use the `Content-Type: application/json` media
type and the request body must be a valid JSON representation of a resource. All
PATCH requests must use the `Content-Type: application/json` media type and the
request body must be a JSON document containing a partial definition of the
original resource.
type and the request body must be a complete and valid JSON representation of a
resource. All PATCH requests must use the `Content-Type: application/json` media
type and the request body must be a JSON document containing a partial
definition of the original resource.
The current version of the API supports PATCH-like PUT requests with
partial definitions of resources in the request body. This is discouraged
as it goes against the intended use of the PUT method. Future versions of
the MaxScale REST API can remove this support which means that this
functionality is deprecated.
#### Host

View File

@ -267,7 +267,7 @@ The :name in the URI must map to a monitor name with all whitespace replaced wit
hyphens. The request body must be a valid JSON document representing the modified monitor.
```
PUT /v1/monitor/:name
PATCH /v1/monitor/:name
```
### Modifiable Fields

View File

@ -312,7 +312,7 @@ Status: 403 Forbidden
### Update a server
```
PUT /v1/servers/:name
PATCH /v1/servers/:name
```
The _:name_ in the URI must map to a server name with all whitespace replaced
@ -443,12 +443,12 @@ Request for `PUT /v1/server/server1`:
}
```
The current implementation accepts both PUT and PATCH requests with partially
defined resources as request body. If parts of the resource are not defined
(e.g. the `attributes` field in the above example), those parts of the resource
are not modified. All parts that are defined are interpreted as the new
definition of those part of the resource. In the above example, the
`relationships` of the resource are completely redefined.
The current implementation accepts PATCH requests with partially defined
resources as request body. If parts of the resource are not defined (e.g. the
`attributes` field in the above example), those parts of the resource are not
modified. All parts that are defined are interpreted as the new definition of
those part of the resource. In the above example, the `relationships` of the
resource are completely redefined.
#### Response

View File

@ -265,7 +265,7 @@ The _:name_ in the URI must map to a service name and the request body must be a
valid JSON Patch document which is applied to the resource.
```
PUT /v1/services/:name
PATCH /v1/services/:name
```
The following standard service parameters can be modified.