1Net::GitHub::V3(3) User Contributed Perl Documentation Net::GitHub::V3(3)
2
3
4
6 Net::GitHub::V3 - Github API v3
7
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
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 ua
138
139 To set the proxy for ua, you can do something like following
140
141 $gh->ua->proxy('https', 'socks://127.0.0.1:9050');
142
143 $gh->ua is an instance of LWP::UserAgent
144
145 METHODS
146 query($method, $url, $data)
147
148 my $data = $gh->query('/user');
149 $gh->query('PATCH', '/user', $data);
150 $gh->query('DELETE', '/user/emails', [ 'myemail@somewhere.com' ]);
151
152 query API directly
153
154 next_page
155
156 When the results have been paginated, "next_page" is sugar for the
157 common case of iterating through all the pages in order. It simply
158 calls "query" with the "next_url".
159
160 set_default_user_repo
161
162 $gh->set_default_user_repo('fayland', 'perl-net-github'); # take effects for all $gh->
163 $gh->repos->set_default_user_repo('fayland', 'perl-net-github'); # take effects on $gh->repos
164
165 To ease the keyboard, we provided two ways to call any method which
166 starts with :user/:repo
167
168 1. SET user/repos before call methods below
169
170 $gh->set_default_user_repo('fayland', 'perl-net-github');
171 my @contributors = $gh->repos->contributors;
172
173 2. If it is just for once, we can pass :user, :repo before any
174 arguments
175
176 my @contributors = $repos->contributors($user, $repo);
177
178 MODULES
179 user
180
181 my $user = $gh->user->show('nothingmuch');
182 $gh->user->update( bio => 'Just Another Perl Programmer' );
183
184 Net::GitHub::V3::Users
185
186 repos
187
188 my @repos = $gh->repos->list;
189 my $rp = $gh->repos->create( {
190 "name" => "Hello-World",
191 "description" => "This is your first repo",
192 "homepage" => "https://github.com"
193 } );
194
195 Net::GitHub::V3::Repos
196
197 issue
198
199 my @issues = $gh->issue->issues();
200 my $issue = $gh->issue->issue($issue_number);
201
202 Net::GitHub::V3::Issues
203
204 pull_request
205
206 my @pulls = $gh->pull_request->pulls();
207
208 Net::GitHub::V3::PullRequests
209
210 org
211
212 my @orgs = $gh->org->orgs;
213
214 Net::GitHub::V3::Orgs
215
216 git_data
217
218 Net::GitHub::V3::GitData
219
220 gist
221
222 Net::GitHub::V3::Gists
223
224 oauth
225
226 Net::GitHub::V3::OAuth
227
228 event
229
230 Net::GitHub::V3::Events
231
232 search
233
234 Net::GitHub::V3::Search
235
237 Pithub
238
240 Refer Net::GitHub
241
242
243
244perl v5.30.0 2019-07-26 Net::GitHub::V3(3)