mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat: Glue Schema Registry support (#621)
* feat(glue): add Glue Schema Registry support * Move Glue SDK coverage to compatibility tests * Align protobuf compatibility expectations * Resolve services index merge conflict * Remove unused Lombok compatibility dependency * Serialize Glue schema registry timestamps as strings * Tighten Glue schema registry name validation * Avoid duplicate schema registry index rebuild * Limit schema registry in-memory constructor visibility * Clone Glue tables before resolving schema references * Align Glue schema registry response shapes * Extract Glue schema version resolver helper Both validateSchemaReference and withResolvedSchemaReference duplicated the latest-version computation and the four-argument getSchemaVersion call. Pull that into a private resolveSchemaVersion(SchemaReference) helper so the call sites read at one level of abstraction and a future change to the resolution rule lands in one place. * Fix Glue schema version list projection --------- Signed-off-by: Tristan Burch <tburch@users.noreply.github.com> Signed-off-by: Hector Ventura <hectorvent@gmail.com> Co-authored-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
ac891db5a7
commit
b84d205b89
30 files changed
+6056
-20
No files matched your search
@@ -6,21 +6,36 @@ import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.glue.model.Database;
|
||||
import io.github.hectorvent.floci.services.glue.model.Partition;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.GlueSchemaRegistryService;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.Registry;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.RegistryId;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.Schema;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.SchemaId;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.SchemaVersion;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ApplicationScoped
|
||||
public class GlueJsonHandler {
|
||||
|
||||
private final GlueService glueService;
|
||||
private final GlueSchemaRegistryService schemaRegistryService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public GlueJsonHandler(GlueService glueService, ObjectMapper mapper) {
|
||||
public GlueJsonHandler(GlueService glueService,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
ObjectMapper mapper) {
|
||||
this.glueService = glueService;
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@@ -73,7 +88,420 @@ public class GlueJsonHandler {
|
||||
String tableName = request.get("TableName").asText();
|
||||
yield Response.ok(Map.of("Partitions", glueService.getPartitions(dbName, tableName))).build();
|
||||
}
|
||||
case "CreateRegistry" -> handleCreateRegistry(request, region);
|
||||
case "GetRegistry" -> handleGetRegistry(request, region);
|
||||
case "ListRegistries" -> handleListRegistries(request);
|
||||
case "UpdateRegistry" -> handleUpdateRegistry(request, region);
|
||||
case "DeleteRegistry" -> handleDeleteRegistry(request, region);
|
||||
case "CreateSchema" -> handleCreateSchema(request, region);
|
||||
case "RegisterSchemaVersion" -> handleRegisterSchemaVersion(request, region);
|
||||
case "GetSchemaByDefinition" -> handleGetSchemaByDefinition(request, region);
|
||||
case "GetSchemaVersion" -> handleGetSchemaVersion(request, region);
|
||||
case "GetSchema" -> handleGetSchema(request, region);
|
||||
case "UpdateSchema" -> handleUpdateSchema(request, region);
|
||||
case "ListSchemas" -> handleListSchemas(request, region);
|
||||
case "ListSchemaVersions" -> handleListSchemaVersions(request, region);
|
||||
case "DeleteSchema" -> handleDeleteSchema(request, region);
|
||||
case "DeleteSchemaVersions" -> handleDeleteSchemaVersions(request, region);
|
||||
case "GetSchemaVersionsDiff" -> handleGetSchemaVersionsDiff(request, region);
|
||||
case "CheckSchemaVersionValidity" -> handleCheckSchemaVersionValidity(request);
|
||||
case "PutSchemaVersionMetadata" -> handlePutSchemaVersionMetadata(request);
|
||||
case "RemoveSchemaVersionMetadata" -> handleRemoveSchemaVersionMetadata(request);
|
||||
case "QuerySchemaVersionMetadata" -> handleQuerySchemaVersionMetadata(request);
|
||||
case "TagResource" -> handleTagResource(request);
|
||||
case "UntagResource" -> handleUntagResource(request);
|
||||
case "GetTags" -> handleGetTags(request);
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
};
|
||||
}
|
||||
|
||||
private Response handleCreateRegistry(JsonNode request, String region) {
|
||||
String name = request.path("RegistryName").asText(null);
|
||||
String description = request.path("Description").asText(null);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> tags = request.has("Tags")
|
||||
? mapper.convertValue(request.get("Tags"), Map.class)
|
||||
: null;
|
||||
Registry registry = schemaRegistryService.createRegistry(name, description, tags, region);
|
||||
return Response.ok(registry).build();
|
||||
}
|
||||
|
||||
private Response handleGetRegistry(JsonNode request, String region) throws Exception {
|
||||
RegistryId registryId = readRegistryId(request);
|
||||
Registry registry = schemaRegistryService.getRegistry(registryId, region);
|
||||
return Response.ok(registry).build();
|
||||
}
|
||||
|
||||
private Response handleListRegistries(JsonNode request) {
|
||||
var page = schemaRegistryService.listRegistries(readMaxResults(request), readNextToken(request));
|
||||
return Response.ok(pageResponse("Registries", registryListItems(page.items()), page.nextToken())).build();
|
||||
}
|
||||
|
||||
private Response handleUpdateRegistry(JsonNode request, String region) throws Exception {
|
||||
RegistryId registryId = readRegistryId(request);
|
||||
String description = request.path("Description").asText(null);
|
||||
Registry registry = schemaRegistryService.updateRegistry(registryId, description, region);
|
||||
return Response.ok(Map.of(
|
||||
"RegistryName", registry.getRegistryName(),
|
||||
"RegistryArn", registry.getRegistryArn()
|
||||
)).build();
|
||||
}
|
||||
|
||||
private Response handleDeleteRegistry(JsonNode request, String region) throws Exception {
|
||||
RegistryId registryId = readRegistryId(request);
|
||||
Registry registry = schemaRegistryService.deleteRegistry(registryId, region);
|
||||
return Response.ok(Map.of(
|
||||
"RegistryName", registry.getRegistryName(),
|
||||
"RegistryArn", registry.getRegistryArn(),
|
||||
"Status", registry.getStatus()
|
||||
)).build();
|
||||
}
|
||||
|
||||
private RegistryId readRegistryId(JsonNode request) throws Exception {
|
||||
JsonNode node = request.get("RegistryId");
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
return mapper.treeToValue(node, RegistryId.class);
|
||||
}
|
||||
|
||||
private SchemaId readSchemaId(JsonNode request) throws Exception {
|
||||
JsonNode node = request.get("SchemaId");
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
return mapper.treeToValue(node, SchemaId.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Response handleCreateSchema(JsonNode request, String region) throws Exception {
|
||||
RegistryId registryId = readRegistryId(request);
|
||||
String schemaName = request.path("SchemaName").asText(null);
|
||||
String dataFormat = request.path("DataFormat").asText(null);
|
||||
String compatibility = request.path("Compatibility").asText(null);
|
||||
String description = request.path("Description").asText(null);
|
||||
String definition = request.path("SchemaDefinition").asText(null);
|
||||
Map<String, String> tags = request.has("Tags")
|
||||
? mapper.convertValue(request.get("Tags"), Map.class)
|
||||
: null;
|
||||
var result = schemaRegistryService.createSchema(
|
||||
registryId, schemaName, dataFormat, compatibility, description, definition, tags, region);
|
||||
Schema schema = result.schema();
|
||||
SchemaVersion version = result.firstVersion();
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("RegistryName", schema.getRegistryName());
|
||||
response.put("RegistryArn", schema.getRegistryArn());
|
||||
response.put("SchemaName", schema.getSchemaName());
|
||||
response.put("SchemaArn", schema.getSchemaArn());
|
||||
if (schema.getDescription() != null) response.put("Description", schema.getDescription());
|
||||
response.put("DataFormat", schema.getDataFormat());
|
||||
response.put("Compatibility", schema.getCompatibility());
|
||||
response.put("SchemaCheckpoint", schema.getSchemaCheckpoint());
|
||||
response.put("LatestSchemaVersion", schema.getLatestSchemaVersion());
|
||||
response.put("NextSchemaVersion", schema.getNextSchemaVersion());
|
||||
response.put("SchemaStatus", schema.getSchemaStatus());
|
||||
if (schema.getTags() != null) response.put("Tags", schema.getTags());
|
||||
response.put("SchemaVersionId", version.getSchemaVersionId());
|
||||
response.put("SchemaVersionStatus", version.getStatus());
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleRegisterSchemaVersion(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
String definition = request.path("SchemaDefinition").asText(null);
|
||||
SchemaVersion version = schemaRegistryService.registerSchemaVersion(schemaId, definition, region);
|
||||
return Response.ok(Map.of(
|
||||
"SchemaVersionId", version.getSchemaVersionId(),
|
||||
"VersionNumber", version.getVersionNumber(),
|
||||
"Status", version.getStatus()
|
||||
)).build();
|
||||
}
|
||||
|
||||
private Response handleGetSchemaByDefinition(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
String definition = request.path("SchemaDefinition").asText(null);
|
||||
SchemaVersion version = schemaRegistryService.getSchemaByDefinition(schemaId, definition, region);
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("SchemaVersionId", version.getSchemaVersionId());
|
||||
response.put("SchemaArn", version.getSchemaArn());
|
||||
response.put("DataFormat", version.getDataFormat());
|
||||
response.put("Status", version.getStatus());
|
||||
response.put("CreatedTime", iso(version.getCreatedTime()));
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleGetSchemaVersion(JsonNode request, String region) throws Exception {
|
||||
String schemaVersionId = request.path("SchemaVersionId").asText(null);
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
Long versionNumber = null;
|
||||
boolean latestVersion = false;
|
||||
JsonNode svn = request.get("SchemaVersionNumber");
|
||||
if (svn != null && !svn.isNull()) {
|
||||
JsonNode vn = svn.get("VersionNumber");
|
||||
if (vn != null && !vn.isNull()) {
|
||||
versionNumber = vn.asLong();
|
||||
}
|
||||
JsonNode lv = svn.get("LatestVersion");
|
||||
if (lv != null && !lv.isNull()) {
|
||||
latestVersion = lv.asBoolean();
|
||||
}
|
||||
}
|
||||
SchemaVersion version = schemaRegistryService.getSchemaVersion(
|
||||
schemaId, schemaVersionId, versionNumber, latestVersion, region);
|
||||
return Response.ok(version).build();
|
||||
}
|
||||
|
||||
private Response handleGetSchema(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
Schema schema = schemaRegistryService.getSchema(schemaId, region);
|
||||
return Response.ok(schema).build();
|
||||
}
|
||||
|
||||
private Response handleUpdateSchema(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
String compatibility = request.path("Compatibility").asText(null);
|
||||
String description = request.path("Description").asText(null);
|
||||
Long checkpointVersion = readVersionNumber(request, "SchemaVersionNumber");
|
||||
Schema schema = schemaRegistryService.updateSchema(
|
||||
schemaId, compatibility, description, checkpointVersion, region);
|
||||
return Response.ok(Map.of(
|
||||
"SchemaArn", schema.getSchemaArn(),
|
||||
"SchemaName", schema.getSchemaName(),
|
||||
"RegistryName", schema.getRegistryName()
|
||||
)).build();
|
||||
}
|
||||
|
||||
private Response handleListSchemas(JsonNode request, String region) throws Exception {
|
||||
RegistryId registryId = readRegistryId(request);
|
||||
var page = schemaRegistryService.listSchemas(
|
||||
registryId, region, readMaxResults(request), readNextToken(request));
|
||||
return Response.ok(pageResponse("Schemas", schemaListItems(page.items()), page.nextToken())).build();
|
||||
}
|
||||
|
||||
private Response handleListSchemaVersions(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
var page = schemaRegistryService.listSchemaVersions(
|
||||
schemaId, region, readMaxResults(request), readNextToken(request));
|
||||
return Response.ok(pageResponse("Schemas", schemaVersionListItems(page.items()), page.nextToken())).build();
|
||||
}
|
||||
|
||||
private Response handleDeleteSchema(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
Schema schema = schemaRegistryService.deleteSchema(schemaId, region);
|
||||
return Response.ok(Map.of(
|
||||
"SchemaArn", schema.getSchemaArn(),
|
||||
"SchemaName", schema.getSchemaName(),
|
||||
"Status", schema.getSchemaStatus()
|
||||
)).build();
|
||||
}
|
||||
|
||||
private Response handleDeleteSchemaVersions(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
String versions = request.path("Versions").asText(null);
|
||||
var results = schemaRegistryService.deleteSchemaVersions(schemaId, versions, region);
|
||||
|
||||
List<Map<String, Object>> errors = new ArrayList<>();
|
||||
for (var r : results) {
|
||||
if (r.errorCode() != null) {
|
||||
Map<String, Object> err = new LinkedHashMap<>();
|
||||
err.put("VersionNumber", r.versionNumber());
|
||||
Map<String, Object> details = new LinkedHashMap<>();
|
||||
details.put("ErrorCode", r.errorCode());
|
||||
details.put("ErrorMessage", r.errorMessage());
|
||||
err.put("ErrorDetails", details);
|
||||
errors.add(err);
|
||||
}
|
||||
}
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("SchemaVersionErrors", errors);
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleGetSchemaVersionsDiff(JsonNode request, String region) throws Exception {
|
||||
SchemaId schemaId = readSchemaId(request);
|
||||
Long first = readVersionNumber(request, "FirstSchemaVersionNumber");
|
||||
Long second = readVersionNumber(request, "SecondSchemaVersionNumber");
|
||||
String diff = schemaRegistryService.getSchemaVersionsDiff(schemaId, first, second, region);
|
||||
return Response.ok(Map.of("Diff", diff)).build();
|
||||
}
|
||||
|
||||
private Response handleCheckSchemaVersionValidity(JsonNode request) {
|
||||
String dataFormat = request.path("DataFormat").asText(null);
|
||||
String definition = request.path("SchemaDefinition").asText(null);
|
||||
var result = schemaRegistryService.checkSchemaVersionValidity(dataFormat, definition);
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("Valid", result.valid());
|
||||
if (result.error() != null) {
|
||||
response.put("Error", result.error());
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Long readVersionNumber(JsonNode request, String field) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
JsonNode vn = node.get("VersionNumber");
|
||||
if (vn == null || vn.isNull()) {
|
||||
return null;
|
||||
}
|
||||
return vn.asLong();
|
||||
}
|
||||
|
||||
private Integer readMaxResults(JsonNode request) {
|
||||
JsonNode node = request.get("MaxResults");
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
return node.asInt();
|
||||
}
|
||||
|
||||
private String readNextToken(JsonNode request) {
|
||||
JsonNode node = request.get("NextToken");
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
return node.asText(null);
|
||||
}
|
||||
|
||||
private Map<String, Object> pageResponse(String field, List<?> items, String nextToken) {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put(field, items);
|
||||
if (nextToken != null) {
|
||||
response.put("NextToken", nextToken);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> registryListItems(List<Registry> registries) {
|
||||
return registries.stream().map(this::registryListItem).toList();
|
||||
}
|
||||
|
||||
private Map<String, Object> registryListItem(Registry registry) {
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
putIfNotNull(item, "RegistryName", registry.getRegistryName());
|
||||
putIfNotNull(item, "RegistryArn", registry.getRegistryArn());
|
||||
putIfNotNull(item, "Description", registry.getDescription());
|
||||
putIfNotNull(item, "Status", registry.getStatus());
|
||||
putIfNotNull(item, "CreatedTime", iso(registry.getCreatedTime()));
|
||||
putIfNotNull(item, "UpdatedTime", iso(registry.getUpdatedTime()));
|
||||
return item;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> schemaListItems(List<Schema> schemas) {
|
||||
return schemas.stream().map(this::schemaListItem).toList();
|
||||
}
|
||||
|
||||
private Map<String, Object> schemaListItem(Schema schema) {
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
putIfNotNull(item, "RegistryName", schema.getRegistryName());
|
||||
putIfNotNull(item, "SchemaName", schema.getSchemaName());
|
||||
putIfNotNull(item, "SchemaArn", schema.getSchemaArn());
|
||||
putIfNotNull(item, "Description", schema.getDescription());
|
||||
putIfNotNull(item, "SchemaStatus", schema.getSchemaStatus());
|
||||
putIfNotNull(item, "CreatedTime", iso(schema.getCreatedTime()));
|
||||
putIfNotNull(item, "UpdatedTime", iso(schema.getUpdatedTime()));
|
||||
return item;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> schemaVersionListItems(List<SchemaVersion> versions) {
|
||||
return versions.stream().map(this::schemaVersionListItem).toList();
|
||||
}
|
||||
|
||||
private Map<String, Object> schemaVersionListItem(SchemaVersion version) {
|
||||
Map<String, Object> item = new LinkedHashMap<>();
|
||||
putIfNotNull(item, "SchemaArn", version.getSchemaArn());
|
||||
putIfNotNull(item, "SchemaVersionId", version.getSchemaVersionId());
|
||||
putIfNotNull(item, "VersionNumber", version.getVersionNumber());
|
||||
putIfNotNull(item, "Status", version.getStatus());
|
||||
putIfNotNull(item, "CreatedTime", iso(version.getCreatedTime()));
|
||||
return item;
|
||||
}
|
||||
|
||||
private static void putIfNotNull(Map<String, Object> target, String key, Object value) {
|
||||
if (value != null) {
|
||||
target.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static String iso(Instant instant) {
|
||||
return instant != null ? instant.toString() : null;
|
||||
}
|
||||
|
||||
private Response handlePutSchemaVersionMetadata(JsonNode request) {
|
||||
String svId = request.path("SchemaVersionId").asText(null);
|
||||
JsonNode kv = request.get("MetadataKeyValue");
|
||||
String key = kv != null ? kv.path("MetadataKey").asText(null) : null;
|
||||
String value = kv != null ? kv.path("MetadataValue").asText(null) : null;
|
||||
var result = schemaRegistryService.putSchemaVersionMetadata(svId, key, value);
|
||||
return Response.ok(buildMetadataPutResponse(result)).build();
|
||||
}
|
||||
|
||||
private Response handleRemoveSchemaVersionMetadata(JsonNode request) {
|
||||
String svId = request.path("SchemaVersionId").asText(null);
|
||||
JsonNode kv = request.get("MetadataKeyValue");
|
||||
String key = kv != null ? kv.path("MetadataKey").asText(null) : null;
|
||||
String value = kv != null ? kv.path("MetadataValue").asText(null) : null;
|
||||
var result = schemaRegistryService.removeSchemaVersionMetadata(svId, key, value);
|
||||
return Response.ok(buildMetadataPutResponse(result)).build();
|
||||
}
|
||||
|
||||
private Response handleQuerySchemaVersionMetadata(JsonNode request) {
|
||||
String svId = request.path("SchemaVersionId").asText(null);
|
||||
List<GlueSchemaRegistryService.MetadataKeyValueFilter> filters = new ArrayList<>();
|
||||
JsonNode list = request.get("MetadataList");
|
||||
if (list != null && list.isArray()) {
|
||||
for (JsonNode item : list) {
|
||||
String k = item.path("MetadataKey").asText(null);
|
||||
String v = item.path("MetadataValue").asText(null);
|
||||
filters.add(new GlueSchemaRegistryService.MetadataKeyValueFilter(k, v));
|
||||
}
|
||||
}
|
||||
Map<String, ?> infoMap = schemaRegistryService.querySchemaVersionMetadata(svId, filters);
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("MetadataInfoMap", infoMap);
|
||||
response.put("SchemaVersionId", svId);
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Map<String, Object> buildMetadataPutResponse(GlueSchemaRegistryService.MetadataPutResult result) {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("SchemaArn", result.version().getSchemaArn());
|
||||
response.put("SchemaName", result.schema().getSchemaName());
|
||||
response.put("RegistryName", result.schema().getRegistryName());
|
||||
response.put("LatestVersion",
|
||||
Objects.equals(result.version().getVersionNumber(), result.schema().getLatestSchemaVersion()));
|
||||
response.put("SchemaVersionId", result.version().getSchemaVersionId());
|
||||
response.put("VersionNumber", result.version().getVersionNumber());
|
||||
response.put("MetadataKey", result.metadataKey());
|
||||
response.put("MetadataValue", result.metadataValue());
|
||||
return response;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Response handleTagResource(JsonNode request) {
|
||||
String arn = request.path("ResourceArn").asText(null);
|
||||
Map<String, String> tagsToAdd = request.has("TagsToAdd")
|
||||
? mapper.convertValue(request.get("TagsToAdd"), Map.class)
|
||||
: null;
|
||||
schemaRegistryService.tagResource(arn, tagsToAdd);
|
||||
return Response.ok(Map.of()).build();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Response handleUntagResource(JsonNode request) {
|
||||
String arn = request.path("ResourceArn").asText(null);
|
||||
List<String> tagsToRemove = request.has("TagsToRemove")
|
||||
? mapper.convertValue(request.get("TagsToRemove"), List.class)
|
||||
: null;
|
||||
schemaRegistryService.untagResource(arn, tagsToRemove);
|
||||
return Response.ok(Map.of()).build();
|
||||
}
|
||||
|
||||
private Response handleGetTags(JsonNode request) {
|
||||
String arn = request.path("ResourceArn").asText(null);
|
||||
Map<String, String> tags = schemaRegistryService.getTags(arn);
|
||||
return Response.ok(Map.of("Tags", tags)).build();
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,27 @@ package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.Column;
|
||||
import io.github.hectorvent.floci.services.glue.model.Database;
|
||||
import io.github.hectorvent.floci.services.glue.model.Partition;
|
||||
import io.github.hectorvent.floci.services.glue.model.SchemaReference;
|
||||
import io.github.hectorvent.floci.services.glue.model.StorageDescriptor;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.GlueSchemaRegistryService;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.SchemaToColumnsConverter;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.SchemaId;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.SchemaVersion;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@ApplicationScoped
|
||||
public class GlueService {
|
||||
@@ -23,12 +32,30 @@ public class GlueService {
|
||||
private final StorageBackend<String, Database> databaseStore;
|
||||
private final StorageBackend<String, Table> tableStore;
|
||||
private final StorageBackend<String, Partition> partitionStore;
|
||||
private final GlueSchemaRegistryService schemaRegistryService;
|
||||
private final RegionResolver regionResolver;
|
||||
|
||||
@Inject
|
||||
public GlueService(StorageFactory storageFactory) {
|
||||
public GlueService(StorageFactory storageFactory,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
RegionResolver regionResolver) {
|
||||
this.databaseStore = storageFactory.create("glue", "databases.json", new TypeReference<Map<String, Database>>() {});
|
||||
this.tableStore = storageFactory.create("glue", "tables.json", new TypeReference<Map<String, Table>>() {});
|
||||
this.partitionStore = storageFactory.create("glue", "partitions.json", new TypeReference<Map<String, Partition>>() {});
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.regionResolver = regionResolver;
|
||||
}
|
||||
|
||||
GlueService(StorageBackend<String, Database> databaseStore,
|
||||
StorageBackend<String, Table> tableStore,
|
||||
StorageBackend<String, Partition> partitionStore,
|
||||
GlueSchemaRegistryService schemaRegistryService,
|
||||
RegionResolver regionResolver) {
|
||||
this.databaseStore = databaseStore;
|
||||
this.tableStore = tableStore;
|
||||
this.partitionStore = partitionStore;
|
||||
this.schemaRegistryService = schemaRegistryService;
|
||||
this.regionResolver = regionResolver;
|
||||
}
|
||||
|
||||
public void createDatabase(Database database) {
|
||||
@@ -49,11 +76,12 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public void createTable(String databaseName, Table table) {
|
||||
getDatabase(databaseName); // Check if db exists
|
||||
getDatabase(databaseName);
|
||||
String key = databaseName + ":" + table.getName();
|
||||
if (tableStore.get(key).isPresent()) {
|
||||
throw new AwsException("AlreadyExistsException", "Table already exists: " + table.getName(), 400);
|
||||
}
|
||||
validateSchemaReference(table);
|
||||
table.setDatabaseName(databaseName);
|
||||
tableStore.put(key, table);
|
||||
LOG.infov("Created Glue Table: {0}.{1}", databaseName, table.getName());
|
||||
@@ -61,18 +89,23 @@ public class GlueService {
|
||||
|
||||
public Table getTable(String databaseName, String tableName) {
|
||||
String key = databaseName + ":" + tableName;
|
||||
return tableStore.get(key)
|
||||
Table table = tableStore.get(key)
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException", "Table not found: " + databaseName + "." + tableName, 400));
|
||||
return withResolvedSchemaReference(table);
|
||||
}
|
||||
|
||||
public List<Table> getTables(String databaseName) {
|
||||
return tableStore.scan(k -> k.startsWith(databaseName + ":"));
|
||||
List<Table> tables = tableStore.scan(k -> k.startsWith(databaseName + ":"));
|
||||
List<Table> resolved = new ArrayList<>(tables.size());
|
||||
for (Table table : tables) {
|
||||
resolved.add(withResolvedSchemaReference(table));
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
public void deleteTable(String databaseName, String tableName) {
|
||||
String key = databaseName + ":" + tableName;
|
||||
tableStore.delete(key);
|
||||
// Also delete partitions
|
||||
partitionStore.scan(k -> k.startsWith(key + ":")).forEach(p -> {
|
||||
partitionStore.delete(databaseName + ":" + tableName + ":" + String.join(",", p.getValues()));
|
||||
});
|
||||
@@ -80,7 +113,7 @@ public class GlueService {
|
||||
}
|
||||
|
||||
public void createPartition(String databaseName, String tableName, Partition partition) {
|
||||
getTable(databaseName, tableName); // Check if table exists
|
||||
getTable(databaseName, tableName);
|
||||
String key = databaseName + ":" + tableName + ":" + String.join(",", partition.getValues());
|
||||
partition.setDatabaseName(databaseName);
|
||||
partition.setTableName(tableName);
|
||||
@@ -91,4 +124,123 @@ public class GlueService {
|
||||
String prefix = databaseName + ":" + tableName + ":";
|
||||
return partitionStore.scan(k -> k.startsWith(prefix));
|
||||
}
|
||||
|
||||
private void validateSchemaReference(Table table) {
|
||||
SchemaReference ref = schemaReferenceOf(table);
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
// Throws EntityNotFoundException / InvalidInputException if reference is broken.
|
||||
resolveSchemaVersion(ref);
|
||||
}
|
||||
|
||||
private Table withResolvedSchemaReference(Table table) {
|
||||
SchemaReference ref = schemaReferenceOf(table);
|
||||
if (ref == null) {
|
||||
return table;
|
||||
}
|
||||
try {
|
||||
SchemaVersion version = resolveSchemaVersion(ref);
|
||||
List<Column> columns = SchemaToColumnsConverter.toColumns(
|
||||
version.getDataFormat(), version.getSchemaDefinition());
|
||||
if (!columns.isEmpty()) {
|
||||
Table resolved = copyTable(table);
|
||||
resolved.getStorageDescriptor().setColumns(columns);
|
||||
return resolved;
|
||||
}
|
||||
} catch (AwsException e) {
|
||||
LOG.warnv("SchemaReference resolution failed for {0}.{1}: {2}",
|
||||
table.getDatabaseName(), table.getName(), e.getMessage());
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
private SchemaVersion resolveSchemaVersion(SchemaReference ref) {
|
||||
boolean latest = ref.getSchemaVersionId() == null && ref.getSchemaVersionNumber() == null;
|
||||
return schemaRegistryService.getSchemaVersion(
|
||||
ref.getSchemaId(), ref.getSchemaVersionId(),
|
||||
ref.getSchemaVersionNumber(), latest, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
private static SchemaReference schemaReferenceOf(Table table) {
|
||||
StorageDescriptor sd = table != null ? table.getStorageDescriptor() : null;
|
||||
return sd != null ? sd.getSchemaReference() : null;
|
||||
}
|
||||
|
||||
private static Table copyTable(Table source) {
|
||||
Table copy = new Table();
|
||||
copy.setName(source.getName());
|
||||
copy.setDatabaseName(source.getDatabaseName());
|
||||
copy.setDescription(source.getDescription());
|
||||
copy.setCreateTime(source.getCreateTime());
|
||||
copy.setUpdateTime(source.getUpdateTime());
|
||||
copy.setLastAccessTime(source.getLastAccessTime());
|
||||
copy.setPartitionKeys(copyColumns(source.getPartitionKeys()));
|
||||
copy.setStorageDescriptor(copyStorageDescriptor(source.getStorageDescriptor()));
|
||||
copy.setTableType(source.getTableType());
|
||||
copy.setParameters(copyMap(source.getParameters()));
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static StorageDescriptor copyStorageDescriptor(StorageDescriptor source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
StorageDescriptor copy = new StorageDescriptor();
|
||||
copy.setColumns(copyColumns(source.getColumns()));
|
||||
copy.setLocation(source.getLocation());
|
||||
copy.setInputFormat(source.getInputFormat());
|
||||
copy.setOutputFormat(source.getOutputFormat());
|
||||
copy.setCompressed(source.getCompressed());
|
||||
copy.setNumberOfBuckets(source.getNumberOfBuckets());
|
||||
copy.setSerdeInfo(copySerDeInfo(source.getSerdeInfo()));
|
||||
copy.setParameters(copyMap(source.getParameters()));
|
||||
copy.setSchemaReference(copySchemaReference(source.getSchemaReference()));
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static StorageDescriptor.SerDeInfo copySerDeInfo(StorageDescriptor.SerDeInfo source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
StorageDescriptor.SerDeInfo copy = new StorageDescriptor.SerDeInfo();
|
||||
copy.setName(source.getName());
|
||||
copy.setSerializationLibrary(source.getSerializationLibrary());
|
||||
copy.setParameters(copyMap(source.getParameters()));
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static SchemaReference copySchemaReference(SchemaReference source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
SchemaReference copy = new SchemaReference();
|
||||
SchemaId schemaId = source.getSchemaId();
|
||||
if (schemaId != null) {
|
||||
copy.setSchemaId(new SchemaId(
|
||||
schemaId.getRegistryName(), schemaId.getSchemaName(), schemaId.getSchemaArn()));
|
||||
}
|
||||
copy.setSchemaVersionId(source.getSchemaVersionId());
|
||||
copy.setSchemaVersionNumber(source.getSchemaVersionNumber());
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static List<Column> copyColumns(List<Column> source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
List<Column> copy = new ArrayList<>(source.size());
|
||||
for (Column column : source) {
|
||||
Column columnCopy = new Column();
|
||||
columnCopy.setName(column.getName());
|
||||
columnCopy.setType(column.getType());
|
||||
columnCopy.setComment(column.getComment());
|
||||
copy.add(columnCopy);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static Map<String, String> copyMap(Map<String, String> source) {
|
||||
return source != null ? new LinkedHashMap<>(source) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.SchemaId;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SchemaReference {
|
||||
|
||||
@JsonProperty("SchemaId")
|
||||
private SchemaId schemaId;
|
||||
|
||||
@JsonProperty("SchemaVersionId")
|
||||
private String schemaVersionId;
|
||||
|
||||
@JsonProperty("SchemaVersionNumber")
|
||||
private Long schemaVersionNumber;
|
||||
|
||||
public SchemaReference() {}
|
||||
|
||||
public SchemaId getSchemaId() { return schemaId; }
|
||||
public void setSchemaId(SchemaId schemaId) { this.schemaId = schemaId; }
|
||||
|
||||
public String getSchemaVersionId() { return schemaVersionId; }
|
||||
public void setSchemaVersionId(String schemaVersionId) { this.schemaVersionId = schemaVersionId; }
|
||||
|
||||
public Long getSchemaVersionNumber() { return schemaVersionNumber; }
|
||||
public void setSchemaVersionNumber(Long schemaVersionNumber) { this.schemaVersionNumber = schemaVersionNumber; }
|
||||
}
|
||||
@@ -23,6 +23,8 @@ public class StorageDescriptor {
|
||||
private SerDeInfo serdeInfo;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
@JsonProperty("SchemaReference")
|
||||
private SchemaReference schemaReference;
|
||||
|
||||
public StorageDescriptor() {}
|
||||
|
||||
@@ -42,6 +44,8 @@ public class StorageDescriptor {
|
||||
public void setSerdeInfo(SerDeInfo serdeInfo) { this.serdeInfo = serdeInfo; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
public SchemaReference getSchemaReference() { return schemaReference; }
|
||||
public void setSchemaReference(SchemaReference schemaReference) { this.schemaReference = schemaReference; }
|
||||
|
||||
@RegisterForReflection
|
||||
public static class SerDeInfo {
|
||||
|
||||
+1047
File diff suppressed because it is too large.
Load diff
+146
@@ -0,0 +1,146 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry;
|
||||
|
||||
import io.apicurio.registry.content.ContentHandle;
|
||||
import io.apicurio.registry.content.canon.AvroContentCanonicalizer;
|
||||
import io.apicurio.registry.content.canon.ContentCanonicalizer;
|
||||
import io.apicurio.registry.content.canon.JsonContentCanonicalizer;
|
||||
import io.apicurio.registry.content.canon.ProtobufContentCanonicalizer;
|
||||
import io.apicurio.registry.rules.compatibility.AvroCompatibilityChecker;
|
||||
import io.apicurio.registry.rules.compatibility.CompatibilityChecker;
|
||||
import io.apicurio.registry.rules.compatibility.CompatibilityDifference;
|
||||
import io.apicurio.registry.rules.compatibility.CompatibilityExecutionResult;
|
||||
import io.apicurio.registry.rules.compatibility.CompatibilityLevel;
|
||||
import io.apicurio.registry.rules.compatibility.JsonSchemaCompatibilityChecker;
|
||||
import io.apicurio.registry.rules.compatibility.ProtobufCompatibilityChecker;
|
||||
import io.apicurio.registry.rules.validity.AvroContentValidator;
|
||||
import io.apicurio.registry.rules.validity.ContentValidator;
|
||||
import io.apicurio.registry.rules.validity.JsonSchemaContentValidator;
|
||||
import io.apicurio.registry.rules.validity.ProtobufContentValidator;
|
||||
import io.apicurio.registry.rules.validity.ValidityLevel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Glue → Apicurio adapter for schema compatibility, validation, and canonicalization.
|
||||
* Pure utility — no CDI. Stateless.
|
||||
*/
|
||||
public final class SchemaCompatibilityChecker {
|
||||
|
||||
public record Result(boolean compatible, String reason) {
|
||||
public static Result ok() {
|
||||
return new Result(true, null);
|
||||
}
|
||||
}
|
||||
|
||||
private SchemaCompatibilityChecker() {}
|
||||
|
||||
/**
|
||||
* Check whether {@code newDefinition} is compatible with {@code existingDefinitions}
|
||||
* under the given Glue compatibility {@code mode}.
|
||||
*
|
||||
* <p>{@code existingDefinitions} must be ordered by version ascending (oldest first,
|
||||
* latest last). For non-transitive modes (BACKWARD/FORWARD/FULL) only the latest
|
||||
* existing version is compared; for transitive modes (BACKWARD_ALL/FORWARD_ALL/FULL_ALL)
|
||||
* every prior version is compared.
|
||||
*/
|
||||
public static Result check(String mode, List<String> existingDefinitions, String newDefinition, String dataFormat) {
|
||||
if (mode == null || existingDefinitions == null || existingDefinitions.isEmpty()) {
|
||||
return Result.ok();
|
||||
}
|
||||
if ("NONE".equals(mode) || "DISABLED".equals(mode)) {
|
||||
return Result.ok();
|
||||
}
|
||||
CompatibilityLevel level = toApicurioLevel(mode);
|
||||
CompatibilityChecker checker = checkerFor(dataFormat);
|
||||
|
||||
List<ContentHandle> existing = existingDefinitions.stream()
|
||||
.map(ContentHandle::create)
|
||||
.collect(Collectors.toList());
|
||||
ContentHandle proposed = ContentHandle.create(newDefinition);
|
||||
|
||||
CompatibilityExecutionResult result = checker.testCompatibility(level, existing, proposed, Map.of());
|
||||
if (result.isCompatible()) {
|
||||
return Result.ok();
|
||||
}
|
||||
return new Result(false, formatDifferences(result));
|
||||
}
|
||||
|
||||
public static String canonicalize(String definition, String dataFormat) {
|
||||
ContentCanonicalizer canon = canonicalizerFor(dataFormat);
|
||||
ContentHandle handle = ContentHandle.create(definition);
|
||||
return canon.canonicalize(handle, Map.of()).content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that {@code definition} is parseable for the declared {@code dataFormat}.
|
||||
* @return null when valid; an error message when invalid.
|
||||
*/
|
||||
public static String validateDefinition(String definition, String dataFormat) {
|
||||
ContentValidator validator = validatorFor(dataFormat);
|
||||
try {
|
||||
validator.validate(ValidityLevel.SYNTAX_ONLY, ContentHandle.create(definition), Map.of());
|
||||
return null;
|
||||
} catch (RuntimeException e) {
|
||||
return e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
||||
private static CompatibilityLevel toApicurioLevel(String glueMode) {
|
||||
return switch (glueMode) {
|
||||
case "NONE", "DISABLED" -> CompatibilityLevel.NONE;
|
||||
case "BACKWARD" -> CompatibilityLevel.BACKWARD;
|
||||
case "BACKWARD_ALL" -> CompatibilityLevel.BACKWARD_TRANSITIVE;
|
||||
case "FORWARD" -> CompatibilityLevel.FORWARD;
|
||||
case "FORWARD_ALL" -> CompatibilityLevel.FORWARD_TRANSITIVE;
|
||||
case "FULL" -> CompatibilityLevel.FULL;
|
||||
case "FULL_ALL" -> CompatibilityLevel.FULL_TRANSITIVE;
|
||||
default -> throw new IllegalArgumentException("Unknown compatibility mode: " + glueMode);
|
||||
};
|
||||
}
|
||||
|
||||
private static CompatibilityChecker checkerFor(String dataFormat) {
|
||||
return switch (dataFormat) {
|
||||
case "AVRO" -> new AvroCompatibilityChecker();
|
||||
case "JSON" -> new JsonSchemaCompatibilityChecker();
|
||||
case "PROTOBUF" -> new ProtobufCompatibilityChecker();
|
||||
default -> throw new IllegalArgumentException("Unsupported DataFormat: " + dataFormat);
|
||||
};
|
||||
}
|
||||
|
||||
private static ContentCanonicalizer canonicalizerFor(String dataFormat) {
|
||||
return switch (dataFormat) {
|
||||
case "AVRO" -> new AvroContentCanonicalizer();
|
||||
case "JSON" -> new JsonContentCanonicalizer();
|
||||
case "PROTOBUF" -> new ProtobufContentCanonicalizer();
|
||||
default -> throw new IllegalArgumentException("Unsupported DataFormat: " + dataFormat);
|
||||
};
|
||||
}
|
||||
|
||||
private static ContentValidator validatorFor(String dataFormat) {
|
||||
return switch (dataFormat) {
|
||||
case "AVRO" -> new AvroContentValidator();
|
||||
case "JSON" -> new JsonSchemaContentValidator();
|
||||
case "PROTOBUF" -> new ProtobufContentValidator();
|
||||
default -> throw new IllegalArgumentException("Unsupported DataFormat: " + dataFormat);
|
||||
};
|
||||
}
|
||||
|
||||
private static String formatDifferences(CompatibilityExecutionResult result) {
|
||||
if (result.getIncompatibleDifferences() == null || result.getIncompatibleDifferences().isEmpty()) {
|
||||
return "Schema is incompatible";
|
||||
}
|
||||
return result.getIncompatibleDifferences().stream()
|
||||
.map(d -> {
|
||||
var rv = d.asRuleViolation();
|
||||
String desc = rv != null ? rv.getDescription() : null;
|
||||
String ctx = rv != null ? rv.getContext() : null;
|
||||
if (desc == null) {
|
||||
return d.toString();
|
||||
}
|
||||
return ctx == null ? desc : desc + " at " + ctx;
|
||||
})
|
||||
.collect(Collectors.joining("; "));
|
||||
}
|
||||
}
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.squareup.wire.schema.Field;
|
||||
import com.squareup.wire.schema.Location;
|
||||
import com.squareup.wire.schema.internal.parser.FieldElement;
|
||||
import com.squareup.wire.schema.internal.parser.MessageElement;
|
||||
import com.squareup.wire.schema.internal.parser.ProtoFileElement;
|
||||
import com.squareup.wire.schema.internal.parser.ProtoParser;
|
||||
import com.squareup.wire.schema.internal.parser.TypeElement;
|
||||
import io.github.hectorvent.floci.services.glue.model.Column;
|
||||
import org.apache.avro.LogicalType;
|
||||
import org.apache.avro.LogicalTypes;
|
||||
import org.apache.avro.Schema;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Converts a registered schema definition (Avro / JSON Schema / Protobuf source) into a list
|
||||
* of Glue Catalog {@link Column} objects with Hive-style type strings.
|
||||
*
|
||||
* <p>Top-level fields only — no flattening of nested records. Unknown / unsupported types
|
||||
* fall back to {@code string}. Parse failures log a warning and return an empty list (the
|
||||
* Catalog read should still succeed).
|
||||
*/
|
||||
public final class SchemaToColumnsConverter {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SchemaToColumnsConverter.class);
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
private SchemaToColumnsConverter() {}
|
||||
|
||||
public static List<Column> toColumns(String dataFormat, String definition) {
|
||||
if (dataFormat == null || definition == null || definition.isBlank()) {
|
||||
return List.of();
|
||||
}
|
||||
try {
|
||||
return switch (dataFormat) {
|
||||
case "AVRO" -> avroColumns(definition);
|
||||
case "JSON" -> jsonColumns(definition);
|
||||
case "PROTOBUF" -> protobufColumns(definition);
|
||||
default -> List.of();
|
||||
};
|
||||
} catch (RuntimeException e) {
|
||||
LOG.warnv("Failed to convert {0} schema to columns: {1}", dataFormat, e.getMessage());
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Avro -----------------------------------------------------------
|
||||
|
||||
private static List<Column> avroColumns(String definition) {
|
||||
Schema schema = new Schema.Parser().parse(definition);
|
||||
if (schema.getType() != Schema.Type.RECORD) {
|
||||
return List.of();
|
||||
}
|
||||
List<Column> out = new ArrayList<>(schema.getFields().size());
|
||||
for (Schema.Field field : schema.getFields()) {
|
||||
out.add(new Column(field.name(), avroToHive(field.schema())));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static String avroToHive(Schema s) {
|
||||
String logical = avroLogicalTypeToHive(s);
|
||||
if (logical != null) {
|
||||
return logical;
|
||||
}
|
||||
return switch (s.getType()) {
|
||||
case LONG -> "bigint";
|
||||
case INT -> "int";
|
||||
case STRING, ENUM -> "string";
|
||||
case BOOLEAN -> "boolean";
|
||||
case DOUBLE -> "double";
|
||||
case FLOAT -> "float";
|
||||
case BYTES, FIXED -> "binary";
|
||||
case NULL -> "string";
|
||||
case UNION -> avroUnionToHive(s);
|
||||
case RECORD -> avroRecordToHive(s);
|
||||
case ARRAY -> "array<" + avroToHive(s.getElementType()) + ">";
|
||||
case MAP -> "map<string," + avroToHive(s.getValueType()) + ">";
|
||||
};
|
||||
}
|
||||
|
||||
private static String avroLogicalTypeToHive(Schema s) {
|
||||
LogicalType logical = s.getLogicalType();
|
||||
if (logical == null) {
|
||||
return null;
|
||||
}
|
||||
if (logical instanceof LogicalTypes.Decimal d) {
|
||||
return "decimal(" + d.getPrecision() + "," + d.getScale() + ")";
|
||||
}
|
||||
return switch (logical.getName()) {
|
||||
case "date" -> "date";
|
||||
case "timestamp-millis", "timestamp-micros",
|
||||
"local-timestamp-millis", "local-timestamp-micros" -> "timestamp";
|
||||
// Hive has no TIME type — surface as string so downstream readers see the raw value.
|
||||
case "time-millis", "time-micros", "uuid" -> "string";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private static String avroUnionToHive(Schema s) {
|
||||
List<Schema> types = s.getTypes();
|
||||
if (types.size() == 2) {
|
||||
if (types.get(0).getType() == Schema.Type.NULL) return avroToHive(types.get(1));
|
||||
if (types.get(1).getType() == Schema.Type.NULL) return avroToHive(types.get(0));
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
private static String avroRecordToHive(Schema s) {
|
||||
StringBuilder sb = new StringBuilder("struct<");
|
||||
boolean first = true;
|
||||
for (Schema.Field f : s.getFields()) {
|
||||
if (!first) sb.append(",");
|
||||
sb.append(f.name()).append(":").append(avroToHive(f.schema()));
|
||||
first = false;
|
||||
}
|
||||
return sb.append(">").toString();
|
||||
}
|
||||
|
||||
// ---- JSON Schema ----------------------------------------------------
|
||||
|
||||
private static List<Column> jsonColumns(String definition) {
|
||||
JsonNode root;
|
||||
try {
|
||||
root = MAPPER.readTree(definition);
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Invalid JSON Schema: {0}", e.getMessage());
|
||||
return List.of();
|
||||
}
|
||||
if (!"object".equals(root.path("type").asText())) {
|
||||
return List.of();
|
||||
}
|
||||
JsonNode properties = root.get("properties");
|
||||
if (properties == null || !properties.isObject()) {
|
||||
return List.of();
|
||||
}
|
||||
List<Column> out = new ArrayList<>();
|
||||
for (Iterator<Map.Entry<String, JsonNode>> it = properties.fields(); it.hasNext(); ) {
|
||||
Map.Entry<String, JsonNode> e = it.next();
|
||||
out.add(new Column(e.getKey(), jsonToHive(e.getValue())));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static String jsonToHive(JsonNode node) {
|
||||
String t = node.path("type").asText("string");
|
||||
return switch (t) {
|
||||
case "string" -> "string";
|
||||
case "integer" -> "bigint";
|
||||
case "number" -> "double";
|
||||
case "boolean" -> "boolean";
|
||||
case "array" -> {
|
||||
JsonNode items = node.get("items");
|
||||
yield "array<" + (items != null && items.isObject() ? jsonToHive(items) : "string") + ">";
|
||||
}
|
||||
case "object" -> jsonObjectToHive(node);
|
||||
default -> "string";
|
||||
};
|
||||
}
|
||||
|
||||
private static String jsonObjectToHive(JsonNode node) {
|
||||
JsonNode properties = node.get("properties");
|
||||
if (properties == null || !properties.isObject() || !properties.fields().hasNext()) {
|
||||
return "struct<>";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("struct<");
|
||||
boolean first = true;
|
||||
for (Iterator<Map.Entry<String, JsonNode>> it = properties.fields(); it.hasNext(); ) {
|
||||
Map.Entry<String, JsonNode> e = it.next();
|
||||
if (!first) sb.append(",");
|
||||
sb.append(e.getKey()).append(":").append(jsonToHive(e.getValue()));
|
||||
first = false;
|
||||
}
|
||||
return sb.append(">").toString();
|
||||
}
|
||||
|
||||
// ---- Protobuf (parsed via Wire — bypasses Apicurio's well-known-deps issue) -------
|
||||
|
||||
private static List<Column> protobufColumns(String definition) {
|
||||
ProtoFileElement file;
|
||||
try {
|
||||
Location loc = Location.get("schema.proto");
|
||||
file = new ProtoParser(loc, definition.toCharArray()).readProtoFile();
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Invalid Protobuf schema: {0}", e.getMessage());
|
||||
return List.of();
|
||||
}
|
||||
MessageElement target = firstMessage(file.getTypes());
|
||||
if (target == null) {
|
||||
return List.of();
|
||||
}
|
||||
Map<String, MessageElement> nestedByName = collectMessages(file.getTypes(), new HashMap<>());
|
||||
List<Column> out = new ArrayList<>(target.getFields().size());
|
||||
for (FieldElement f : target.getFields()) {
|
||||
out.add(new Column(f.getName(), protobufToHive(f, nestedByName)));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static MessageElement firstMessage(List<TypeElement> types) {
|
||||
for (TypeElement t : types) {
|
||||
if (t instanceof MessageElement m) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Map<String, MessageElement> collectMessages(List<TypeElement> types, Map<String, MessageElement> acc) {
|
||||
for (TypeElement t : types) {
|
||||
if (t instanceof MessageElement m) {
|
||||
acc.put(m.getName(), m);
|
||||
collectMessages(m.getNestedTypes(), acc);
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
private static String protobufToHive(FieldElement field, Map<String, MessageElement> messages) {
|
||||
String base = protobufBaseTypeToHive(field.getType(), messages);
|
||||
return field.getLabel() == Field.Label.REPEATED ? "array<" + base + ">" : base;
|
||||
}
|
||||
|
||||
private static String protobufBaseTypeToHive(String type, Map<String, MessageElement> messages) {
|
||||
if (type.startsWith("map<") && type.endsWith(">")) {
|
||||
// Wire preserves the literal "map<key, value>" syntax in field types.
|
||||
String inner = type.substring(4, type.length() - 1);
|
||||
int comma = inner.indexOf(',');
|
||||
if (comma > 0) {
|
||||
String valueType = inner.substring(comma + 1).trim();
|
||||
return "map<string," + protobufBaseTypeToHive(valueType, messages) + ">";
|
||||
}
|
||||
return "map<string,string>";
|
||||
}
|
||||
return switch (type) {
|
||||
case "int32", "uint32", "sint32", "fixed32", "sfixed32" -> "int";
|
||||
case "int64", "uint64", "sint64", "fixed64", "sfixed64" -> "bigint";
|
||||
case "float" -> "float";
|
||||
case "double" -> "double";
|
||||
case "bool" -> "boolean";
|
||||
case "string" -> "string";
|
||||
case "bytes" -> "binary";
|
||||
default -> {
|
||||
MessageElement nested = messages.get(type);
|
||||
yield nested != null ? protobufMessageToHive(nested, messages) : "string";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static String protobufMessageToHive(MessageElement msg, Map<String, MessageElement> messages) {
|
||||
StringBuilder sb = new StringBuilder("struct<");
|
||||
boolean first = true;
|
||||
for (FieldElement f : msg.getFields()) {
|
||||
if (!first) sb.append(",");
|
||||
sb.append(f.getName()).append(":").append(protobufToHive(f, messages));
|
||||
first = false;
|
||||
}
|
||||
return sb.append(">").toString();
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class MetadataInfo {
|
||||
|
||||
@JsonProperty("MetadataValue")
|
||||
private String metadataValue;
|
||||
|
||||
@JsonProperty("CreatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant createdTime;
|
||||
|
||||
@JsonProperty("OtherMetadataValueList")
|
||||
private List<OtherMetadataValueListItem> otherMetadataValueList;
|
||||
|
||||
public MetadataInfo() {}
|
||||
|
||||
public MetadataInfo(String metadataValue, Instant createdTime) {
|
||||
this.metadataValue = metadataValue;
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public String getMetadataValue() { return metadataValue; }
|
||||
public void setMetadataValue(String metadataValue) { this.metadataValue = metadataValue; }
|
||||
|
||||
public Instant getCreatedTime() { return createdTime; }
|
||||
public void setCreatedTime(Instant createdTime) { this.createdTime = createdTime; }
|
||||
|
||||
public List<OtherMetadataValueListItem> getOtherMetadataValueList() { return otherMetadataValueList; }
|
||||
public void setOtherMetadataValueList(List<OtherMetadataValueListItem> otherMetadataValueList) {
|
||||
this.otherMetadataValueList = otherMetadataValueList;
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class OtherMetadataValueListItem {
|
||||
@JsonProperty("MetadataValue")
|
||||
private String metadataValue;
|
||||
|
||||
@JsonProperty("CreatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant createdTime;
|
||||
|
||||
public OtherMetadataValueListItem() {}
|
||||
|
||||
public OtherMetadataValueListItem(String metadataValue, Instant createdTime) {
|
||||
this.metadataValue = metadataValue;
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public String getMetadataValue() { return metadataValue; }
|
||||
public void setMetadataValue(String metadataValue) { this.metadataValue = metadataValue; }
|
||||
|
||||
public Instant getCreatedTime() { return createdTime; }
|
||||
public void setCreatedTime(Instant createdTime) { this.createdTime = createdTime; }
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Registry {
|
||||
|
||||
@JsonProperty("RegistryName")
|
||||
private String registryName;
|
||||
|
||||
@JsonProperty("RegistryArn")
|
||||
private String registryArn;
|
||||
|
||||
@JsonProperty("Description")
|
||||
private String description;
|
||||
|
||||
@JsonProperty("Status")
|
||||
private String status;
|
||||
|
||||
@JsonProperty("CreatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant createdTime;
|
||||
|
||||
@JsonProperty("UpdatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant updatedTime;
|
||||
|
||||
@JsonProperty("Tags")
|
||||
private Map<String, String> tags;
|
||||
|
||||
public Registry() {}
|
||||
|
||||
public Registry(String registryName) {
|
||||
this.registryName = registryName;
|
||||
this.createdTime = Instant.now();
|
||||
this.updatedTime = this.createdTime;
|
||||
this.status = "AVAILABLE";
|
||||
}
|
||||
|
||||
public String getRegistryName() { return registryName; }
|
||||
public void setRegistryName(String registryName) { this.registryName = registryName; }
|
||||
|
||||
public String getRegistryArn() { return registryArn; }
|
||||
public void setRegistryArn(String registryArn) { this.registryArn = registryArn; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
|
||||
public Instant getCreatedTime() { return createdTime; }
|
||||
public void setCreatedTime(Instant createdTime) { this.createdTime = createdTime; }
|
||||
|
||||
public Instant getUpdatedTime() { return updatedTime; }
|
||||
public void setUpdatedTime(Instant updatedTime) { this.updatedTime = updatedTime; }
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RegistryId {
|
||||
|
||||
@JsonProperty("RegistryName")
|
||||
private String registryName;
|
||||
|
||||
@JsonProperty("RegistryArn")
|
||||
private String registryArn;
|
||||
|
||||
public RegistryId() {}
|
||||
|
||||
public RegistryId(String registryName, String registryArn) {
|
||||
this.registryName = registryName;
|
||||
this.registryArn = registryArn;
|
||||
}
|
||||
|
||||
public String getRegistryName() { return registryName; }
|
||||
public void setRegistryName(String registryName) { this.registryName = registryName; }
|
||||
|
||||
public String getRegistryArn() { return registryArn; }
|
||||
public void setRegistryArn(String registryArn) { this.registryArn = registryArn; }
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Schema {
|
||||
|
||||
@JsonProperty("RegistryName")
|
||||
private String registryName;
|
||||
|
||||
@JsonProperty("RegistryArn")
|
||||
private String registryArn;
|
||||
|
||||
@JsonProperty("SchemaName")
|
||||
private String schemaName;
|
||||
|
||||
@JsonProperty("SchemaArn")
|
||||
private String schemaArn;
|
||||
|
||||
@JsonProperty("Description")
|
||||
private String description;
|
||||
|
||||
@JsonProperty("DataFormat")
|
||||
private String dataFormat;
|
||||
|
||||
@JsonProperty("Compatibility")
|
||||
private String compatibility;
|
||||
|
||||
@JsonProperty("SchemaStatus")
|
||||
private String schemaStatus;
|
||||
|
||||
@JsonProperty("SchemaCheckpoint")
|
||||
private Long schemaCheckpoint;
|
||||
|
||||
@JsonProperty("LatestSchemaVersion")
|
||||
private Long latestSchemaVersion;
|
||||
|
||||
@JsonProperty("NextSchemaVersion")
|
||||
private Long nextSchemaVersion;
|
||||
|
||||
@JsonProperty("CreatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant createdTime;
|
||||
|
||||
@JsonProperty("UpdatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant updatedTime;
|
||||
|
||||
@JsonProperty("Tags")
|
||||
private Map<String, String> tags;
|
||||
|
||||
public Schema() {}
|
||||
|
||||
public String getRegistryName() { return registryName; }
|
||||
public void setRegistryName(String registryName) { this.registryName = registryName; }
|
||||
|
||||
public String getRegistryArn() { return registryArn; }
|
||||
public void setRegistryArn(String registryArn) { this.registryArn = registryArn; }
|
||||
|
||||
public String getSchemaName() { return schemaName; }
|
||||
public void setSchemaName(String schemaName) { this.schemaName = schemaName; }
|
||||
|
||||
public String getSchemaArn() { return schemaArn; }
|
||||
public void setSchemaArn(String schemaArn) { this.schemaArn = schemaArn; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public String getDataFormat() { return dataFormat; }
|
||||
public void setDataFormat(String dataFormat) { this.dataFormat = dataFormat; }
|
||||
|
||||
public String getCompatibility() { return compatibility; }
|
||||
public void setCompatibility(String compatibility) { this.compatibility = compatibility; }
|
||||
|
||||
public String getSchemaStatus() { return schemaStatus; }
|
||||
public void setSchemaStatus(String schemaStatus) { this.schemaStatus = schemaStatus; }
|
||||
|
||||
public Long getSchemaCheckpoint() { return schemaCheckpoint; }
|
||||
public void setSchemaCheckpoint(Long schemaCheckpoint) { this.schemaCheckpoint = schemaCheckpoint; }
|
||||
|
||||
public Long getLatestSchemaVersion() { return latestSchemaVersion; }
|
||||
public void setLatestSchemaVersion(Long latestSchemaVersion) { this.latestSchemaVersion = latestSchemaVersion; }
|
||||
|
||||
public Long getNextSchemaVersion() { return nextSchemaVersion; }
|
||||
public void setNextSchemaVersion(Long nextSchemaVersion) { this.nextSchemaVersion = nextSchemaVersion; }
|
||||
|
||||
public Instant getCreatedTime() { return createdTime; }
|
||||
public void setCreatedTime(Instant createdTime) { this.createdTime = createdTime; }
|
||||
|
||||
public Instant getUpdatedTime() { return updatedTime; }
|
||||
public void setUpdatedTime(Instant updatedTime) { this.updatedTime = updatedTime; }
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SchemaId {
|
||||
|
||||
@JsonProperty("SchemaArn")
|
||||
private String schemaArn;
|
||||
|
||||
@JsonProperty("SchemaName")
|
||||
private String schemaName;
|
||||
|
||||
@JsonProperty("RegistryName")
|
||||
private String registryName;
|
||||
|
||||
public SchemaId() {}
|
||||
|
||||
public SchemaId(String registryName, String schemaName, String schemaArn) {
|
||||
this.registryName = registryName;
|
||||
this.schemaName = schemaName;
|
||||
this.schemaArn = schemaArn;
|
||||
}
|
||||
|
||||
public String getSchemaArn() { return schemaArn; }
|
||||
public void setSchemaArn(String schemaArn) { this.schemaArn = schemaArn; }
|
||||
|
||||
public String getSchemaName() { return schemaName; }
|
||||
public void setSchemaName(String schemaName) { this.schemaName = schemaName; }
|
||||
|
||||
public String getRegistryName() { return registryName; }
|
||||
public void setRegistryName(String registryName) { this.registryName = registryName; }
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package io.github.hectorvent.floci.services.glue.schemaregistry.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SchemaVersion {
|
||||
|
||||
@JsonProperty("SchemaVersionId")
|
||||
private String schemaVersionId;
|
||||
|
||||
@JsonProperty("SchemaArn")
|
||||
private String schemaArn;
|
||||
|
||||
@JsonProperty("VersionNumber")
|
||||
private Long versionNumber;
|
||||
|
||||
@JsonProperty("Status")
|
||||
private String status;
|
||||
|
||||
@JsonProperty("SchemaDefinition")
|
||||
private String schemaDefinition;
|
||||
|
||||
@JsonProperty("DataFormat")
|
||||
private String dataFormat;
|
||||
|
||||
@JsonProperty("CreatedTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Instant createdTime;
|
||||
|
||||
public SchemaVersion() {}
|
||||
|
||||
public String getSchemaVersionId() { return schemaVersionId; }
|
||||
public void setSchemaVersionId(String schemaVersionId) { this.schemaVersionId = schemaVersionId; }
|
||||
|
||||
public String getSchemaArn() { return schemaArn; }
|
||||
public void setSchemaArn(String schemaArn) { this.schemaArn = schemaArn; }
|
||||
|
||||
public Long getVersionNumber() { return versionNumber; }
|
||||
public void setVersionNumber(Long versionNumber) { this.versionNumber = versionNumber; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
|
||||
public String getSchemaDefinition() { return schemaDefinition; }
|
||||
public void setSchemaDefinition(String schemaDefinition) { this.schemaDefinition = schemaDefinition; }
|
||||
|
||||
public String getDataFormat() { return dataFormat; }
|
||||
public void setDataFormat(String dataFormat) { this.dataFormat = dataFormat; }
|
||||
|
||||
public Instant getCreatedTime() { return createdTime; }
|
||||
public void setCreatedTime(Instant createdTime) { this.createdTime = createdTime; }
|
||||
}
|
||||
Reference in new issue
Block a user