diff --git a/Documentation/REST-API/Resources-Monitor.md b/Documentation/REST-API/Resources-Monitor.md index 61a09f500..84495a0a2 100644 --- a/Documentation/REST-API/Resources-Monitor.md +++ b/Documentation/REST-API/Resources-Monitor.md @@ -298,6 +298,54 @@ Invalid request body: `Status: 403 Forbidden` +### Update monitor relationships + +``` +PATCH /v1/monitors/:name/relationships/servers +``` + +The _:name_ in the URI must map to a monitor name with all whitespace replaced +with hyphens. + +The request body must be a JSON object that defines only the _data_ field. The +value of the _data_ field must be an array of relationship objects that define +the _id_ and _type_ fields of the relationship. This object will replace the +existing relationships of the monitor. + +The following is an example request and request body that defines a single +server relationship for a monitor. + +``` +PATCH /v1/monitors/my-monitor/relationships/servers + +{ + data: [ + { "id": "my-server", "type": "servers" } + ] +} +``` + +All relationships for a monitor can be deleted by sending an empty array as the +_data_ field value. The following example removes all servers from a monitor. + +``` +PATCH /v1/monitors/my-monitor/relationships/servers + +{ + data: [] +} +``` + +#### Response + +Monitor relationships modified: + +`Status: 204 No Content` + +Invalid JSON body: + +`Status: 403 Forbidden` + ### Destroy a monitor Destroy a created monitor. The monitor must not have relationships to any diff --git a/Documentation/REST-API/Resources-Server.md b/Documentation/REST-API/Resources-Server.md index cd3c0316c..1409790f7 100644 --- a/Documentation/REST-API/Resources-Server.md +++ b/Documentation/REST-API/Resources-Server.md @@ -467,6 +467,55 @@ Invalid JSON body: `Status: 403 Forbidden` +### Update server relationships + +``` +PATCH /v1/servers/:name/relationships/:type +``` + +The _:name_ in the URI must map to a server name with all whitespace replaced +with hyphens. The _:type_ in the URI must be either _services_, for service +relationships, or _monitors_, for monitor relationships. + +The request body must be a JSON object that defines only the _data_ field. The +value of the _data_ field must be an array of relationship objects that define +the _id_ and _type_ fields of the relationship. This object will replace the +existing relationships of the particular type from the server. + +The following is an example request and request body that defines a single +service relationship for a server. + +``` +PATCH /v1/servers/my-db-server/relationships/services + +{ + data: [ + { "id": "my-rwsplit-service", "type": "services" } + ] +} +``` + +All relationships for a server can be deleted by sending an empty array as the +_data_ field value. The following example removes the server from all services. + +``` +PATCH /v1/servers/my-db-server/relationships/services + +{ + data: [] +} +``` + +#### Response + +Server relationships modified: + +`Status: 204 No Content` + +Invalid JSON body: + +`Status: 403 Forbidden` + ### Destroy a server ``` diff --git a/Documentation/REST-API/Resources-Service.md b/Documentation/REST-API/Resources-Service.md index 382b46c3c..bb59c05b1 100644 --- a/Documentation/REST-API/Resources-Service.md +++ b/Documentation/REST-API/Resources-Service.md @@ -420,6 +420,54 @@ Service is modified: `Status: 204 No Content` +### Update service relationships + +``` +PATCH /v1/services/:name/relationships/servers +``` + +The _:name_ in the URI must map to a service name with all whitespace replaced +with hyphens. + +The request body must be a JSON object that defines only the _data_ field. The +value of the _data_ field must be an array of relationship objects that define +the _id_ and _type_ fields of the relationship. This object will replace the +existing relationships of the service. + +The following is an example request and request body that defines a single +server relationship for a service. + +``` +PATCH /v1/services/my-rw-service/relationships/servers + +{ + data: [ + { "id": "my-server", "type": "servers" } + ] +} +``` + +All relationships for a service can be deleted by sending an empty array as the +_data_ field value. The following example removes all servers from a service. + +``` +PATCH /v1/services/my-rw-service/relationships/servers + +{ + data: [] +} +``` + +#### Response + +Service relationships modified: + +`Status: 204 No Content` + +Invalid JSON body: + +`Status: 403 Forbidden` + ### Stop a service Stops a started service.