|
85 | 85 | " params = [_mk_param(k) for k in req_args]\n", |
86 | 86 | " params += [_mk_param(k, default=v) for k,v in opt_args.items()]\n", |
87 | 87 | " params += [_mk_param(k, **_mk_sig_detls(v)) for k,v in anno_args.items()]\n", |
88 | | - " return Signature(params)" |
89 | | - ] |
90 | | - }, |
91 | | - { |
92 | | - "cell_type": "code", |
93 | | - "execution_count": null, |
94 | | - "metadata": {}, |
95 | | - "outputs": [], |
96 | | - "source": [ |
97 | | - "#|export\n", |
| 88 | + " return Signature(params)\n", |
| 89 | + "\n", |
98 | 90 | "class _GhObj: pass" |
99 | 91 | ] |
100 | 92 | }, |
|
165 | 157 | "_docroot = 'https://docs.github.com/rest/reference/'" |
166 | 158 | ] |
167 | 159 | }, |
| 160 | + { |
| 161 | + "cell_type": "code", |
| 162 | + "execution_count": null, |
| 163 | + "metadata": {}, |
| 164 | + "outputs": [], |
| 165 | + "source": [ |
| 166 | + "#|export\n", |
| 167 | + "def print_summary(req:Request):\n", |
| 168 | + " \"Print `Request.summary` with the token (if any) removed\"\n", |
| 169 | + " pprint(req.summary('Authorization'))" |
| 170 | + ] |
| 171 | + }, |
168 | 172 | { |
169 | 173 | "cell_type": "markdown", |
170 | 174 | "metadata": {}, |
|
185 | 189 | " token = token or os.getenv('GITHUB_TOKEN', None)\n", |
186 | 190 | " jwt_token = jwt_token or os.getenv('GITHUB_JWT_TOKEN', None)\n", |
187 | 191 | " if jwt_token: self.headers['Authorization'] = 'Bearer ' + jwt_token\n", |
188 | | - " if token: self.headers['Authorization'] = 'token ' + token\n", |
| 192 | + " elif token: self.headers['Authorization'] = 'token ' + token\n", |
| 193 | + " else: warn('Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated')\n", |
189 | 194 | " if owner: kwargs['owner'] = owner\n", |
190 | 195 | " if repo: kwargs['repo' ] = repo\n", |
191 | 196 | " funcs_ = L(funcs).starmap(_GhVerb, client=self, kwargs=kwargs)\n", |
|
203 | 208 | " if route:\n", |
204 | 209 | " for k,v in route.items(): route[k] = quote(str(route[k]))\n", |
205 | 210 | " return_json = ('json' in headers['Accept'])\n", |
206 | | - " res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=self.debug, return_headers=True,\n", |
| 211 | + " debug = self.debug if self.debug else print_summary if os.getenv('GHAPI_DEBUG') else None\n", |
| 212 | + " res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=debug, return_headers=True,\n", |
207 | 213 | " route=route or None, query=query or None, data=data or None, return_json=return_json)\n", |
208 | 214 | " if 'X-RateLimit-Remaining' in self.recv_hdrs:\n", |
209 | 215 | " newlim = self.recv_hdrs['X-RateLimit-Remaining']\n", |
|
253 | 259 | "text/markdown": [ |
254 | 260 | "---\n", |
255 | 261 | "\n", |
256 | | - "#### GhApi.__call__\n", |
| 262 | + "### GhApi.__call__\n", |
257 | 263 | "\n", |
258 | 264 | "> GhApi.__call__ (path:str, verb:str=None, headers:dict=None,\n", |
259 | 265 | "> route:dict=None, query:dict=None, data=None)\n", |
260 | 266 | "\n", |
261 | 267 | "Call a fully specified `path` using HTTP `verb`, passing arguments to `fastcore.core.urlsend`" |
262 | 268 | ], |
263 | 269 | "text/plain": [ |
264 | | - "<nbdev.showdoc.BasicMarkdownRenderer>" |
| 270 | + "---\n", |
| 271 | + "\n", |
| 272 | + "### GhApi.__call__\n", |
| 273 | + "\n", |
| 274 | + "> GhApi.__call__ (path:str, verb:str=None, headers:dict=None,\n", |
| 275 | + "> route:dict=None, query:dict=None, data=None)\n", |
| 276 | + "\n", |
| 277 | + "Call a fully specified `path` using HTTP `verb`, passing arguments to `fastcore.core.urlsend`" |
265 | 278 | ] |
266 | 279 | }, |
267 | 280 | "execution_count": null, |
|
299 | 312 | "text/markdown": [ |
300 | 313 | "```json\n", |
301 | 314 | "{ 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n", |
302 | | - " 'object': { 'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n", |
| 315 | + " 'object': { 'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n", |
303 | 316 | " 'type': 'commit',\n", |
304 | | - " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'},\n", |
| 317 | + " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'},\n", |
305 | 318 | " 'ref': 'refs/heads/master',\n", |
306 | 319 | " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master'}\n", |
307 | 320 | "```" |
|
310 | 323 | "{'ref': 'refs/heads/master',\n", |
311 | 324 | " 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n", |
312 | 325 | " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master',\n", |
313 | | - " 'object': {'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n", |
| 326 | + " 'object': {'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n", |
314 | 327 | " 'type': 'commit',\n", |
315 | | - " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'}}" |
| 328 | + " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'}}" |
316 | 329 | ] |
317 | 330 | }, |
318 | 331 | "execution_count": null, |
|
335 | 348 | "text/markdown": [ |
336 | 349 | "---\n", |
337 | 350 | "\n", |
338 | | - "#### GhApi.__getitem__\n", |
| 351 | + "### GhApi.__getitem__\n", |
339 | 352 | "\n", |
340 | 353 | "> GhApi.__getitem__ (k)\n", |
341 | 354 | "\n", |
342 | 355 | "Lookup and call an endpoint by path and verb (which defaults to 'GET')" |
343 | 356 | ], |
344 | 357 | "text/plain": [ |
345 | | - "<nbdev.showdoc.BasicMarkdownRenderer>" |
| 358 | + "---\n", |
| 359 | + "\n", |
| 360 | + "### GhApi.__getitem__\n", |
| 361 | + "\n", |
| 362 | + "> GhApi.__getitem__ (k)\n", |
| 363 | + "\n", |
| 364 | + "Lookup and call an endpoint by path and verb (which defaults to 'GET')" |
346 | 365 | ] |
347 | 366 | }, |
348 | 367 | "execution_count": null, |
|
371 | 390 | "text/markdown": [ |
372 | 391 | "```json\n", |
373 | 392 | "{ 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n", |
374 | | - " 'object': { 'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n", |
| 393 | + " 'object': { 'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n", |
375 | 394 | " 'type': 'commit',\n", |
376 | | - " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'},\n", |
| 395 | + " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'},\n", |
377 | 396 | " 'ref': 'refs/heads/master',\n", |
378 | 397 | " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master'}\n", |
379 | 398 | "```" |
|
382 | 401 | "{'ref': 'refs/heads/master',\n", |
383 | 402 | " 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n", |
384 | 403 | " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master',\n", |
385 | | - " 'object': {'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n", |
| 404 | + " 'object': {'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n", |
386 | 405 | " 'type': 'commit',\n", |
387 | | - " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'}}" |
| 406 | + " 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'}}" |
388 | 407 | ] |
389 | 408 | }, |
390 | 409 | "execution_count": null, |
|
418 | 437 | { |
419 | 438 | "data": { |
420 | 439 | "text/plain": [ |
421 | | - "'af24f2afd42cdaf2e368fed47e52a9f7c6065bed'" |
| 440 | + "'037bf40e4e5eb32a165db42a35dd89e1c1546493'" |
422 | 441 | ] |
423 | 442 | }, |
424 | 443 | "execution_count": null, |
|
455 | 474 | "name": "stdout", |
456 | 475 | "output_type": "stream", |
457 | 476 | "text": [ |
458 | | - "Quota remaining: 4727 of 5000\n" |
| 477 | + "Quota remaining: 4995 of 5000\n" |
459 | 478 | ] |
460 | 479 | }, |
461 | 480 | { |
|
491 | 510 | { |
492 | 511 | "data": { |
493 | 512 | "text/plain": [ |
494 | | - "'4727'" |
| 513 | + "'4995'" |
495 | 514 | ] |
496 | 515 | }, |
497 | 516 | "execution_count": null, |
|
788 | 807 | "outputs": [], |
789 | 808 | "source": [ |
790 | 809 | "#|hide\n", |
791 | | - "for hook in api.repos.list_webhooks(): api.repos.delete_webhook(hook.id)" |
| 810 | + "for hook in api.repos.list_webhooks():\n", |
| 811 | + " api.repos.delete_webhook(hook.id)" |
792 | 812 | ] |
793 | 813 | }, |
794 | 814 | { |
|
948 | 968 | "print(created, '->', gh2date(created))" |
949 | 969 | ] |
950 | 970 | }, |
951 | | - { |
952 | | - "cell_type": "code", |
953 | | - "execution_count": null, |
954 | | - "metadata": {}, |
955 | | - "outputs": [], |
956 | | - "source": [ |
957 | | - "#|export\n", |
958 | | - "def print_summary(req:Request):\n", |
959 | | - " \"Print `Request.summary` with the token (if any) removed\"\n", |
960 | | - " pprint(req.summary('Authorization'))" |
961 | | - ] |
962 | | - }, |
963 | 971 | { |
964 | 972 | "cell_type": "markdown", |
965 | 973 | "metadata": {}, |
|
0 commit comments