Skip to content
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

Update documentation #43

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
out/
build
.gradle
/gradle/wrapper/gradle-wrapper.jar
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,31 @@ Our library is using Jackson for (de)serialization so, objects that you are pass

### Query for document
```java
OpaQueryApi client = OpaClient.builder()
.opaConfiguration("http://localhost:8181")
.build();
OpaQueryApi client = OpaClient.builder()
.opaConfiguration("http://localhost:8181")
.build();

DesiredResponse response = client.queryForDocument(new QueryForDocumentRequest(yourDTO, "path/to/document"), DesiredResponse.class);
DesiredResponse response = client.queryForDocument(new QueryForDocumentRequest(yourDTO, "path/to/document"), DesiredResponse.class);

// Do whatever you like with the response
```

### Query for a list of documents

This requires [commons-lang3](https://mvnrepository.com/artifact/org.apache.commons/commons-lang3) to be present on your classpath.

```java
OpaQueryApi client = OpaClient.builder()
.opaConfiguration("http://localhost:8181")
.build();

ParameterizedType type = TypeUtils.parameterize(List.class, DesiredResponse.class);

// Do whatever you like with the response
List<DesiredResponse> response = client.queryForDocument(new QueryForDocumentRequest(yourDTO, "path/to/document"), type);

// Do whatever you like with the response
```

####Example
Example project is in `examples/query-for-document` directory.
### Create policy
Expand Down
2 changes: 1 addition & 1 deletion examples/query-for-document/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
}

dependencies {
implementation("com.bisnode.opa:opa-java-client:0.0.2")
implementation("com.bisnode.opa:opa-java-client:0.3.0")
implementation("org.slf4j:slf4j-simple:1.7.30")

testImplementation("org.codehaus.groovy:groovy-all:2.5.13")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,9 @@ class QueryingForDocumentSpec extends Specification {
when:

def type = TypeUtils.parameterize(List.class,ValidationResult.class);
def result = client.queryForDocument(new QueryForDocumentRequest([shouldPass: true], path), type)
List<ValidationResult> result = client.queryForDocument(new QueryForDocumentRequest([shouldPass: true], path), type)
then:
def element = result[0]
element.getClass() == ValidationResult.class
ValidationResult element = result[0]
element.allow
}

Expand Down
Loading