File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
dek-registry-client/src/main/java/io/confluent/dekregistry/client/rest Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -264,14 +264,30 @@ public Dek createDek(
264264 String kekName ,
265265 CreateDekRequest request )
266266 throws IOException , RestClientException {
267- UriBuilder builder = UriBuilder .fromPath ("/dek-registry/v1/keks/{name}/deks/{subject}" );
268- String path = builder .build (kekName , request .getSubject ()).toString ();
269-
270- return httpRequest (
271- path , "POST" ,
272- request .toJson ().getBytes (StandardCharsets .UTF_8 ),
273- requestProperties ,
274- DEK_TYPE );
267+ try {
268+ UriBuilder builder = UriBuilder .fromPath ("/dek-registry/v1/keks/{name}/deks/{subject}" );
269+ String path = builder .build (kekName , request .getSubject ()).toString ();
270+
271+ return httpRequest (
272+ path , "POST" ,
273+ request .toJson ().getBytes (StandardCharsets .UTF_8 ),
274+ requestProperties ,
275+ DEK_TYPE );
276+ } catch (RestClientException e ) {
277+ if (e .getErrorCode () == 405 ) {
278+ // Try fallback to older API that does not have subject in the path
279+ UriBuilder builder = UriBuilder .fromPath ("/dek-registry/v1/keks/{name}/deks" );
280+ String path = builder .build (kekName ).toString ();
281+
282+ return httpRequest (
283+ path , "POST" ,
284+ request .toJson ().getBytes (StandardCharsets .UTF_8 ),
285+ requestProperties ,
286+ DEK_TYPE );
287+ } else {
288+ throw e ;
289+ }
290+ }
275291 }
276292
277293 public Kek updateKek (String name , UpdateKekRequest request )
You can’t perform that action at this time.
0 commit comments