forked from projectnessie/nessie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add v2 REST endpoints. Add java client implementation for v2 REST API. Since namespaces are treated as ordinary content objects in API v2 the old java client API for dealing with namespaces is implemented on the client side on top of v2 "get entries" and "commit" APIs. Run in-memory REST server tests for both v1 and v2 APIs. REST test using persistent backend only use v2 API. Resteasy test remain on v1 API since they construct REST requests according to Nessie API v1 specs. OpenAPI YAML is built and published only for v2. OpenAPI for v1 should be obtained from older Nessie publications. This is the main contribution towards projectnessie#5112
- Loading branch information
Showing
73 changed files
with
4,320 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
clients/client/src/main/java/org/projectnessie/client/api/NessieApiV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (C) 2022 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.client.api; | ||
|
||
/** | ||
* Interface for the Nessie V2 API implementation. | ||
* | ||
* <p>At the java client level this API uses the same builder classes and model types as API v1, | ||
* however the behaviour of some API methods is different. | ||
* | ||
* <p>Most changes between v1 and v2 exist at the REST level (HTTP). | ||
*/ | ||
public interface NessieApiV2 extends NessieApiV1 {} |
78 changes: 78 additions & 0 deletions
78
clients/client/src/main/java/org/projectnessie/client/http/ApiHttpRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (C) 2022 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.client.http; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* This is a helper class for use with an {@link HttpRequest} that will unwrap the specified | ||
* API-level exceptions from {@link HttpClientException} thrown during the execution of the {@link | ||
* HttpRequest}. | ||
* | ||
* <p>Currently this class supports up to two distinct API-level exception types, but it can easily | ||
* be extended to support more if required. | ||
* | ||
* <p>The exception types to be unwrapped are specifies as arguments to {@link | ||
* HttpRequest#unwrap(Class)} and {@link HttpRequest#unwrap(Class, Class)} calls. | ||
* | ||
* @param <E1> the first API-level exception that should be unwrapped | ||
* @param <E2> the second API-level exception that should be unwrapped | ||
*/ | ||
public class ApiHttpRequest<E1 extends Throwable, E2 extends Throwable> { | ||
private final HttpRequest request; | ||
private final Class<E1> ex1; | ||
private final Class<E2> ex2; | ||
|
||
ApiHttpRequest(HttpRequest request, Class<E1> ex1, Class<E2> ex2) { | ||
this.request = request; | ||
this.ex1 = ex1; | ||
this.ex2 = ex2; | ||
} | ||
|
||
public HttpResponse get() throws E1, E2 { | ||
return unwrap(request::get); | ||
} | ||
|
||
public HttpResponse delete() throws E1, E2 { | ||
return unwrap(request::delete); | ||
} | ||
|
||
public HttpResponse post(Object obj) throws E1, E2 { | ||
return unwrap(() -> request.post(obj)); | ||
} | ||
|
||
public HttpResponse put(Object obj) throws E1, E2 { | ||
return unwrap(() -> request.put(obj)); | ||
} | ||
|
||
private HttpResponse unwrap(Supplier<HttpResponse> action) throws E1, E2 { | ||
try { | ||
return action.get(); | ||
} catch (HttpClientException e) { | ||
Throwable cause = e.getCause(); | ||
|
||
if (ex1.isInstance(cause)) { | ||
throw ex1.cast(cause); | ||
} | ||
|
||
if (ex2.isInstance(cause)) { | ||
throw ex2.cast(cause); | ||
} | ||
|
||
throw e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../client/src/main/java/org/projectnessie/client/http/v2api/BaseHttpOnReferenceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2022 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.client.http.v2api; | ||
|
||
import org.projectnessie.client.api.OnReferenceBuilder; | ||
import org.projectnessie.client.http.HttpClient; | ||
|
||
abstract class BaseHttpOnReferenceRequest<R extends OnReferenceBuilder<R>> extends BaseHttpRequest | ||
implements OnReferenceBuilder<R> { | ||
protected String refName; | ||
protected String hashOnRef; | ||
|
||
protected BaseHttpOnReferenceRequest(HttpClient client) { | ||
super(client); | ||
} | ||
|
||
@Override | ||
public R refName(String refName) { | ||
this.refName = refName; | ||
return (R) this; | ||
} | ||
|
||
@Override | ||
public R hashOnRef(String hashOnRef) { | ||
this.hashOnRef = hashOnRef; | ||
return (R) this; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
clients/client/src/main/java/org/projectnessie/client/http/v2api/BaseHttpRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2022 Dremio | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.projectnessie.client.http.v2api; | ||
|
||
import org.projectnessie.client.http.HttpClient; | ||
|
||
public abstract class BaseHttpRequest { | ||
|
||
protected final HttpClient client; | ||
|
||
protected BaseHttpRequest(HttpClient client) { | ||
this.client = client; | ||
} | ||
} |
Oops, something went wrong.