☕️ Java
Variants
For the Java clients, the following variants are pre-built:
Aspect | Permutations |
---|---|
Java | 17, 21 |
HTTP lib | feign, resttemplate, webclient, restclient, okhttp-gson |
Version policy
The following version policy will be applied to the Java clients:
# pattern
$artifactVersion-$javaVersion-$spicedbVersion[-SNAPSHOT]
# parts
$artifactVersion := semver (major.minor.patch) of the artifact determined from repo tags
$javaVersion := Java JDK version (from build matrix)
$spicedbVersion := SpiceDB version (from spicedb.version file)
$snapshot := Optional Java snapshot classifier, format '-SNAPSHOT'
# release example
1.0.1-2-v1.1.0
# snapshot example
0.0.1-17-v1.1.0-SNAPSHOT
Snapshots
The Java client library build from the main
branch are deployed to the GitHub Packages registry.
The snapshots can be seen within
the packages view on GiHub.
The snapshots should be immediately available to your build, e.g. by using:
// Gradle example
// only necessary for snapshots final versions will be published to maven central
maven {
url = 'https://maven.pkg.github.com/ewerk/authzed-http-client'
credentials {
username = System.getenv('GITHUB_USER')
password = System.getenv('GITHUB_TOKEN')
}
}
implementation 'com.ewerk.spicedb:authzed-http-client-restclient:0.0.1-21-v1.1.0-SNAPSHOT'
Releases
⚠️ Currently, release pipelines are missing and therefore no packages are published to Maven Central.
Usage
The client can be pretty much used as any HTTP client generated by OpenAPI generator.
ℹ️ The following example is taken from the generated code and might be outdated, as the generated
README.md
is not part of the created and published Java packages. The example is bar far not complete, also it does not apply any best practices (e.g. logging)
import com.ewerk.spicedb.authzed.http.*;
import com.ewerk.spicedb.authzed.http.auth.*;
import com.ewerk.spicedb.authzed.http.model.*;
import com.ewerk.spicedb.authzed.http.client.ExperimentalServiceApi;
public final class ExperimentalServiceApiExample {
public static void main(String[] args) {
var defaultClient = new ApiClient();
defaultClient.setBasePath("http://localhost");
var apiInstance = new ExperimentalServiceApi(defaultClient);
// NOTE: Deprecated now that BulkCheckPermission has been promoted
// to the stable API as "CheckBulkPermission".
var body = new V1BulkCheckPermissionRequest();
try {
var result = apiInstance.experimentalServiceBulkCheckPermission(body);
System.out.println(result);
} catch (HttpStatusCodeException cause) {
System.err.println("Exception occurred");
System.err.println("Status code: " + cause.getStatusCode().value());
System.err.println("Reason: " + cause.getResponseBodyAsString());
System.err.println("Response headers: " + cause.getResponseHeaders());
cause.printStackTrace();
}
}
}