Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,30 @@ public Dek createDek(
String kekName,
CreateDekRequest request)
throws IOException, RestClientException {
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks/{subject}");
String path = builder.build(kekName, request.getSubject()).toString();

return httpRequest(
path, "POST",
request.toJson().getBytes(StandardCharsets.UTF_8),
requestProperties,
DEK_TYPE);
try {
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks/{subject}");
String path = builder.build(kekName, request.getSubject()).toString();

return httpRequest(
path, "POST",
request.toJson().getBytes(StandardCharsets.UTF_8),
requestProperties,
DEK_TYPE);
} catch (RestClientException e) {
if (e.getErrorCode() == 405) {
// Try fallback to older API that does not have subject in the path
UriBuilder builder = UriBuilder.fromPath("/dek-registry/v1/keks/{name}/deks");
String path = builder.build(kekName).toString();

return httpRequest(
path, "POST",
request.toJson().getBytes(StandardCharsets.UTF_8),
requestProperties,
DEK_TYPE);
} else {
throw e;
}
}
}

public Kek updateKek(String name, UpdateKekRequest request)
Expand Down