use of io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest in project schema-registry by confluentinc.
the class RestService method setMode.
public ModeUpdateRequest setMode(String mode, String subject, boolean force) throws IOException, RestClientException {
ModeUpdateRequest request = new ModeUpdateRequest();
request.setMode(mode);
return setMode(DEFAULT_REQUEST_PROPERTIES, request, subject, force);
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest in project schema-registry by confluentinc.
the class CachedSchemaRegistryClientTest method testSetMode.
@Test
public void testSetMode() throws Exception {
final String mode = "READONLY";
reset(restService);
ModeUpdateRequest modeUpdateRequest = new ModeUpdateRequest();
modeUpdateRequest.setMode(mode);
expect(restService.setMode(eq(mode))).andReturn(modeUpdateRequest);
replay(restService);
assertEquals(mode, client.setMode(mode));
verify(restService);
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest in project schema-registry by confluentinc.
the class RestService method setMode.
/**
* On success, this api simply echoes the request in the response.
*/
public ModeUpdateRequest setMode(Map<String, String> requestProperties, ModeUpdateRequest modeUpdateRequest, String subject, boolean force) throws IOException, RestClientException {
String path = subject != null ? UriBuilder.fromPath("/mode/{subject}").queryParam("force", force).build(subject).toString() : UriBuilder.fromPath("/mode").queryParam("force", force).build().toString();
ModeUpdateRequest response = httpRequest(path, "PUT", modeUpdateRequest.toJson().getBytes(StandardCharsets.UTF_8), requestProperties, UPDATE_MODE_RESPONSE_TYPE_REFERENCE);
return response;
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest in project schema-registry by confluentinc.
the class KafkaSchemaRegistry method forwardSetModeRequestToLeader.
private void forwardSetModeRequestToLeader(String subject, Mode mode, boolean force, Map<String, String> headerProperties) throws SchemaRegistryRequestForwardingException {
UrlList baseUrl = leaderRestService.getBaseUrls();
ModeUpdateRequest modeUpdateRequest = new ModeUpdateRequest();
modeUpdateRequest.setMode(mode.name());
log.debug(String.format("Forwarding update mode request %s to %s", modeUpdateRequest, baseUrl));
try {
leaderRestService.setMode(headerProperties, modeUpdateRequest, subject, force);
} catch (IOException e) {
throw new SchemaRegistryRequestForwardingException(String.format("Unexpected error while forwarding the update mode request %s to %s", modeUpdateRequest, baseUrl), e);
} catch (RestClientException e) {
throw new RestException(e.getMessage(), e.getStatus(), e.getErrorCode(), e);
}
}
Aggregations