use of io.confluent.kafka.schemaregistry.client.rest.entities.Config in project schema-registry by confluentinc.
the class ConfigResource method deleteTopLevelConfig.
@DELETE
@Operation(summary = "Deletes the Global-level compatibility level config and " + "revert to the global default.", responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = CompatibilityLevel.class))), @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "datastore") })
public void deleteTopLevelConfig(@Suspended final AsyncResponse asyncResponse, @Context HttpHeaders headers) {
log.info("Deleting Global compatibility setting and reverting back to default");
Config deletedConfig;
try {
CompatibilityLevel currentCompatibility = schemaRegistry.getCompatibilityLevel(null);
Map<String, String> headerProperties = requestHeaderBuilder.buildRequestHeaders(headers, schemaRegistry.config().whitelistHeaders());
schemaRegistry.deleteCompatibilityConfigOrForward(null, headerProperties);
deletedConfig = new Config(currentCompatibility.name);
} catch (OperationNotPermittedException e) {
throw Errors.operationNotPermittedException(e.getMessage());
} catch (SchemaRegistryStoreException e) {
throw Errors.storeException("Failed to delete compatibility level", e);
} catch (UnknownLeaderException e) {
throw Errors.unknownLeaderException("Failed to delete compatibility level", e);
} catch (SchemaRegistryRequestForwardingException e) {
throw Errors.requestForwardingFailedException("Error while forwarding delete config request" + " to the leader", e);
}
asyncResponse.resume(deletedConfig);
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.Config in project schema-registry by confluentinc.
the class ConfigResource method getSubjectLevelConfig.
@Path("/{subject}")
@GET
@Operation(summary = "Get compatibility level for a subject.", responses = { @ApiResponse(responseCode = "404", description = "Subject not found"), @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "data store") })
public Config getSubjectLevelConfig(@Parameter(description = "Name of the subject", required = true) @PathParam("subject") String subject, @Parameter(description = "Whether to return the global compatibility level " + " if subject compatibility level not found") @QueryParam("defaultToGlobal") boolean defaultToGlobal) {
subject = QualifiedSubject.normalize(schemaRegistry.tenant(), subject);
Config config;
try {
CompatibilityLevel compatibilityLevel = defaultToGlobal ? schemaRegistry.getCompatibilityLevelInScope(subject) : schemaRegistry.getCompatibilityLevel(subject);
if (compatibilityLevel == null) {
throw Errors.subjectLevelCompatibilityNotConfiguredException(subject);
}
config = new Config(compatibilityLevel.name);
} catch (SchemaRegistryStoreException e) {
throw Errors.storeException("Failed to get the configs for subject " + subject, e);
}
return config;
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.Config in project schema-registry by confluentinc.
the class ConfigResource method getTopLevelConfig.
@GET
@Operation(summary = "Get global compatibility level.", responses = { @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "data store") })
public Config getTopLevelConfig() {
Config config;
try {
CompatibilityLevel compatibilityLevel = schemaRegistry.getCompatibilityLevel(null);
config = new Config(compatibilityLevel == null ? null : compatibilityLevel.name);
} catch (SchemaRegistryStoreException e) {
throw Errors.storeException("Failed to get compatibility level", e);
}
return config;
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.Config in project schema-registry by confluentinc.
the class ConfigResource method deleteSubjectConfig.
@DELETE
@Path("/{subject}")
@Operation(summary = "Deletes the specified subject-level compatibility level config and " + "revert to the global default.", responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = CompatibilityLevel.class))), @ApiResponse(responseCode = "404", description = "Error code 40401 -- Subject not found"), @ApiResponse(responseCode = "500", description = "Error code 50001 -- Error in the backend " + "datastore") })
public void deleteSubjectConfig(@Suspended final AsyncResponse asyncResponse, @Context HttpHeaders headers, @Parameter(description = "Name of the subject", required = true) @PathParam("subject") String subject) {
log.info("Deleting compatibility setting for subject {}", subject);
subject = QualifiedSubject.normalize(schemaRegistry.tenant(), subject);
Config deletedConfig;
try {
CompatibilityLevel currentCompatibility = schemaRegistry.getCompatibilityLevel(subject);
if (currentCompatibility == null) {
throw Errors.subjectNotFoundException(subject);
}
Map<String, String> headerProperties = requestHeaderBuilder.buildRequestHeaders(headers, schemaRegistry.config().whitelistHeaders());
schemaRegistry.deleteCompatibilityConfigOrForward(subject, headerProperties);
deletedConfig = new Config(currentCompatibility.name);
} catch (OperationNotPermittedException e) {
throw Errors.operationNotPermittedException(e.getMessage());
} catch (SchemaRegistryStoreException e) {
throw Errors.storeException("Failed to delete compatibility level", e);
} catch (UnknownLeaderException e) {
throw Errors.unknownLeaderException("Failed to delete compatibility level", e);
} catch (SchemaRegistryRequestForwardingException e) {
throw Errors.requestForwardingFailedException("Error while forwarding delete config request" + " to the leader", e);
}
asyncResponse.resume(deletedConfig);
}
use of io.confluent.kafka.schemaregistry.client.rest.entities.Config in project schema-registry by confluentinc.
the class RestService method getConfig.
public Config getConfig(Map<String, String> requestProperties, String subject, boolean defaultToGlobal) throws IOException, RestClientException {
String path = subject != null ? UriBuilder.fromPath("/config/{subject}").queryParam("defaultToGlobal", defaultToGlobal).build(subject).toString() : "/config";
Config config = httpRequest(path, "GET", null, requestProperties, GET_CONFIG_RESPONSE_TYPE);
return config;
}
Aggregations