Skip to content

Commit 23c08c2

Browse files
committed
_quarto
1 parent c85a68a commit 23c08c2

File tree

3 files changed

+310
-5
lines changed

3 files changed

+310
-5
lines changed

90_build_lib.ipynb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@
144144
"GhMeta = namedtuple('GhMeta', 'path verb oper_id summary doc_url params data preview'.split())"
145145
]
146146
},
147+
{
148+
"cell_type": "code",
149+
"execution_count": null,
150+
"metadata": {},
151+
"outputs": [],
152+
"source": [
153+
"from ghapi.metadata import funcs"
154+
]
155+
},
147156
{
148157
"cell_type": "code",
149158
"execution_count": null,
@@ -161,7 +170,6 @@
161170
}
162171
],
163172
"source": [
164-
"from ghapi.metadata import funcs\n",
165173
"GhMeta(*funcs[3])"
166174
]
167175
},

README.md

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
ghapi
2+
================
3+
4+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5+
6+
[`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) provides 100%
7+
always-updated coverage of the entire [GitHub
8+
API](https://docs.github.com/rest). Because we automatically convert the
9+
[OpenAPI
10+
spec](https://docs.github.com/rest/overview/openapi-description) to a
11+
Pythonic API, [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) is always
12+
up to date with the latest changes to GitHub APIs. Furthermore, because
13+
this is all done dynamically, the entire package is only 35kB in size!
14+
15+
Using [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi), you can automate
16+
nearly anything that you can do through the GitHub web interface or
17+
through the `git` client, such as:
18+
19+
- Open, list, comment on, or modify
20+
[issues](https://guides.github.com/features/issues/) or [pull
21+
requests](https://docs.github.com/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
22+
- Create, list, or modify [git
23+
tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging) or [GitHub
24+
releases](https://docs.github.com/github/administering-a-repository/managing-releases-in-a-repository),
25+
including uploading release assets
26+
- Configure and run GitHub
27+
[Actions](https://github.com/features/actions) and
28+
[webhooks](https://docs.github.com/developers/webhooks-and-events/about-webhooks)
29+
- Set up GitHub [users](https://docs.github.com/rest/reference/users)
30+
and
31+
[organizations](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/about-organizations)
32+
- Manage your
33+
[deployments](https://docs.github.com/rest/guides/delivering-deployments)
34+
- …and much, much more.
35+
36+
There are two ways to use
37+
[`ghapi`](https://ghapi.fast.ai/cli.html#ghapi): either through Python,
38+
or from the command line. An overview of each is provided below.
39+
40+
## Installation
41+
42+
To install, run either `pip install ghapi` or
43+
`conda install -c fastai ghapi`.
44+
45+
## How to use - Python
46+
47+
Throughout this documentation, you will see code inputs and outputs
48+
shown in this format:
49+
50+
``` python
51+
1+1
52+
```
53+
54+
2
55+
56+
We recommend reading the documentation on the [official
57+
site](https://ghapi.fast.ai/), rather than on GitHub, since not all the
58+
functionality described on this page is available through the GitHub
59+
viewer.
60+
61+
All of the documentation is available directly as Jupyter Notebooks, for
62+
instance the current page you’re reading is available as a notebook
63+
[here](https://github.com/fastai/ghapi/blob/master/index.ipynb). To open
64+
any page as an interactive notebook in Google Colab, click the *Colab*
65+
badge at the top of the page.
66+
67+
To access the GitHub API, first create a
68+
[`GhApi`](https://ghapi.fast.ai/core.html#ghapi) object:
69+
70+
``` python
71+
from ghapi.all import GhApi
72+
api = GhApi()
73+
```
74+
75+
Every part of the API includes documentation directly in the `api`
76+
object itself. For instance, here’s how to explore the groups of
77+
functionality provided by the API by displaying the object:
78+
79+
``` python
80+
api
81+
```
82+
83+
- [actions](https://docs.github.com/rest/reference/actions)
84+
- [activity](https://docs.github.com/rest/reference/activity)
85+
- [apps](https://docs.github.com/rest/reference/apps)
86+
- [billing](https://docs.github.com/rest/reference/billing)
87+
- [checks](https://docs.github.com/rest/reference/checks)
88+
- [code_scanning](https://docs.github.com/rest/reference/code-scanning)
89+
- [codes_of_conduct](https://docs.github.com/rest/reference/codes-of-conduct)
90+
- [emojis](https://docs.github.com/rest/reference/emojis)
91+
- [enterprise_admin](https://docs.github.com/rest/reference/enterprise-admin)
92+
- [gists](https://docs.github.com/rest/reference/gists)
93+
- [git](https://docs.github.com/rest/reference/git)
94+
- [gitignore](https://docs.github.com/rest/reference/gitignore)
95+
- [interactions](https://docs.github.com/rest/reference/interactions)
96+
- [issues](https://docs.github.com/rest/reference/issues)
97+
- [licenses](https://docs.github.com/rest/reference/licenses)
98+
- [markdown](https://docs.github.com/rest/reference/markdown)
99+
- [meta](https://docs.github.com/rest/reference/meta)
100+
- [migrations](https://docs.github.com/rest/reference/migrations)
101+
- [oauth_authorizations](https://docs.github.com/rest/reference/oauth-authorizations)
102+
- [orgs](https://docs.github.com/rest/reference/orgs)
103+
- [projects](https://docs.github.com/rest/reference/projects)
104+
- [pulls](https://docs.github.com/rest/reference/pulls)
105+
- [rate_limit](https://docs.github.com/rest/reference/rate-limit)
106+
- [reactions](https://docs.github.com/rest/reference/reactions)
107+
- [repos](https://docs.github.com/rest/reference/repos)
108+
- [scim](https://docs.github.com/rest/reference/scim)
109+
- [search](https://docs.github.com/rest/reference/search)
110+
- [secret_scanning](https://docs.github.com/rest/reference/secret-scanning)
111+
- [teams](https://docs.github.com/rest/reference/teams)
112+
- [users](https://docs.github.com/rest/reference/users)
113+
114+
Then we can explore the endpoints provided by the API in each group,
115+
e.g. for the `git` group:
116+
117+
``` python
118+
api.git
119+
```
120+
121+
- [git.create_blob](https://docs.github.com/rest/reference/git#create-a-blob)(owner,
122+
repo, content, encoding): *Create a blob*
123+
- [git.get_blob](https://docs.github.com/rest/reference/git#get-a-blob)(owner,
124+
repo, file_sha): *Get a blob*
125+
- [git.create_commit](https://docs.github.com/rest/reference/git#create-a-commit)(owner,
126+
repo, message, tree, parents, author, committer, signature): *Create a
127+
commit*
128+
- [git.get_commit](https://docs.github.com/rest/reference/git#get-a-commit)(owner,
129+
repo, commit_sha): *Get a commit*
130+
- [git.list_matching_refs](https://docs.github.com/rest/reference/git#list-matching-references)(owner,
131+
repo, ref, per_page, page): *List matching references*
132+
- [git.get_ref](https://docs.github.com/rest/reference/git#get-a-reference)(owner,
133+
repo, ref): *Get a reference*
134+
- [git.create_ref](https://docs.github.com/rest/reference/git#create-a-reference)(owner,
135+
repo, ref, sha, key): *Create a reference*
136+
- [git.update_ref](https://docs.github.com/rest/reference/git#update-a-reference)(owner,
137+
repo, ref, sha, force): *Update a reference*
138+
- [git.delete_ref](https://docs.github.com/rest/reference/git#delete-a-reference)(owner,
139+
repo, ref): *Delete a reference*
140+
- [git.create_tag](https://docs.github.com/rest/reference/git#create-a-tag-object)(owner,
141+
repo, tag, message, object, type, tagger): *Create a tag object*
142+
- [git.get_tag](https://docs.github.com/rest/reference/git#get-a-tag)(owner,
143+
repo, tag_sha): *Get a tag*
144+
- [git.create_tree](https://docs.github.com/rest/reference/git#create-a-tree)(owner,
145+
repo, tree, base_tree): *Create a tree*
146+
- [git.get_tree](https://docs.github.com/rest/reference/git#get-a-tree)(owner,
147+
repo, tree_sha, recursive): *Get a tree*
148+
149+
Here’s how to learn about an endpoint you want to use, e.g.:
150+
151+
``` python
152+
api.git.get_ref
153+
```
154+
155+
[git.get_ref](https://docs.github.com/rest/reference/git#get-a-reference)(owner,
156+
repo, ref): *Get a reference*
157+
158+
In Jupyter Notebook full tab completion, parameter lists, etc are
159+
provided for all endpoints. Endpoints are called as standard Python
160+
methods:
161+
162+
``` python
163+
api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master')
164+
```
165+
166+
- ref: refs/heads/master
167+
- node_id: MDM6UmVmMjI1NDYwNTk5OnJlZnMvaGVhZHMvbWFzdGVy
168+
- url:
169+
https://api.github.com/repos/fastai/fastcore/git/refs/heads/master
170+
- object:
171+
- sha: 0e3084ed009baa51db38a640ae7c23d638af2756
172+
- type: commit
173+
- url:
174+
https://api.github.com/repos/fastai/fastcore/git/commits/0e3084ed009baa51db38a640ae7c23d638af2756
175+
176+
To use [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) to access
177+
authenticated operations (other than when running through GitHub
178+
Actions), you will need a GitHub [personal access
179+
token](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token),
180+
which is a secret code used to access your account. If you don’t have
181+
one, [click here](https://github.com/settings/tokens/new) to create one.
182+
You’ll be asked to enter a name – choose anything you like, for instance
183+
*ghapi*”. You’ll also be asked to choose “scopes”; this limits what
184+
you’ll be able to do with the API using this token. If you’re not sure,
185+
click “*repo*” “*gist*”, “*notifications*”, and “*workflow*”. Then click
186+
“Generate Token” at the bottom of the screen, and copy the token (the
187+
long string of letters and numbers shown). You can easily do that by
188+
clicking the little clipboard icon next to the token.
189+
190+
Rather than pasting that token into every script, it’s easiest to save
191+
it as an environment variable. If you save it as `$GITHUB_TOKEN` then it
192+
will be most convenient, so add this to the end of your `.bashrc` or
193+
`.zshrc` file:
194+
195+
export GITHUB_TOKEN=xxx
196+
197+
…replacing the `xxx` with the token you just copied. (Don’t forget to
198+
`source` that file after you change it.), pass a \[GitHub token\].
199+
200+
As well as your `token`, you can also pass any parameters you want
201+
auto-inserted into relevant methods, such as `owner` and `repo`:
202+
203+
``` python
204+
api = GhApi(owner='fastai', repo='fastcore', token=github_token)
205+
```
206+
207+
We can now repeat the previous method, but only need to pass `ref`:
208+
209+
``` python
210+
api.git.get_ref('heads/master')
211+
```
212+
213+
- ref: refs/heads/master
214+
- node_id: MDM6UmVmMjI1NDYwNTk5OnJlZnMvaGVhZHMvbWFzdGVy
215+
- url:
216+
https://api.github.com/repos/fastai/fastcore/git/refs/heads/master
217+
- object:
218+
- sha: 0e3084ed009baa51db38a640ae7c23d638af2756
219+
- type: commit
220+
- url:
221+
https://api.github.com/repos/fastai/fastcore/git/commits/0e3084ed009baa51db38a640ae7c23d638af2756
222+
223+
Now that we’ve provided our token, we can use authenticated endpoints
224+
such as creating an issue:
225+
226+
``` python
227+
issue = api.issues.create("Remember to check out GhApi!")
228+
```
229+
230+
Since we’ve now checked out GhApi, let’s close this issue. 😎
231+
232+
``` python
233+
api.issues.update(issue.number, state='closed')
234+
```
235+
236+
## How to use - command line
237+
238+
You can use [`GhApi`](https://ghapi.fast.ai/core.html#ghapi) via the
239+
command line, and can access nearly everything in the [GitHub
240+
API](https://docs.github.com/rest). We provide an overview here of one
241+
of the command line programs,
242+
[`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) – see the full CLI docs
243+
page for details on all the programs available.
244+
245+
We strongly recommend enabling tab completion for
246+
[`ghapi`](https://ghapi.fast.ai/cli.html#ghapi), which you can do by
247+
placing the following command at the end of your `~/.bashrc` or
248+
`~/.zshrc` file:
249+
250+
``` bash
251+
eval "$(completion-ghapi --install)"
252+
```
253+
254+
To get started with the [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi)
255+
command, first find the name of the operation you wish to perform, for
256+
instance by searching the [full API
257+
reference](https://ghapi.fast.ai/fullapi.html).
258+
259+
To use [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi), pass the method
260+
name (exactly the same as you’d use in the Python API) as the first
261+
parameter, followed by any positional parameters required, and then
262+
keyword arguments with “`--`” before each parameter name.
263+
264+
For instance, [git.get_ref](https://ghapi.fast.ai/fullapi.html#git)
265+
takes three parameters: `owner`, `repo`, and `ref`. If we wish to pass
266+
the first two as positional parameters, and the last as a named
267+
argument, then we’d call:
268+
269+
``` bash
270+
ghapi git.get_ref fastai ghapi-test --ref heads/master
271+
```
272+
273+
If you have enabled tab completion, then after you’ve typed `ghapi g`
274+
try pressing <kbd>Tab</kbd>, and you’ll see all the operation groups
275+
available in the GitHub API that start with `g`. If you keep typing,
276+
e.g. `ghapi git.`, and hit <kbd>Tab</kbd> again, you’ll now see all the
277+
operations available in the `git` group, i.e:
278+
279+
git.create_blob git.create_commit git.create_ref git.create_tag git.create_tree git.delete_ref git.get_blob git.get_commit git.get_ref git.get_tag git.get_tree git.list_matching_refs git.name git.update_ref git.verbs
280+
281+
If you pass just `--help` after the operation name, you’ll see a full
282+
list of all parameters accepted, and a link to the official GitHub
283+
documentation.
284+
285+
``` bash
286+
ghapi git.get_ref --help
287+
>>> git.get_ref(owner, repo, ref)
288+
>>> https://docs.github.com/rest/reference/git#get-a-reference
289+
```
290+
291+
In addition to `--help` and the GitHub operation parameters, you can
292+
also pass the following:
293+
294+
- `--headers`: A list of extra headers to pass, JSON-encoded
295+
- `--token`: A GitHub authentation token
296+
- `--debug`: Print requests before sending them

_quarto.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ipynb-filters: [nbdev_filter]
22

33
project:
44
type: website
5-
output-dir: docs
5+
output-dir: _docs
66
preview:
77
port: 3000
88
browser: false
@@ -12,22 +12,23 @@ format:
1212
theme: cosmo
1313
css: styles.css
1414
toc: true
15+
toc-depth: 4
1516

1617
website:
1718
title: "ghapi"
19+
site-url: "https://ghapi.fast.ai/"
1820
description: "A python client for the GitHub API"
1921
twitter-card: true
2022
open-graph: true
21-
reader-mode: true
2223
repo-branch: master
23-
repo-url: https://github.com/fastai/ghapi/tree/master/
24+
repo-url: "https://github.com/fastai/ghapi/tree/master/"
2425
repo-actions: [issue]
2526
navbar:
2627
background: primary
2728
search: true
2829
right:
2930
- icon: github
30-
href: https://github.com/fastai/ghapi/tree/master/
31+
href: "https://github.com/fastai/ghapi/tree/master/"
3132
sidebar:
3233
style: "floating"
3334

0 commit comments

Comments
 (0)