This module provides a Nit object oriented interface to access the Github api.
To access the API you need an instance of a GithubAPI
client.
var token = get_github_oauth
assert not token.is_empty
# Init the client.
var api = new GithubAPI(token)
The API client allows you to get Github API entities.
var repo = api.get_repo("nitlang/nit")
assert repo != null
assert repo.name == "nit"
var user = api.get_user("Morriar")
assert user != null
assert user.login == "Morriar"
Error: Multiple entities for auth
: auth
, auth
Token can also be recovered from user config with get_github_oauth
.
git
configurationReturn the value of git config --get github.oauthtoken
or ""
if no key exists.
Error: No entity for load_user
.
Did you mean:
Provides access to Github user data.
Should be accessed from GithubAPI::get_user
.
self
to serializer
deserializer
Error: No entity for load_repo
.
Did you mean:
Provides access to Github repo data.
Should be accessed from GithubAPI::get_repo
.
self
to serializer
self
to serializer
deserializer
deserializer
Issue
./search
Error: Multiple entities for cache
: cache
, cache
, cache
, cache
, cache
, cache
, cache
, cache
This method returns a deserialized result.
For raw data see send
.
var api = new GithubAPI(get_github_oauth)
var obj = api.get("/repos/nitlang/nit")
assert obj isa Repo
assert obj.name == "nit"
Returns null
in case of error
.
obj = api.get("/foo/bar/baz")
assert obj == null
assert api.was_error
assert api.last_error isa GithubError
Default is nit_github_api
.
Error: No entity for verbose_lvl
.
Did you mean:
If URL scheme of GitLab API follows the one of Github API, it may be possible to configure this wrapper to use a custom URL.
Default is https://api.github.com
and should not be changed.
Using this API you can create Github hooks able to respond to actions performed on a repository.
nitcorn
.Usage:
import github::hooks
# A simple hook listener that print received events in stdout.
class LogHookListener
super HookListener
# Use double dispatch to implement log behavior.
redef fun apply_event(event) do event.log_event(self)
end
redef class GithubEvent
# Log this event.
#
# Do nothing by default.
fun log_event(l: LogHookListener) do end
end
redef class CommitCommentEvent
redef fun log_event(l) do
print "new comment on commit {comment.commit_id}"
end
end
var api = new GithubAPI(get_github_oauth)
var listener = new LogHookListener(api, "127.0.0.1", 8080)
GithubAPI can trigger different events depending on the hook configuration.