{"id":13787781,"url":"https://github.com/Bisnode/opa-java-client","last_synced_at":"2025-05-12T01:31:36.684Z","repository":{"id":41966022,"uuid":"236950603","full_name":"Bisnode/opa-java-client","owner":"Bisnode","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-28T01:43:26.000Z","size":202,"stargazers_count":36,"open_issues_count":9,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-07T01:45:48.923Z","etag":null,"topics":["java","javaclient","opa","openpolicyagent"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bisnode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-29T09:56:34.000Z","updated_at":"2024-07-31T10:33:39.000Z","dependencies_parsed_at":"2024-07-31T11:55:46.064Z","dependency_job_id":null,"html_url":"https://github.com/Bisnode/opa-java-client","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-java-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-java-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-java-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-java-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bisnode","download_url":"https://codeload.github.com/Bisnode/opa-java-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253659373,"owners_count":21943627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","javaclient","opa","openpolicyagent"],"created_at":"2024-08-03T21:00:30.836Z","updated_at":"2025-05-12T01:31:36.305Z","avatar_url":"https://github.com/Bisnode.png","language":"Java","readme":"# opa-java-client\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.bisnode.opa/opa-java-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.bisnode.opa/opa-java-client) ![build](https://github.com/Bisnode/opa-java-client/workflows/build/badge.svg)\n\nOPA java client is a wrapper for [OPA REST API](https://www.openpolicyagent.org/docs/latest/rest-api/). The goal was to create client that is lightweight and framework independent. It's built for current Bisnode needs, including:\n - creating documents\n - creating policies\n - querying for documents\n## Installation\n**Prerequisites:** Java 11 or higher\n\nAdd library using maven:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.bisnode.opa\u003c/groupId\u003e\n    \u003cartifactId\u003eopa-java-client\u003c/artifactId\u003e\n    \u003cversion\u003e{version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\nor Gradle\n```groovy\nimplementation 'com.bisnode.opa:opa-java-client:{version}'\n```\n\n## Usage\nOur library is using Jackson for (de)serialization so, objects that you are passing/retrieving using this client should have either proper Jackson-friendly configuration or - the solution working in most cases - getters and setters for fields you want to pass/retrieve to/from OPA. \n [More information about Jackson](https://github.com/FasterXML/jackson-docs).\n\n### Query for document\n```java\nOpaQueryApi client = OpaClient.builder()\n                        .opaConfiguration(\"http://localhost:8181\")\n                        .build();\n\nDesiredResponse response = client.queryForDocument(new QueryForDocumentRequest(yourDTO, \"path/to/document\"), DesiredResponse.class);\n\n// Do whatever you like with the response\n```\n\n### Query for a list of documents\n\nThis requires [commons-lang3](https://mvnrepository.com/artifact/org.apache.commons/commons-lang3) to be present on your classpath.\n\n```java\nOpaQueryApi client = OpaClient.builder()\n        .opaConfiguration(\"http://localhost:8181\")\n        .build();\n        \nParameterizedType type = TypeUtils.parameterize(List.class, DesiredResponse.class);\n        \nList\u003cDesiredResponse\u003e response = client.queryForDocument(new QueryForDocumentRequest(yourDTO, \"path/to/document\"), type);\n\n// Do whatever you like with the response\n```\n\n####Example\nExample project is in `examples/query-for-document` directory.\n### Create policy\n```java\n        OpaPolicyApi client = OpaClient.builder()\n                                     .opaConfiguration(\"http://localhost:8181\")\n                                     .build();\n\n        void createOrUpdatePolicy(new OpaPolicy(\"your_policy_id\", \"content of the policy\"));\n```\n### Create document\n```java\n        OpaDataApi client = OpaClient.builder()\n                                     .opaConfiguration(\"http://localhost:8181\")\n                                     .build();\n\n        void createOrOverwriteDocument(new OpaDocument(\"path/to/document\", \"content of document (json)\"));\n```\n\n### Error handling\nError handling is done via exceptions. This means that if any error occurs, runtime exception which is subclass of `OpaClientException` is thrown. For now, there is simple error message returned.\n\n`OpaServerConnectionException` is thrown when connection problems with OPA server occur.\n\n### Interface segregation\nEvery OPA (Data, Policy, Query) API has it's own interface. So, for example, if you want to use client only for querying, you can use `OpaQueryApi` as projection. Thanks to that, in your code there will be exposed only methods that are needed by you, while not allowing to mess with policies and data.\n\nAvailable interface projections:\n- `OpaQueryApi`\n- `OpaPolicyApi`\n- `OpaDataApi`\n\n## Developing and building\nBuild process and dependency management is done using Gradle.\nTests are written in spock.\n\n## Contribution\n\nInterested in contributing? Please, start by reading [this document](https://github.com/Bisnode/opa-java-client/blob/master/CONTRIBUTING.md).\n","funding_links":[],"categories":["Language and Platform Integrations"],"sub_categories":["Java"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBisnode%2Fopa-java-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBisnode%2Fopa-java-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBisnode%2Fopa-java-client/lists"}