Search in sources :

Example 1 with ModeUpdateRequest

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);
}
Also used : ModeUpdateRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest)

Example 2 with ModeUpdateRequest

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);
}
Also used : ModeUpdateRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest) SchemaString(io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString) EasyMock.anyString(org.easymock.EasyMock.anyString) Test(org.junit.Test)

Example 3 with ModeUpdateRequest

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;
}
Also used : ModeUpdateRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest) SchemaString(io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString)

Example 4 with ModeUpdateRequest

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);
    }
}
Also used : SchemaRegistryRequestForwardingException(io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException) ModeUpdateRequest(io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) RestException(io.confluent.rest.exceptions.RestException) IOException(java.io.IOException) UrlList(io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)

Aggregations

ModeUpdateRequest (io.confluent.kafka.schemaregistry.client.rest.entities.requests.ModeUpdateRequest)4 SchemaString (io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString)2 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)1 UrlList (io.confluent.kafka.schemaregistry.client.rest.utils.UrlList)1 SchemaRegistryRequestForwardingException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryRequestForwardingException)1 RestException (io.confluent.rest.exceptions.RestException)1 IOException (java.io.IOException)1 EasyMock.anyString (org.easymock.EasyMock.anyString)1 Test (org.junit.Test)1