-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARC-1699: Spicegen gRPC client binding #2
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a full example. Testing with generated sources directly is a bit problematic, because support for generated test-sources is a bit lackluster ;) |
||
<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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can extend in the future with e.g. checks etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically a copy of https://github.com/oviva-ag/permissions/blob/main/api/src/main/java/com/oviva/permissions/api/PermissionService.java if I understood it correctly?