Skip to content

JavaAPI : missing universe_plugin_list #1228

Closed

Description

@hepiyellow

Hi,

I couldn't find a way to get the list of universes using the Java API.
I did find the son API for it: universe_plugin_list
And I didn't find the RPC documentation in order to see if such an API call exist with RPC (in which case I could implement the Java RPC for it in OlaClient.java)

Any help here?
Am I missing something?

Thanks,
Erez

Activity

  1. peternewman commented on Apr 21, 2017

    @peternewman
    Member

    You want getPlugins. See the C++ code for the JSON API:

    int OladHTTPServer::JsonUniversePluginList(const HTTPRequest*,

  2. peternewman commented on Apr 21, 2017

    @peternewman
    Member
  3. hepiyellow commented on Apr 21, 2017

    @hepiyellow
    ContributorAuthor

    Well, I tried the Java version of getPlugins(), which returns the PluginListReply object, which doesn't seem to have a universe list.

    Also looking at the common/protocol/Ola.proto, it doesn't seem that it returns the universe list:

    rpc GetPlugins (PluginListRequest) returns (PluginListReply);
    ...
    message PluginInfo {
      required int32 plugin_id = 1;
      required string name = 2;
      required bool active = 3;
      optional bool enabled = 4;
    }
    
    message PluginListReply {
      repeated PluginInfo plugin = 1;
    }
    
  4. peternewman commented on Apr 21, 2017

    @peternewman
    Member

    Did you mean the JSON /json/universe_plugin_list? That's what that RPC returns.

    The other likely one is FetchUniverseList

    void OlaClientCore::FetchUniverseList(UniverseListCallback *callback) {

    Point us to the JSON you want, and I can tell you the appropriate RPC. Or look in the RPC directly.

  5. hepiyellow commented on Apr 21, 2017

    @hepiyellow
    ContributorAuthor

    Yes, it is the /json/universe_plugin_list API that I was trying to find in Java API.

    The FetchUniverseList that you referenced call the RPC GetUniverseInfo.
    This RPC is defined in Ola.proto :

    rpc GetUniverseInfo (OptionalUniverseRequest) returns (UniverseInfoReply);
    ...
    // request info about a universe
    message OptionalUniverseRequest {
      optional int32 universe = 1;
    }
    

    But in the Java API:

    public UniverseInfoReply getUniverseInfo(int universe) {
            OptionalUniverseRequest request = OptionalUniverseRequest.newBuilder().setUniverse(universe).build();
         return (UniverseInfoReply) callRpcMethod("GetUniverseInfo", request);
    }

    Notice that the universe argument is mandatory int (not optional like in the RPC).
    I assume that without setting a universe, the reply will include all universes.
    So I guess a small fix in the Java API would solve it. Something like:

    public UniverseInfoReply getUniverseInfo(Integer universe) {
      final OptionalUniverseRequest.Builder b = OptionalUniverseRequest.newBuilder();
      if (universe!=null) b.setUniverse(universe);
      final OptionalUniverseRequest request = b.build();
      return (UniverseInfoReply) callRpcMethod("GetUniverseInfo", request);
     }

    If it It sound good to you,
    I'll test it and make a PR.

    Thanks,
    Erez

  6. peternewman commented on Apr 22, 2017

    @peternewman
    Member

    Hi @hepiyellow ,

    It turns out the JSON API is cheating, it's doing GetPluginList, then GetUniverseInfo and combining the results as one chunk of JSON:
    https://github.com/OpenLightingProject/ola/blob/master/olad/OladHTTPServer.cpp#L840

    In terms of FetchUniverseList/FetchUniverseInfo, they're done as two methods in the C++ API, which you really ought to try and mirror:
    https://github.com/OpenLightingProject/ola/blob/master/ola/OlaClientCore.cpp#L331
    https://github.com/OpenLightingProject/ola/blob/master/ola/OlaClientCore.cpp#L348

    So just add another method which has a different name and doesn't require a universe argument.

  7. hepiyellow commented on Apr 22, 2017

    @hepiyellow
    ContributorAuthor

    I submitted a PR for this:
    #1231

  8. peternewman commented on Apr 22, 2017

    @peternewman
    Member

    Thanks @hepiyellow .

  9. added this to the 0.11.0 milestone on Apr 22, 2017
  10. peternewman commented on Dec 2, 2017

    @peternewman
    Member

    Closed in #1231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions