Giter VIP home page Giter VIP logo

keto-client-java's Introduction

ory/keto-client-java

This is the official Ory Keto SDK for java.

Please do not make any pull requests against this repository! Its contents are fully auto-generated by the ory/sdk repository. Any changes to this repository will be overwritten on the next CI run!

Installation

Java (Maven Central)

Documentation

Generation

This code base, including this README, is auto-generated using OpenAPI Generator. If you find bugs in the SDK please check if there is an open issue at OpenAPITools/openapi-generator or ory/sdk already before opening an issue here.

Feedback

If you have feedback on how to improve the Ory SDK or are looking to contribute, please open an issue in ory/sdk to discuss your ideas.

Thanks for being a part of the Ory community!

keto-client-java's People

Contributors

aeneasr avatar kevgo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keto-client-java's Issues

IllegalArgumentException when calling ReadApi.getExpand

Preflight checklist

Describe the bug

When calling the getExpand method with parameters from the cat videos example, an IllegalArgumentException (log output below) is thrown.

Code

@Component
public class StartupApplicationListenerExample implements ApplicationListener<ContextRefreshedEvent> {

    private static Logger logger = LoggerFactory.getLogger(StartupApplicationListenerExample.class);

    private final String ketoApiUrl;

    public StartupApplicationListenerExample(@Value("${keto.api.url}") String ketoApiUrl) {
        this.ketoApiUrl = ketoApiUrl;
    }

     @Override
     public void onApplicationEvent(ContextRefreshedEvent event) {

        // Make a call to Keto and expand a tree with all subjects that can view /cats/1.mp4
        ReadApi api = new ReadApi();
        api.setCustomBaseUrl(ketoApiUrl);

        String namespace = "videos";
        String _object = "/cats/1.mp4";
        String relation = "view";
        String subjectId = "*";
        String subjectSetNamespace = null;
        String subjectSetObject = null;
        String subjectSetRelation = null;
        Long maxDepth = null;
        try {

            ExpandTree responseExpand = api.getExpand(namespace, _object, relation, 3L);
            logger.info("Response Expand: {}", responseExpand);
        } catch (ApiException e) {
            logger.info("Response body: {}", e.getResponseBody());
            throw new IllegalStateException("Could not perform API request", e);
        }
    }
}

Relevant line

ExpandTree responseExpand = api.getExpand(namespace, _object, relation, 3L);

Reproducing the bug

  1. Follow the cat video quickstart example here: https://www.ory.sh/docs/keto/quickstart
  2. Call ReadApi.getExpand("videos", "/cats/1.mp4", "view", 3L);
  3. java.lang.IllegalArgumentException: Unexpected value 'union'

Relevant log output

java.lang.IllegalArgumentException: Unexpected value 'union'
	at sh.ory.keto.model.ExpandTree$TypeEnum.fromValue(ExpandTree.java:76) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.model.ExpandTree$TypeEnum$Adapter.read(ExpandTree.java:88) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.model.ExpandTree$TypeEnum$Adapter.read(ExpandTree.java:79) ~[keto-client-0.8.0-alpha.1.jar:na]
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199) ~[gson-2.8.9.jar:na]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[gson-2.8.9.jar:na]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[gson-2.8.9.jar:na]
	at com.google.gson.Gson.fromJson(Gson.java:963) ~[gson-2.8.9.jar:na]
	at com.google.gson.Gson.fromJson(Gson.java:928) ~[gson-2.8.9.jar:na]
	at com.google.gson.Gson.fromJson(Gson.java:877) ~[gson-2.8.9.jar:na]
	at sh.ory.keto.JSON.deserialize(JSON.java:153) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.ApiClient.deserialize(ApiClient.java:845) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.ApiClient.handleResponse(ApiClient.java:1053) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.ApiClient.execute(ApiClient.java:977) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.api.ReadApi.getExpandWithHttpInfo(ReadApi.java:421) ~[keto-client-0.8.0-alpha.1.jar:na]
	at sh.ory.keto.api.ReadApi.getExpand(ReadApi.java:396) ~[keto-client-0.8.0-alpha.1.jar:na]
	at ab.xyz.ketopoc.ketopoc.StartupApplicationListenerExample.onApplicationEvent(StartupApplicationListenerExample.java:51) ~[classes/:na]
	at ab.xyz.ketopoc.ketopoc.StartupApplicationListenerExample.onApplicationEvent(StartupApplicationListenerExample.java:15) ~[classes/:na]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.16.jar:5.3.16]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.4.jar:2.6.4]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.4.jar:2.6.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.4.jar:2.6.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.4.jar:2.6.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.4.jar:2.6.4]
	at ab.xyz.ketopoc.ketopoc.KetoPocApplication.main(KetoPocApplication.java:10) ~[classes/:na]

Relevant configuration

keto.api.url="http://localhost:4466"

Version

Java Client for Ory Keto 0.8.0-alpha.1 (https://search.maven.org/artifact/sh.ory.keto/keto-client/0.8.0-alpha.1/jar)

On which operating system are you observing this issue?

Windows

In which environment are you deploying?

No response

Additional Context

  • ReadApi.getCheck does work from the same class. Everything is set up and running properly.
  • When changing the max depth to 1L, the type of unexpected value changes from union to leaf.
  • When setting max depth to 0L no exception is thrown. Instead the expected empty Expand Tree is returned.
  • The IllegalArgumentException is thrown at ExpandTree.java > public static TypeEnum fromValue(String value) (line 70-77)
    public static TypeEnum fromValue(String value) {
      for (TypeEnum b : TypeEnum.values()) {
        if (b.value.equals(value)) {
          return b;
        }
      }
      throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }
  • Debugging there:
    grafik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.