From c2136d5878ff47cf13d89919bb92b50678d4b329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kami=C5=84ski?= Date: Thu, 4 Nov 2021 19:19:13 +0100 Subject: [PATCH] Update documentation --- .gitignore | 1 + README.md | 27 +++++++++++++++---- build.gradle.kts | 2 +- examples/query-for-document/build.gradle.kts | 2 +- .../opa/client/QueryingForDocumentSpec.groovy | 5 ++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index ff733f4..848709a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +out/ build .gradle /gradle/wrapper/gradle-wrapper.jar diff --git a/README.md b/README.md index 1d8f7a7..9fdb159 100644 --- a/README.md +++ b/README.md @@ -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 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 diff --git a/build.gradle.kts b/build.gradle.kts index 6f31f31..42a5d0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ import org.gradle.api.JavaVersion.VERSION_11 import java.util.* -version = "0.3.1" +version = "0.3.2" group = "com.bisnode.opa" plugins { diff --git a/examples/query-for-document/build.gradle.kts b/examples/query-for-document/build.gradle.kts index 48ea277..a13d8e8 100644 --- a/examples/query-for-document/build.gradle.kts +++ b/examples/query-for-document/build.gradle.kts @@ -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") diff --git a/src/test/groovy/com/bisnode/opa/client/QueryingForDocumentSpec.groovy b/src/test/groovy/com/bisnode/opa/client/QueryingForDocumentSpec.groovy index e47bef9..2d35cf0 100644 --- a/src/test/groovy/com/bisnode/opa/client/QueryingForDocumentSpec.groovy +++ b/src/test/groovy/com/bisnode/opa/client/QueryingForDocumentSpec.groovy @@ -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 result = client.queryForDocument(new QueryForDocumentRequest([shouldPass: true], path), type) then: - def element = result[0] - element.getClass() == ValidationResult.class + ValidationResult element = result[0] element.allow }