1Net::GitHub::V3(3)    User Contributed Perl Documentation   Net::GitHub::V3(3)
2
3
4

NAME

6       Net::GitHub::V3 - Github API v3
7

SYNOPSIS

9       Prefer:
10
11           use Net::GitHub;
12           my $gh = Net::GitHub->new(
13               version => 3,
14               login => 'fayland', pass => 'mypass',
15               # or
16               # access_token => $oauth_token
17           );
18
19       Or:
20
21           use Net::GitHub::V3;
22           my $gh = Net::GitHub::V3->new(
23               login => 'fayland', pass => 'mypass',
24               # or
25               # access_token => $oauth_token
26           );
27

DESCRIPTION

29       <http://developer.github.com/v3/>
30
31   ATTRIBUTES
32       Authentication
33
34       There are two ways to authenticate through GitHub API v3:
35
36       login/pass
37               my $gh = Net::GitHub::V3->new( login => $ENV{GITHUB_USER}, pass => $ENV{GITHUB_PASS} );
38
39       access_token
40               my $gh = Net::GitHub->new( access_token => $ENV{GITHUB_ACCESS_TOKEN} );
41
42       raw_response
43
44           my $gh = Net::GitHub->new(
45               # login/pass or access_token
46               raw_response => 1
47           );
48
49       return raw HTTP::Response object
50
51       raw_string
52
53           my $gh = Net::GitHub->new(
54               # login/pass or access_token
55               raw_string => 1
56           );
57
58       return HTTP::Response response content as string
59
60       api_throttle
61
62           my $gh = Net::GitHub->new(
63               # login/pass or access_token
64               api_throttle => 0
65           );
66
67       To disable call rate limiting (e.g. if your account is whitelisted),
68       set api_throttle to 0.
69
70       RaiseError
71
72       By default, error responses are propagated to the user as they are
73       received from the API. By switching RaiseError on you can make the be
74       turned into exceptions instead, so that you don't have to check for
75       error response after every call.
76
77       Iterating over pages: next_url, last_url, prev_url, first_url, per_page
78
79       Any methods which return multiple results may be paginated. After
80       performing a query you should check to see if there are more results.
81       These attributes will be reset for each query.
82
83       The predicates to check these attributes are "has_next_page",
84       "has_last_page", "has_prev_page" and "has_first_page".
85
86       "per_page" defaults to 100. It will be applied to GET urls no matter it
87       supports or not.
88
89       See Github's documentation:
90       <http://developer.github.com/v3/#pagination>
91
92         my @issues = $gh->issue->repos_issues;
93         while ($gh->issue->has_next_page) {
94             push @issues, $gh->issue->query($gh->issue->next_url);
95             ## OR ##
96             push @issues, $gh->issue->next_page;
97         }
98
99       Iterating over individual items: next_xxx and close_xxx
100
101       The queries which can return paginated results can also be evaluated
102       one by one, like this:
103
104         while (my $issue = $gh->issue->next_repos_issue( @args )) {
105           # do something with $issue
106         }
107
108       The arguments to next_repos_issue are the same as for repos_issues, and
109       is also applicable to all other interfaces which offer a next_xxx
110       method.  All available next_xxx methods are listed in the documentation
111       of the corresponding modules, see the list below.
112
113       If you loop over the next_xxx interfaces, new API calls will be
114       performed automatically, but only when needed to fetch more items.  An
115       undefined return value means there are no more items.
116
117       To start over with the first item, you need to close the iteration.
118       Every next_xxx method has a corresponding close_xxx method which must
119       be called with exactly the same parameters as the next_xxx method to
120       take effect:
121
122         $gh->issue->close_repos_issue(@args);
123
124       If you use Net::GitHub::V3 in a command line program, there is no need
125       to call the close_xxx methods at all.  As soon as the Net::GitHub::V3
126       object $gh goes out of scope, everything is neatly cleaned up.
127
128       However, if you have a long-lived Net::GitHub::V3 object, e.g. in a
129       persistent service process which provides an own interface to its users
130       and talks to GitHub under the hood, then it is advisable to close the
131       iterations when you're done with them.
132
133       For brevity and because they usually are not needed, the close_xxx
134       methods are not listed with their modules.  It is guaranteed that every
135       next_xxx method has a corresponding close_xxx method.
136
137       Alternate iterator over individual items:
138
139       If next_xxx and close_xxx methods are not available for your pagination
140       method you can use a generic iterator using the "iterate" helper.
141
142           $gh->issues->iterate( 'repos_issues', [ @args ], sub {
143               my $issue = shift;
144
145               ... # do something with $issue
146
147               return 1; # if you want to continue iterating
148               return;   # when you want to interrupt the iteration process
149           } );
150
151       ua
152
153       To set the proxy for ua, you can do something like following
154
155           $gh->ua->proxy('https', 'socks://127.0.0.1:9050');
156
157       $gh->ua is an instance of LWP::UserAgent
158
159   METHODS
160       query($method, $url, $data)
161
162           my $data = $gh->query('/user');
163           $gh->query('PATCH', '/user', $data);
164           $gh->query('DELETE', '/user/emails', [ 'myemail@somewhere.com' ]);
165
166       query API directly
167
168       next_page
169
170       When the results have been paginated, "next_page" is sugar for the
171       common case of iterating through all the pages in order. It simply
172       calls "query" with the "next_url".
173
174       set_default_user_repo
175
176           $gh->set_default_user_repo('fayland', 'perl-net-github'); # take effects for all $gh->
177           $gh->repos->set_default_user_repo('fayland', 'perl-net-github'); # take effects on $gh->repos
178
179       To ease the keyboard, we provided two ways to call any method which
180       starts with :user/:repo
181
182       1. SET user/repos before call methods below
183
184           $gh->set_default_user_repo('fayland', 'perl-net-github');
185           my @contributors = $gh->repos->contributors;
186
187       2. If it is just for once, we can pass :user, :repo before any
188       arguments
189
190           my @contributors = $repos->contributors($user, $repo);
191
192   MODULES
193       user
194
195           my $user = $gh->user->show('nothingmuch');
196           $gh->user->update( bio => 'Just Another Perl Programmer' );
197
198       Net::GitHub::V3::Users
199
200       repos
201
202           my @repos = $gh->repos->list;
203           my $rp = $gh->repos->create( {
204               "name" => "Hello-World",
205               "description" => "This is your first repo",
206               "homepage" => "https://github.com"
207           } );
208
209       Net::GitHub::V3::Repos
210
211       issue
212
213           my @issues = $gh->issue->issues();
214           my $issue  = $gh->issue->issue($issue_number);
215
216       Net::GitHub::V3::Issues
217
218       pull_request
219
220           my @pulls = $gh->pull_request->pulls();
221
222       Net::GitHub::V3::PullRequests
223
224       org
225
226           my @orgs   = $gh->org->orgs;
227
228       Net::GitHub::V3::Orgs
229
230       git_data
231
232       Net::GitHub::V3::GitData
233
234       gist
235
236       Net::GitHub::V3::Gists
237
238       oauth
239
240       Net::GitHub::V3::OAuth
241
242       event
243
244       Net::GitHub::V3::Events
245
246       search
247
248       Net::GitHub::V3::Search
249

SEE ALSO

251       Pithub
252
254       Refer Net::GitHub
255
256
257
258perl v5.32.0                      2020-07-28                Net::GitHub::V3(3)
Impressum