.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::GitHub::V3 3pm" .TH Net::GitHub::V3 3pm "2022-10-08" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::GitHub::V3 \- Github API v3 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Prefer: .PP .Vb 7 \& use Net::GitHub; \& my $gh = Net::GitHub\->new( \& version => 3, \& login => \*(Aqfayland\*(Aq, pass => \*(Aqmypass\*(Aq, \& # or \& # access_token => $oauth_token \& ); .Ve .PP Or: .PP .Vb 6 \& use Net::GitHub::V3; \& my $gh = Net::GitHub::V3\->new( \& login => \*(Aqfayland\*(Aq, pass => \*(Aqmypass\*(Aq, \& # or \& # access_token => $oauth_token \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" .SS "\s-1ATTRIBUTES\s0" .IX Subsection "ATTRIBUTES" \fIAuthentication\fR .IX Subsection "Authentication" .PP There are two ways to authenticate through GitHub \s-1API\s0 v3: .IP "login/pass" 4 .IX Item "login/pass" .Vb 1 \& my $gh = Net::GitHub::V3\->new( login => $ENV{GITHUB_USER}, pass => $ENV{GITHUB_PASS} ); .Ve .IP "access_token" 4 .IX Item "access_token" .Vb 1 \& my $gh = Net::GitHub\->new( access_token => $ENV{GITHUB_ACCESS_TOKEN} ); .Ve .PP \fIraw_response\fR .IX Subsection "raw_response" .PP .Vb 4 \& my $gh = Net::GitHub\->new( \& # login/pass or access_token \& raw_response => 1 \& ); .Ve .PP return raw HTTP::Response object .PP \fIraw_string\fR .IX Subsection "raw_string" .PP .Vb 4 \& my $gh = Net::GitHub\->new( \& # login/pass or access_token \& raw_string => 1 \& ); .Ve .PP return HTTP::Response response content as string .PP \fIapi_throttle\fR .IX Subsection "api_throttle" .PP .Vb 4 \& my $gh = Net::GitHub\->new( \& # login/pass or access_token \& api_throttle => 0 \& ); .Ve .PP To disable call rate limiting (e.g. if your account is whitelisted), set \fBapi_throttle\fR to 0. .PP \fIRaiseError\fR .IX Subsection "RaiseError" .PP By default, error responses are propagated to the user as they are received from the \s-1API.\s0 By switching \fBRaiseError\fR on you can make the be turned into exceptions instead, so that you don't have to check for error response after every call. .PP \fIIterating over pages: next_url, last_url, prev_url, first_url, per_page\fR .IX Subsection "Iterating over pages: next_url, last_url, prev_url, first_url, per_page" .PP Any methods which return multiple results \fImay\fR be paginated. After performing a query you should check to see if there are more results. These attributes will be reset for each query. .PP The predicates to check these attributes are \f(CW\*(C`has_next_page\*(C'\fR, \f(CW\*(C`has_last_page\*(C'\fR, \&\f(CW\*(C`has_prev_page\*(C'\fR and \f(CW\*(C`has_first_page\*(C'\fR. .PP \&\f(CW\*(C`per_page\*(C'\fR defaults to 100. It will be applied to \s-1GET\s0 urls no matter it supports or not. .PP See Github's documentation: .PP .Vb 6 \& my @issues = $gh\->issue\->repos_issues; \& while ($gh\->issue\->has_next_page) { \& push @issues, $gh\->issue\->query($gh\->issue\->next_url); \& ## OR ## \& push @issues, $gh\->issue\->next_page; \& } .Ve .PP \fIIterating over individual items: next_xxx and close_xxx\fR .IX Subsection "Iterating over individual items: next_xxx and close_xxx" .PP The queries which can return paginated results can also be evaluated one by one, like this: .PP .Vb 3 \& while (my $issue = $gh\->issue\->next_repos_issue( @args )) { \& # do something with $issue \& } .Ve .PP The arguments to next_repos_issue are the same as for repos_issues, and is also applicable to all other interfaces which offer a next_xxx method. All available next_xxx methods are listed in the documentation of the corresponding modules, see the list below. .PP If you loop over the next_xxx interfaces, new \s-1API\s0 calls will be performed automatically, but only when needed to fetch more items. An undefined return value means there are no more items. .PP To start over with the first item, you need to close the iteration. Every next_xxx method has a corresponding close_xxx method which must be called with exactly the same parameters as the next_xxx method to take effect: .PP .Vb 1 \& $gh\->issue\->close_repos_issue(@args); .Ve .PP If you use Net::GitHub::V3 in a command line program, there is no need to call the close_xxx methods at all. As soon as the Net::GitHub::V3 object \f(CW$gh\fR goes out of scope, everything is neatly cleaned up. .PP However, if you have a long-lived Net::GitHub::V3 object, e.g. in a persistent service process which provides an own interface to its users and talks to GitHub under the hood, then it is advisable to close the iterations when you're done with them. .PP For brevity and because they usually are not needed, the close_xxx methods are not listed with their modules. It is guaranteed that \&\fIevery\fR next_xxx method has a corresponding close_xxx method. .PP \fIAlternate iterator over individual items:\fR .IX Subsection "Alternate iterator over individual items:" .PP If next_xxx and close_xxx methods are not available for your pagination method you can use a generic iterator using the \f(CW\*(C`iterate\*(C'\fR helper. .PP .Vb 2 \& $gh\->issues\->iterate( \*(Aqrepos_issues\*(Aq, [ @args ], sub { \& my $issue = shift; \& \& ... # do something with $issue \& \& return 1; # if you want to continue iterating \& return; # when you want to interrupt the iteration process \& } ); .Ve .PP \fIua\fR .IX Subsection "ua" .PP To set the proxy for ua, you can do something like following .PP .Vb 1 \& $gh\->ua\->proxy(\*(Aqhttps\*(Aq, \*(Aqsocks://127.0.0.1:9050\*(Aq); .Ve .PP \&\f(CW$gh\fR\->ua is an instance of LWP::UserAgent .SS "\s-1METHODS\s0" .IX Subsection "METHODS" \fIquery($method, \f(CI$url\fI, \f(CI$data\fI)\fR .IX Subsection "query($method, $url, $data)" .PP .Vb 3 \& my $data = $gh\->query(\*(Aq/user\*(Aq); \& $gh\->query(\*(AqPATCH\*(Aq, \*(Aq/user\*(Aq, $data); \& $gh\->query(\*(AqDELETE\*(Aq, \*(Aq/user/emails\*(Aq, [ \*(Aqmyemail@somewhere.com\*(Aq ]); .Ve .PP query \s-1API\s0 directly .PP \fInext_page\fR .IX Subsection "next_page" .PP When the results have been paginated, \f(CW\*(C`next_page\*(C'\fR is sugar for the common case of iterating through all the pages in order. It simply calls \f(CW\*(C`query\*(C'\fR with the \f(CW\*(C`next_url\*(C'\fR. .PP \fIset_default_user_repo\fR .IX Subsection "set_default_user_repo" .PP .Vb 2 \& $gh\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); # take effects for all $gh\-> \& $gh\->repos\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); # take effects on $gh\->repos .Ve .PP \&\fBTo ease the keyboard, we provided two ways to call any method which starts with :user/:repo\fR .PP 1. \s-1SET\s0 user/repos before call methods below .PP .Vb 2 \& $gh\->set_default_user_repo(\*(Aqfayland\*(Aq, \*(Aqperl\-net\-github\*(Aq); \& my @contributors = $gh\->repos\->contributors; .Ve .PP 2. If it is just for once, we can pass :user, :repo before any arguments .PP .Vb 1 \& my @contributors = $repos\->contributors($user, $repo); .Ve .SS "\s-1MODULES\s0" .IX Subsection "MODULES" \fIuser\fR .IX Subsection "user" .PP .Vb 2 \& my $user = $gh\->user\->show(\*(Aqnothingmuch\*(Aq); \& $gh\->user\->update( bio => \*(AqJust Another Perl Programmer\*(Aq ); .Ve .PP Net::GitHub::V3::Users .PP \fIrepos\fR .IX Subsection "repos" .PP .Vb 6 \& my @repos = $gh\->repos\->list; \& my $rp = $gh\->repos\->create( { \& "name" => "Hello\-World", \& "description" => "This is your first repo", \& "homepage" => "https://github.com" \& } ); .Ve .PP Net::GitHub::V3::Repos .PP \fIissue\fR .IX Subsection "issue" .PP .Vb 2 \& my @issues = $gh\->issue\->issues(); \& my $issue = $gh\->issue\->issue($issue_number); .Ve .PP Net::GitHub::V3::Issues .PP \fIpull_request\fR .IX Subsection "pull_request" .PP .Vb 1 \& my @pulls = $gh\->pull_request\->pulls(); .Ve .PP Net::GitHub::V3::PullRequests .PP \fIorg\fR .IX Subsection "org" .PP .Vb 1 \& my @orgs = $gh\->org\->orgs; .Ve .PP Net::GitHub::V3::Orgs .PP \fIgit_data\fR .IX Subsection "git_data" .PP Net::GitHub::V3::GitData .PP \fIgist\fR .IX Subsection "gist" .PP Net::GitHub::V3::Gists .PP \fIoauth\fR .IX Subsection "oauth" .PP Net::GitHub::V3::OAuth .PP \fIevent\fR .IX Subsection "event" .PP Net::GitHub::V3::Events .PP \fIsearch\fR .IX Subsection "search" .PP Net::GitHub::V3::Search .SH "SEE ALSO" .IX Header "SEE ALSO" Pithub .SH "AUTHOR & COPYRIGHT & LICENSE" .IX Header "AUTHOR & COPYRIGHT & LICENSE" Refer Net::GitHub