ivanyu commented on code in PR #6934:
URL: https://github.com/apache/kafka/pull/6934#discussion_r1587904583
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/resources/ConnectorsResource.java:
##########
@@ -242,6 +242,19 @@ public Response putConnectorConfig(final
@PathParam("connector") String connecto
return response.entity(createdInfo.result()).build();
}
+ @PATCH
+ @Path("/{connector}/config")
+ public Response patchConnectorConfig(final @PathParam("connector") String
connector,
+ final @Context HttpHeaders headers,
+ final @QueryParam("forward") Boolean
forward,
+ final Map<String, String>
connectorConfigPatch) throws Throwable {
+ FutureCallback<Herder.Created<ConnectorInfo>> cb = new
FutureCallback<>();
+ herder.patchConnectorConfig(connector, connectorConfigPatch, cb);
+ Herder.Created<ConnectorInfo> createdInfo =
requestHandler.completeOrForwardRequest(cb, "/connectors/" + connector +
"/config",
+ "PATCH", headers, connectorConfigPatch, new
TypeReference<ConnectorInfo>() { }, new CreatedConnectorInfoTranslator(),
forward);
+ return Response.ok().entity(createdInfo.result()).build();
Review Comment:
I didn't find the current `PUT` response documentation, so I propose
something like this:
```
Responses follow the model of the configuration PUT endpoint:
1. If the patch was successfully applied, the response code is 200 and the
body is a JSON object with the updated connector information (`name`, `type`,
`config`, and `tasks`), for example:
{
"name": "my-connector",
"config":
{
"name": "my-connector",
"sample_config_2": "test_config_2",
"sample_config": "test_config_new"
},
"tasks":
[
{
"connector": "my-connector",
"task": 0
},
{
"connector": "my-connector",
"task": 1
}
],
"type": "sink"
}
2. In case of errors, the response code matches the error type (e.g. 400 in
case of a config validation error; 404 if the connector is not found; 500 in
case of other server-side errors) and the body is a JSON object with the error
details:
{
"error_code": 400,
"message": "Connector configuration is invalid and contains the
following 1 error(s):\n...\nYou can also find the above list of errors at the
endpoint `/{connectorType}/config/validate`"
}
```
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]