github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Feature Request: expose shallow event data

Open devinrsmith opened this issue 3 years ago • 1 comments

First time user at github-api...

I'm interested in consuming the GH event API for organizations. I see that org.kohsuke.github.GHOrganization#listEvents returns org.kohsuke.github.GHEventInfos.

Of particular importance for my use case is minimizing API requests. I see some fields in GHEventInfo that are commented as "shallow"; I'm assuming this means they have been partially filled in via the GH event response? Is there any reason these shallow objects can't / shouldn't be exposed to the end user?

I'm hoping all of the commons properties listed https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#event-object-common-properties can be accessible without additional API calls. It looks like the field public can be added as well?

Happy to follow up with a PR if this sounds appropriate. Thanks!

devinrsmith avatar Oct 17 '22 15:10 devinrsmith

You're talking about these fields, yes? https://github.com/hub4j/github-api/blob/ee1f0685a8e9feb4bdd719470874efb86d9307e2/src/main/java/org/kohsuke/github/GHEventInfo.java#L34-L37

The objects maybe too shallow to be sensible. If you are going to take this on, please consider doing the following.

  • Add the public field, in the same way it is done here:
  • Add nested classes that exactly match the items returned
  • Add methods that return the instances of the nested classes instead of the fully populated objects. Naming of the methods can be something like ``getRaw*orgetEventInfo*`.
  • Since your change doesn't cause additional API calls you might be able to modify this test to test you new methods and classes.

bitwiseman avatar Oct 21 '22 18:10 bitwiseman