Net::Async::Github - support for the https://github.com REST API with IO::Async
use IO::Async::Loop; use Net::Async::Github; my $loop = IO::Async::Loop->new; $loop->add( my $gh = Net::Async::Github->new( token => '...', ) ); # Give 'secret_team' pull access to all private repos $gh->repos(visibility => 'private') ->grant_team(secret_team => 'pull') ->await;
This is a basic wrapper for Github's API.
Returns information about the current user.
my $user = $gh->current_user->get; printf "User [%s] has %d public repos and was last updated on %s%s\n", $user->login, $user->public_repos, $user->updated_at->to_string
Resolves to a Net::Async::Github::User instance.
Accepts the following optional named parameters:
token - the Github API token
token
endpoints - hashref of RFC6570-compliant URL mappings
endpoints
http - an HTTP client compatible with the Net::Async::HTTP API
http
mime_type - the MIME type to use as the Accept header for requests
mime_type
Accept
page_cache_size - number of GET responses to cache. Defaults to 1000, set to 0 to disable.
page_cache_size
timeout - How long in seconds to wait before giving up on a request. Defaults to 60. If set to 0, then no timeout will take place.
timeout
You probably just want token, defaults should be fine for the other settings.
If you're creating a large number of instances, you can avoid some disk access overhead by passing endpoints from an existing instance to the constructor for a new instance.
Reopens the given PR.
Expects the following named parameters:
owner - which user or organisation owns this PR
repo - which repo it's for
id - the pull request ID
Resolves to the current status.
Returns information about the given PR.
Returns information of all PRs of given repository.
owner
repo - the repository this pull request is for
repo
Returns a Ryu::Source instance, this will emit a Net::Async::Github::PullRequest instance for each found repository.
Creates a new branch.
Takes the following named parameters:
owner - which organisation owns the target repository
repo - the repository to raise the PR against
branch - new branch name that will be created
branch
sha - the SHA1 value for this branch
sha
Update a reference to a new commit
ref - ref name that we are updating.
ref
sha - the SHA1 value of comment that the ref will point to
force - force update ref even if it is not fast-forward if it is true.
force
Creates a new pull request.
head - head commit starting point, typically the latest commit on your fork's branch
head
base - base commit this PR applies changes to typically you'd want the target repo master
base
master
Creates an empty commit. Can be used to simulate git commit --allow-empty or to create a merge commit from multiple heads.
git commit --allow-empty
message - The commit message
message
tree - The SHA of tree object that commit will point to
tree
parents - Arrayref that include the parents of the commit
parents
Returns information about the given user.
Iterates through all users. This is a good way to exhaust your 5000-query ratelimiting quota.
Identifies the head version for this branch.
Requires the following named parameters:
owner - which organisation or person owns the repo
repo - the repository name
branch - which branch to check
Returns a Net::Async::Github::RateLimit::Core instance which can track rate limits.
The following methods are used internally. They're not expected to be useful for external callers.
Returns an accessor for the endpoints data. This is a hashref containing URI templates, used by "endpoint".
Expands the selected URI via URI::Template. Each item is defined in our endpoints.json file.
endpoints.json
Returns a URI instance.
Accessor for the HTTP client object. Will load and instantiate a Net::Async::HTTP instance if necessary.
Actual HTTP implementation is not guaranteed, and the default is likely to change in future.
The parameter that will be used when create Net::Async::HTTP object. If it is undef, then a default value 60 seconds will be used. If it is 0, then Net::Async::HTTP will never timeout.
Returns authentication information used in the HTTP request.
Returns the MIME type used for requests. Currently defined by github in https://developer.github.com/v3/media/ as application/vnd.github.v3+json.
application/vnd.github.v3+json
The URI for requests. Defaults to https://api.github.com.
Performs an HTTP GET request.
A list of all pending requests.
Applies validation rules from git-check-ref-format for a branch name.
Will raise an exception on invalid input.
Applies github rules for user/organisation name.
Applies github rules for repository name.
Convenience method to apply validation on common parameters.
Returns the total number of GET responses we'll cache. Default is probably 1000.
The page cache instance, likely to be provided by Cache::LRU.
Our Ryu::Async instance, used for instantiating Ryu::Source instances.
add_child, adopt_future, adopted_futures, can_event, children, configure_unknown, debug_printf, get_loop, invoke_error, invoke_event, loop, make_event_cb, maybe_invoke_event, maybe_make_event_cb, new, notifier_name, parent, remove_child, remove_from_parent
Tom Molesworth <TEAM@cpan.org>, with contributions from @chylli-binary.
@chylli-binary
Copyright Tom Molesworth 2014-2021. Licensed under the same terms as Perl itself.
To install Net::Async::Github, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Async::Github
CPAN shell
perl -MCPAN -e shell install Net::Async::Github
For more information on module installation, please visit the detailed CPAN module installation guide.