-
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.
ARC-1699: Spicegen gRPC client binding (#2)
* ARC-1699: Added SpiceDB binding and example * ARC-1699: Update CODEOWNERS * ARC-1699: Better README * ARC-1699: Removed copy paste leftovers.
- Loading branch information
1 parent
c0ffeeb
commit 365d857
Showing
37 changed files
with
1,545 additions
and
82 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 @@ | ||
* [email protected] [email protected] [email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
package com.oviva.spicegen.api; | ||
|
||
import com.oviva.spicegen.api.internal.SimpleObjectRef; | ||
|
||
public interface ObjectRef { | ||
String kind(); | ||
|
||
String id(); | ||
|
||
static ObjectRef of(String kind, String id) { | ||
return SimpleObjectRef.of(kind, id); | ||
return new ObjectRef() { | ||
@Override | ||
public String kind() { | ||
return kind; | ||
} | ||
|
||
@Override | ||
public String id() { | ||
return id; | ||
} | ||
}; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
api/src/main/java/com/oviva/spicegen/api/PermissionService.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,15 @@ | ||
package com.oviva.spicegen.api; | ||
|
||
public interface PermissionService { | ||
|
||
/** | ||
* Updates relationships, optionally with preconditions. The returned consistencyToken should be | ||
* stored alongside the created resource such that the authorization can be done at the given | ||
* consistency. This vastly improves the performance and allows the system to function even when | ||
* it is partitioned. | ||
* | ||
* @param updateRelationships the request | ||
* @return the result, containing the consistencyToken | ||
*/ | ||
UpdateResult updateRelationships(UpdateRelationships updateRelationships); | ||
} |
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,5 @@ | ||
package com.oviva.spicegen.api; | ||
|
||
public interface UpdateResult { | ||
String consistencyToken(); | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/oviva/spicegen/api/exceptions/AuthenticationException.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,11 @@ | ||
package com.oviva.spicegen.api.exceptions; | ||
|
||
public class AuthenticationException extends ClientException { | ||
public AuthenticationException(String message) { | ||
super(message); | ||
} | ||
|
||
public AuthenticationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/oviva/spicegen/api/exceptions/AuthorizationException.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,11 @@ | ||
package com.oviva.spicegen.api.exceptions; | ||
|
||
public class AuthorizationException extends ClientException { | ||
public AuthorizationException(String message) { | ||
super(message); | ||
} | ||
|
||
public AuthorizationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/oviva/spicegen/api/exceptions/ClientException.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,11 @@ | ||
package com.oviva.spicegen.api.exceptions; | ||
|
||
public class ClientException extends RuntimeException { | ||
public ClientException(String message) { | ||
super(message); | ||
} | ||
|
||
public ClientException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/oviva/spicegen/api/exceptions/ConflictException.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,11 @@ | ||
package com.oviva.spicegen.api.exceptions; | ||
|
||
public class ConflictException extends ClientException { | ||
public ConflictException(String message) { | ||
super(message); | ||
} | ||
|
||
public ConflictException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/com/oviva/spicegen/api/exceptions/ValidationException.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,11 @@ | ||
package com.oviva.spicegen.api.exceptions; | ||
|
||
public class ValidationException extends ClientException { | ||
public ValidationException(String message) { | ||
super(message); | ||
} | ||
|
||
public ValidationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
api/src/main/java/com/oviva/spicegen/api/internal/SimpleObjectRef.java
This file was deleted.
Oops, something went wrong.
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,69 @@ | ||
# Spicegen Example | ||
|
||
## Code | ||
See [ExampleTest](./src/test/java/com/oviva/spicegen/example/ExampleTest.java). | ||
|
||
|
||
## Maven Setup | ||
Example [pom.xml](./pom.xml) | ||
```xml | ||
<project> | ||
|
||
<!-- ... --> | ||
|
||
<!-- see https://docs.github.com/de/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registr<!––>y--> | ||
<repositories> | ||
<repository> | ||
<id>spicegen</id> | ||
<name>GitHub Oviva Spicegen</name> | ||
<url>https://maven.pkg.github.com/oviva-ag/spicegen</url> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>spicegen</id> | ||
<name>GitHub Oviva Spicegen Plugin</name> | ||
<url>https://maven.pkg.github.com/oviva-ag/spicegen</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<!-- ... --> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>api</artifactId> | ||
<version>...</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>spicedb-binding</artifactId> | ||
<version>...</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!-- ... --> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>spicegen-maven-plugin</artifactId> | ||
<version>${project.version}</version> | ||
<executions> | ||
<execution> | ||
<configuration> | ||
<schemaPath>${project.basedir}/src/test/resources/files.zed</schemaPath> | ||
<packageName>${project.groupId}.permissions</packageName> | ||
<outputDirectory>${project.basedir}/target/generated-sources/src/main/java</outputDirectory> | ||
</configuration> | ||
<goals> | ||
<goal>spicegen</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
``` |
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,120 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>spicegen-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>Permissions Generator Example</name> | ||
<artifactId>example</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>spicedb-binding</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>versions-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.diffplug.spotless</groupId> | ||
<artifactId>spotless-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<excludedGroups>integration</excludedGroups> | ||
<argLine> | ||
${argLine} | ||
</argLine> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>integration-tests</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<excludedGroups>!integration</excludedGroups> | ||
<groups>integration</groups> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.oviva.spicegen</groupId> | ||
<artifactId>spicegen-maven-plugin</artifactId> | ||
<version>${project.version}</version> | ||
<executions> | ||
<execution> | ||
<configuration> | ||
<schemaPath>${project.basedir}/src/test/resources/files.zed</schemaPath> | ||
<packageName>${project.groupId}.permissions</packageName> | ||
<outputDirectory>${project.basedir}/target/generated-sources/src/main/java</outputDirectory> | ||
</configuration> | ||
<goals> | ||
<goal>spicegen</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
|
Oops, something went wrong.