ghapi 2.0.6__tar.gz → 2.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {ghapi-2.0.6/ghapi.egg-info → ghapi-2.0.7}/PKG-INFO +43 -29
  2. {ghapi-2.0.6 → ghapi-2.0.7}/README.md +40 -26
  3. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/__init__.py +2 -1
  4. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/_modidx.py +4 -12
  5. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/build_lib.py +10 -2
  6. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/core.py +4 -4
  7. ghapi-2.0.7/ghapi/gql_spec.py +1815 -0
  8. ghapi-2.0.7/ghapi/graphql.py +39 -0
  9. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/skill.py +11 -12
  10. {ghapi-2.0.6 → ghapi-2.0.7/ghapi.egg-info}/PKG-INFO +43 -29
  11. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi.egg-info/SOURCES.txt +1 -0
  12. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi.egg-info/requires.txt +2 -2
  13. {ghapi-2.0.6 → ghapi-2.0.7}/pyproject.toml +1 -1
  14. ghapi-2.0.6/ghapi/graphql.py +0 -74
  15. {ghapi-2.0.6 → ghapi-2.0.7}/CONTRIBUTING.md +0 -0
  16. {ghapi-2.0.6 → ghapi-2.0.7}/LICENSE +0 -0
  17. {ghapi-2.0.6 → ghapi-2.0.7}/MANIFEST.in +0 -0
  18. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/actions.py +0 -0
  19. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/all.py +0 -0
  20. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/auth.py +0 -0
  21. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/cli.py +0 -0
  22. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/event.py +0 -0
  23. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/gh_spec.py +0 -0
  24. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/page.py +0 -0
  25. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/py.typed +0 -0
  26. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi/templates.py +0 -0
  27. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi.egg-info/dependency_links.txt +0 -0
  28. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi.egg-info/entry_points.txt +0 -0
  29. {ghapi-2.0.6 → ghapi-2.0.7}/ghapi.egg-info/top_level.txt +0 -0
  30. {ghapi-2.0.6 → ghapi-2.0.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ghapi
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: A python client for the GitHub API
5
5
  Author-email: Jeremy Howard <info@fast.ai>
6
6
  License: Apache-2.0
@@ -15,8 +15,8 @@ Classifier: Programming Language :: Python :: 3 :: Only
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: fastcore>=2.1.16
19
- Requires-Dist: fastspec>=0.1.5
18
+ Requires-Dist: fastcore>=2.2.6
19
+ Requires-Dist: fastspec>=0.1.7
20
20
  Requires-Dist: tomli; python_version < "3.11"
21
21
  Provides-Extra: dev
22
22
  Requires-Dist: fastgit; extra == "dev"
@@ -70,6 +70,9 @@ To access the GitHub API, first create a [`GhApi`](https://ghapi.fast.ai/core.ht
70
70
 
71
71
  ``` python
72
72
  from ghapi.all import GhApi
73
+ ```
74
+
75
+ ``` python
73
76
  api = GhApi()
74
77
  ```
75
78
 
@@ -79,8 +82,6 @@ Every part of the API includes documentation directly in the `api` object itself
79
82
  api
80
83
  ```
81
84
 
82
- <div class="prose" markdown="1">
83
-
84
85
  - [actions](https://docs.github.com/rest/reference/actions)
85
86
  - [activity](https://docs.github.com/rest/reference/activity)
86
87
  - [agent_tasks](https://docs.github.com/rest/reference/agent-tasks)
@@ -120,6 +121,7 @@ api
120
121
  - [packages](https://docs.github.com/rest/reference/packages)
121
122
  - [private_registries](https://docs.github.com/rest/reference/private-registries)
122
123
  - [projects](https://docs.github.com/rest/reference/projects)
124
+ - [pull_request_stacks](https://docs.github.com/rest/reference/pull-request-stacks)
123
125
  - [pulls](https://docs.github.com/rest/reference/pulls)
124
126
  - [rate_limit](https://docs.github.com/rest/reference/rate-limit)
125
127
  - [reactions](https://docs.github.com/rest/reference/reactions)
@@ -130,16 +132,12 @@ api
130
132
  - [teams](https://docs.github.com/rest/reference/teams)
131
133
  - [users](https://docs.github.com/rest/reference/users)
132
134
 
133
- </div>
134
-
135
135
  Then we can explore the endpoints provided by the API in each group, e.g. for the `git` group:
136
136
 
137
137
  ``` python
138
138
  api.git
139
139
  ```
140
140
 
141
- <div class="prose" markdown="1">
142
-
143
141
  - [git.create_blob](https://docs.github.com/rest/git/blobs#create-a-blob)(owner, repo, content, encoding): *Create a blob*
144
142
  - [git.get_blob](https://docs.github.com/rest/git/blobs#get-a-blob)(owner, repo, file_sha): *Get a blob*
145
143
  - [git.create_commit](https://docs.github.com/rest/git/commits#create-a-commit)(owner, repo, message, tree, parents, author, committer, signature): *Create a commit*
@@ -154,16 +152,12 @@ api.git
154
152
  - [git.create_tree](https://docs.github.com/rest/git/trees#create-a-tree)(owner, repo, tree, base_tree): *Create a tree*
155
153
  - [git.get_tree](https://docs.github.com/rest/git/trees#get-a-tree)(owner, repo, tree_sha, recursive): *Get a tree*
156
154
 
157
- </div>
158
-
159
155
  Here’s how to learn about an endpoint you want to use, e.g.:
160
156
 
161
157
  ``` python
162
158
  api.git.get_ref
163
159
  ```
164
160
 
165
- <div class="prose" markdown="1">
166
-
167
161
  Get a reference
168
162
 
169
163
  Docs: https://docs.github.com/rest/git/refs#get-a-reference
@@ -173,16 +167,12 @@ Parameters:
173
167
  - repo (str, required): The name of the repository without the `.git` extension. The name is not case sensitive.
174
168
  - ref (str, required): The Git reference. For more information, see “[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)” in the Git documentation.
175
169
 
176
- </div>
177
-
178
- In Jupyter Notebook full tab completion, parameter lists, etc are provided for all endpoints. Endpoints are called as standard Python methods:
170
+ Jupyter provides full tab completion and parameter lists for every endpoint. Endpoints are called as standard Python methods:
179
171
 
180
172
  ``` python
181
173
  await api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master')
182
174
  ```
183
175
 
184
- <div class="prose" markdown="1">
185
-
186
176
  ``` python
187
177
  { 'node_id': 'MDM6UmVmMjI1NDYwNTk5OnJlZnMvaGVhZHMvbWFzdGVy',
188
178
  'object': { 'sha': 'c0608379fe60014534c8dffe2e381138e8160f53',
@@ -192,17 +182,13 @@ await api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master')
192
182
  'url': 'https://api.github.com/repos/AnswerDotAI/fastcore/git/refs/heads/master'}
193
183
  ```
194
184
 
195
- </div>
196
-
197
- To use [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) to access authenticated operations (other than when running through GitHub Actions), you will need a GitHub [personal access token](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token), which is a secret code used to access your account. If you don’t have one, [click here](https://github.com/settings/tokens/new) to create one. You’ll be asked to enter a name – choose anything you like, for instance “*ghapi*”. You’ll also be asked to choose “scopes”; this limits what you’ll be able to do with the API using this token. If you’re not sure, click “*repo*” “*gist*”, “*notifications*”, and “*workflow*”. Then click “Generate Token” at the bottom of the screen, and copy the token (the long string of letters and numbers shown). You can easily do that by clicking the little clipboard icon next to the token.
198
-
199
- Rather than pasting that token into every script, it’s easiest to save it as an environment variable. If you save it as `$GITHUB_TOKEN` then it will be most convenient, so add this to the end of your `.bashrc` or `.zshrc` file:
185
+ To use authenticated operations (other than when running through GitHub Actions), you will need a GitHub [personal access token](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token). If you don’t have one, [click here](https://github.com/settings/tokens/new) to create it, choosing the scopes you need (“repo”, “gist”, “notifications”, and “workflow” cover most uses). Save it as an environment variable named `GITHUB_TOKEN`, e.g. by adding this to your `.bashrc` or `.zshrc`:
200
186
 
201
187
  export GITHUB_TOKEN=xxx
202
188
 
203
- …replacing the `xxx` with the token you just copied. (Don’t forget to `source` that file after you change it.), pass a \[GitHub token\].
189
+ [`GhApi`](https://ghapi.fast.ai/core.html#ghapi) uses that variable automatically, or you can pass `token=` explicitly.
204
190
 
205
- As well as your `token`, you can also pass any parameters you want auto-inserted into relevant methods, such as `owner` and `repo`:
191
+ As well as `token`, you can pass any parameters you want auto-inserted into relevant methods, such as `owner` and `repo`:
206
192
 
207
193
  ``` python
208
194
  api = GhApi(owner='fastai', repo='fastcore', token=github_token)
@@ -214,8 +200,6 @@ We can now repeat the previous method, but only need to pass `ref`:
214
200
  await api.git.get_ref('heads/master')
215
201
  ```
216
202
 
217
- <div class="prose" markdown="1">
218
-
219
203
  ``` python
220
204
  { 'node_id': 'MDM6UmVmMjI1NDYwNTk5OnJlZnMvaGVhZHMvbWFzdGVy',
221
205
  'object': { 'sha': 'c0608379fe60014534c8dffe2e381138e8160f53',
@@ -225,8 +209,6 @@ await api.git.get_ref('heads/master')
225
209
  'url': 'https://api.github.com/repos/AnswerDotAI/fastcore/git/refs/heads/master'}
226
210
  ```
227
211
 
228
- </div>
229
-
230
212
  Now that we’ve provided our token, we can use authenticated endpoints such as creating an issue:
231
213
 
232
214
  ``` python
@@ -239,6 +221,38 @@ Since we’ve now checked out GhApi, let’s close this issue. 😎
239
221
  await api.issues.update(issue.number, state='closed')
240
222
  ```
241
223
 
224
+ ## Beyond the endpoints
225
+
226
+ [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) also layers task-level conveniences over the generated endpoints – see the [GhApi details](https://ghapi.fast.ai/core.html) page for the full set. Highlights: [`paged`](https://ghapi.fast.ai/page.html#paged)/[`pages`](https://ghapi.fast.ai/page.html#pages) iterate any list endpoint; [`read_issue`](https://ghapi.fast.ai/core.html#read_issue)/[`read_pr`](https://ghapi.fast.ai/core.html#read_pr) gather a whole issue or PR (body, comments, diff, reviews) in one call; [`dep_graph`](https://ghapi.fast.ai/core.html#dep_graph)/[`dep_order`](https://ghapi.fast.ai/core.html#dep_order) sort an ecosystem’s repos dependency-first; plus helpers for gists, releases, branches, and repo files. For CI, [`check_status`](https://ghapi.fast.ai/core.html#check_status) combines commit statuses and check runs into one verdict, and [`failed_step_log`](https://ghapi.fast.ai/core.html#failed_step_log) drills into why a run went red:
227
+
228
+ ``` python
229
+ api = GhApi(owner='AnswerDotAI', repo='ghapi', token=github_token)
230
+ await api.check_status('main')
231
+ ```
232
+
233
+ **failure**
234
+
235
+ - 93199230629 update-pip-graph: success (46s)
236
+ - 93199227080 deploy: failure (22s)
237
+
238
+ ## GraphQL
239
+
240
+ When a read fans out across many repos, the [GraphQL client](https://ghapi.fast.ai/graphql.html) fetches it in a single `batch` call – issued as parallel chunked requests under the hood, at a fraction of the rate-limit cost of per-repo REST calls. Build schema-checked query fragments by attribute chaining, then `batch` them: here, the head commit of several repos at once. The same page covers interactive schema discovery, cursor pagination, raw queries, and more:
241
+
242
+ ``` python
243
+ from ghapi.graphql import GhGql
244
+ ```
245
+
246
+ ``` python
247
+ gql = GhGql()
248
+ await gql.batch(*[gql.repository(owner='AnswerDotAI', name=n).defaultBranchRef.target.oid
249
+ for n in ('fastcore', 'fasthtml', 'ghapi')])
250
+ ```
251
+
252
+ ['25c4f3228ccac3c5a63da71b5eaa4be3c428f602',
253
+ 'e5d967ae627c63035e296e6f319f220e278327e7',
254
+ 'ad07893daac86de6693bc9bb57ae7216c1b347d0']
255
+
242
256
  ## How to use - command line
243
257
 
244
258
  You can use [`GhApi`](https://ghapi.fast.ai/core.html#ghapi) via the command line, and can access nearly everything in the [GitHub API](https://docs.github.com/rest). We provide an overview here of one of the command line programs, [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) – see the full CLI docs page for details on all the programs available.
@@ -40,6 +40,9 @@ To access the GitHub API, first create a [`GhApi`](https://ghapi.fast.ai/core.ht
40
40
 
41
41
  ``` python
42
42
  from ghapi.all import GhApi
43
+ ```
44
+
45
+ ``` python
43
46
  api = GhApi()
44
47
  ```
45
48
 
@@ -49,8 +52,6 @@ Every part of the API includes documentation directly in the `api` object itself
49
52
  api
50
53
  ```
51
54
 
52
- <div class="prose" markdown="1">
53
-
54
55
  - [actions](https://docs.github.com/rest/reference/actions)
55
56
  - [activity](https://docs.github.com/rest/reference/activity)
56
57
  - [agent_tasks](https://docs.github.com/rest/reference/agent-tasks)
@@ -90,6 +91,7 @@ api
90
91
  - [packages](https://docs.github.com/rest/reference/packages)
91
92
  - [private_registries](https://docs.github.com/rest/reference/private-registries)
92
93
  - [projects](https://docs.github.com/rest/reference/projects)
94
+ - [pull_request_stacks](https://docs.github.com/rest/reference/pull-request-stacks)
93
95
  - [pulls](https://docs.github.com/rest/reference/pulls)
94
96
  - [rate_limit](https://docs.github.com/rest/reference/rate-limit)
95
97
  - [reactions](https://docs.github.com/rest/reference/reactions)
@@ -100,16 +102,12 @@ api
100
102
  - [teams](https://docs.github.com/rest/reference/teams)
101
103
  - [users](https://docs.github.com/rest/reference/users)
102
104
 
103
- </div>
104
-
105
105
  Then we can explore the endpoints provided by the API in each group, e.g. for the `git` group:
106
106
 
107
107
  ``` python
108
108
  api.git
109
109
  ```
110
110
 
111
- <div class="prose" markdown="1">
112
-
113
111
  - [git.create_blob](https://docs.github.com/rest/git/blobs#create-a-blob)(owner, repo, content, encoding): *Create a blob*
114
112
  - [git.get_blob](https://docs.github.com/rest/git/blobs#get-a-blob)(owner, repo, file_sha): *Get a blob*
115
113
  - [git.create_commit](https://docs.github.com/rest/git/commits#create-a-commit)(owner, repo, message, tree, parents, author, committer, signature): *Create a commit*
@@ -124,16 +122,12 @@ api.git
124
122
  - [git.create_tree](https://docs.github.com/rest/git/trees#create-a-tree)(owner, repo, tree, base_tree): *Create a tree*
125
123
  - [git.get_tree](https://docs.github.com/rest/git/trees#get-a-tree)(owner, repo, tree_sha, recursive): *Get a tree*
126
124
 
127
- </div>
128
-
129
125
  Here’s how to learn about an endpoint you want to use, e.g.:
130
126
 
131
127
  ``` python
132
128
  api.git.get_ref
133
129
  ```
134
130
 
135
- <div class="prose" markdown="1">
136
-
137
131
  Get a reference
138
132
 
139
133
  Docs: https://docs.github.com/rest/git/refs#get-a-reference
@@ -143,16 +137,12 @@ Parameters:
143
137
  - repo (str, required): The name of the repository without the `.git` extension. The name is not case sensitive.
144
138
  - ref (str, required): The Git reference. For more information, see “[Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References)” in the Git documentation.
145
139
 
146
- </div>
147
-
148
- In Jupyter Notebook full tab completion, parameter lists, etc are provided for all endpoints. Endpoints are called as standard Python methods:
140
+ Jupyter provides full tab completion and parameter lists for every endpoint. Endpoints are called as standard Python methods:
149
141
 
150
142
  ``` python
151
143
  await api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master')
152
144
  ```
153
145
 
154
- <div class="prose" markdown="1">
155
-
156
146
  ``` python
157
147
  { 'node_id': 'MDM6UmVmMjI1NDYwNTk5OnJlZnMvaGVhZHMvbWFzdGVy',
158
148
  'object': { 'sha': 'c0608379fe60014534c8dffe2e381138e8160f53',
@@ -162,17 +152,13 @@ await api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master')
162
152
  'url': 'https://api.github.com/repos/AnswerDotAI/fastcore/git/refs/heads/master'}
163
153
  ```
164
154
 
165
- </div>
166
-
167
- To use [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) to access authenticated operations (other than when running through GitHub Actions), you will need a GitHub [personal access token](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token), which is a secret code used to access your account. If you don’t have one, [click here](https://github.com/settings/tokens/new) to create one. You’ll be asked to enter a name – choose anything you like, for instance “*ghapi*”. You’ll also be asked to choose “scopes”; this limits what you’ll be able to do with the API using this token. If you’re not sure, click “*repo*” “*gist*”, “*notifications*”, and “*workflow*”. Then click “Generate Token” at the bottom of the screen, and copy the token (the long string of letters and numbers shown). You can easily do that by clicking the little clipboard icon next to the token.
168
-
169
- Rather than pasting that token into every script, it’s easiest to save it as an environment variable. If you save it as `$GITHUB_TOKEN` then it will be most convenient, so add this to the end of your `.bashrc` or `.zshrc` file:
155
+ To use authenticated operations (other than when running through GitHub Actions), you will need a GitHub [personal access token](https://docs.github.com/github/authenticating-to-github/creating-a-personal-access-token). If you don’t have one, [click here](https://github.com/settings/tokens/new) to create it, choosing the scopes you need (“repo”, “gist”, “notifications”, and “workflow” cover most uses). Save it as an environment variable named `GITHUB_TOKEN`, e.g. by adding this to your `.bashrc` or `.zshrc`:
170
156
 
171
157
  export GITHUB_TOKEN=xxx
172
158
 
173
- …replacing the `xxx` with the token you just copied. (Don’t forget to `source` that file after you change it.), pass a \[GitHub token\].
159
+ [`GhApi`](https://ghapi.fast.ai/core.html#ghapi) uses that variable automatically, or you can pass `token=` explicitly.
174
160
 
175
- As well as your `token`, you can also pass any parameters you want auto-inserted into relevant methods, such as `owner` and `repo`:
161
+ As well as `token`, you can pass any parameters you want auto-inserted into relevant methods, such as `owner` and `repo`:
176
162
 
177
163
  ``` python
178
164
  api = GhApi(owner='fastai', repo='fastcore', token=github_token)
@@ -184,8 +170,6 @@ We can now repeat the previous method, but only need to pass `ref`:
184
170
  await api.git.get_ref('heads/master')
185
171
  ```
186
172
 
187
- <div class="prose" markdown="1">
188
-
189
173
  ``` python
190
174
  { 'node_id': 'MDM6UmVmMjI1NDYwNTk5OnJlZnMvaGVhZHMvbWFzdGVy',
191
175
  'object': { 'sha': 'c0608379fe60014534c8dffe2e381138e8160f53',
@@ -195,8 +179,6 @@ await api.git.get_ref('heads/master')
195
179
  'url': 'https://api.github.com/repos/AnswerDotAI/fastcore/git/refs/heads/master'}
196
180
  ```
197
181
 
198
- </div>
199
-
200
182
  Now that we’ve provided our token, we can use authenticated endpoints such as creating an issue:
201
183
 
202
184
  ``` python
@@ -209,6 +191,38 @@ Since we’ve now checked out GhApi, let’s close this issue. 😎
209
191
  await api.issues.update(issue.number, state='closed')
210
192
  ```
211
193
 
194
+ ## Beyond the endpoints
195
+
196
+ [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) also layers task-level conveniences over the generated endpoints – see the [GhApi details](https://ghapi.fast.ai/core.html) page for the full set. Highlights: [`paged`](https://ghapi.fast.ai/page.html#paged)/[`pages`](https://ghapi.fast.ai/page.html#pages) iterate any list endpoint; [`read_issue`](https://ghapi.fast.ai/core.html#read_issue)/[`read_pr`](https://ghapi.fast.ai/core.html#read_pr) gather a whole issue or PR (body, comments, diff, reviews) in one call; [`dep_graph`](https://ghapi.fast.ai/core.html#dep_graph)/[`dep_order`](https://ghapi.fast.ai/core.html#dep_order) sort an ecosystem’s repos dependency-first; plus helpers for gists, releases, branches, and repo files. For CI, [`check_status`](https://ghapi.fast.ai/core.html#check_status) combines commit statuses and check runs into one verdict, and [`failed_step_log`](https://ghapi.fast.ai/core.html#failed_step_log) drills into why a run went red:
197
+
198
+ ``` python
199
+ api = GhApi(owner='AnswerDotAI', repo='ghapi', token=github_token)
200
+ await api.check_status('main')
201
+ ```
202
+
203
+ **failure**
204
+
205
+ - 93199230629 update-pip-graph: success (46s)
206
+ - 93199227080 deploy: failure (22s)
207
+
208
+ ## GraphQL
209
+
210
+ When a read fans out across many repos, the [GraphQL client](https://ghapi.fast.ai/graphql.html) fetches it in a single `batch` call – issued as parallel chunked requests under the hood, at a fraction of the rate-limit cost of per-repo REST calls. Build schema-checked query fragments by attribute chaining, then `batch` them: here, the head commit of several repos at once. The same page covers interactive schema discovery, cursor pagination, raw queries, and more:
211
+
212
+ ``` python
213
+ from ghapi.graphql import GhGql
214
+ ```
215
+
216
+ ``` python
217
+ gql = GhGql()
218
+ await gql.batch(*[gql.repository(owner='AnswerDotAI', name=n).defaultBranchRef.target.oid
219
+ for n in ('fastcore', 'fasthtml', 'ghapi')])
220
+ ```
221
+
222
+ ['25c4f3228ccac3c5a63da71b5eaa4be3c428f602',
223
+ 'e5d967ae627c63035e296e6f319f220e278327e7',
224
+ 'ad07893daac86de6693bc9bb57ae7216c1b347d0']
225
+
212
226
  ## How to use - command line
213
227
 
214
228
  You can use [`GhApi`](https://ghapi.fast.ai/core.html#ghapi) via the command line, and can access nearly everything in the [GitHub API](https://docs.github.com/rest). We provide an overview here of one of the command line programs, [`ghapi`](https://ghapi.fast.ai/cli.html#ghapi) – see the full CLI docs page for details on all the programs available.
@@ -2,6 +2,7 @@
2
2
 
3
3
  Modules:
4
4
 
5
+ - `ghapi.graphql`: Query GitHub's GraphQL API: schema-aware chained queries, one-request batching, and raw GraphQL
5
6
  - `ghapi.skill`: GitHub REST API access via `GhApi`, plus local git operations via `fastgit.Git`. Use this for day-to-day GitHub work: reading/creating issues and PRs, checking CI status, managing releases/branches/gists, and repo-local git operations -- all from Python, no shelling out to `gh`/`git` needed."""
6
7
 
7
- __version__ = "2.0.6"
8
+ __version__ = "2.0.7"
@@ -32,7 +32,8 @@ d = { 'settings': { 'branch': 'main',
32
32
  'ghapi.auth.GhDeviceAuth.wait': ('auth.html#ghdeviceauth.wait', 'ghapi/auth.py'),
33
33
  'ghapi.auth.github_auth_device': ('auth.html#github_auth_device', 'ghapi/auth.py'),
34
34
  'ghapi.auth.scope_str': ('auth.html#scope_str', 'ghapi/auth.py')},
35
- 'ghapi.build_lib': {'ghapi.build_lib.build_spec': ('build_lib.html#build_spec', 'ghapi/build_lib.py')},
35
+ 'ghapi.build_lib': { 'ghapi.build_lib.build_gql_spec': ('build_lib.html#build_gql_spec', 'ghapi/build_lib.py'),
36
+ 'ghapi.build_lib.build_spec': ('build_lib.html#build_spec', 'ghapi/build_lib.py')},
36
37
  'ghapi.cli': { 'ghapi.cli._api': ('cli.html#_api', 'ghapi/cli.py'),
37
38
  'ghapi.cli._call_api': ('cli.html#_call_api', 'ghapi/cli.py'),
38
39
  'ghapi.cli._ghapi': ('cli.html#_ghapi', 'ghapi/cli.py'),
@@ -144,19 +145,10 @@ d = { 'settings': { 'branch': 'main',
144
145
  'ghapi.event.load_sample_events': ('event.html#load_sample_events', 'ghapi/event.py'),
145
146
  'ghapi.event.save_sample_events': ('event.html#save_sample_events', 'ghapi/event.py')},
146
147
  'ghapi.gh_spec': {},
148
+ 'ghapi.gql_spec': {},
147
149
  'ghapi.graphql': { 'ghapi.graphql.GhGql': ('graphql.html#ghgql', 'ghapi/graphql.py'),
148
- 'ghapi.graphql.GhGql.__call__': ('graphql.html#ghgql.__call__', 'ghapi/graphql.py'),
149
150
  'ghapi.graphql.GhGql.__init__': ('graphql.html#ghgql.__init__', 'ghapi/graphql.py'),
150
- 'ghapi.graphql.GhGql.client': ('graphql.html#ghgql.client', 'ghapi/graphql.py'),
151
- 'ghapi.graphql.GhGql.list_queries': ('graphql.html#ghgql.list_queries', 'ghapi/graphql.py'),
152
- 'ghapi.graphql.GhGql.query_args': ('graphql.html#ghgql.query_args', 'ghapi/graphql.py'),
153
- 'ghapi.graphql.GhGql.schema': ('graphql.html#ghgql.schema', 'ghapi/graphql.py'),
154
- 'ghapi.graphql.GhGql.type_fields': ('graphql.html#ghgql.type_fields', 'ghapi/graphql.py'),
155
- 'ghapi.graphql._get_client': ('graphql.html#_get_client', 'ghapi/graphql.py'),
156
- 'ghapi.graphql.gh_query': ('graphql.html#gh_query', 'ghapi/graphql.py'),
157
- 'ghapi.graphql.list_queries': ('graphql.html#list_queries', 'ghapi/graphql.py'),
158
- 'ghapi.graphql.query_args': ('graphql.html#query_args', 'ghapi/graphql.py'),
159
- 'ghapi.graphql.type_fields': ('graphql.html#type_fields', 'ghapi/graphql.py')},
151
+ 'ghapi.graphql.GhGql.repo': ('graphql.html#ghgql.repo', 'ghapi/graphql.py')},
160
152
  'ghapi.page': { 'ghapi.page.GhApi.last_page': ('page.html#ghapi.last_page', 'ghapi/page.py'),
161
153
  'ghapi.page._Scanner': ('page.html#_scanner', 'ghapi/page.py'),
162
154
  'ghapi.page._Scanner.__getitem__': ('page.html#_scanner.__getitem__', 'ghapi/page.py'),
@@ -3,13 +3,14 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/90_build_lib.ipynb.
4
4
 
5
5
  # %% auto #0
6
- __all__ = ['GH_OPENAPI_URL', 'build_spec']
6
+ __all__ = ['GH_OPENAPI_URL', 'build_spec', 'build_gql_spec']
7
7
 
8
8
  # %% ../nbs/90_build_lib.ipynb #cdbcf258
9
9
  from fastcore.all import *
10
10
  from fastspec.spec import SpecParser
11
+ from fastspec.gql import GqlSpec, INTROSPECT
11
12
 
12
- import json
13
+ import json, httpx
13
14
 
14
15
  # %% ../nbs/90_build_lib.ipynb #c215ed8d
15
16
  GH_OPENAPI_URL = 'https://github.com/github/rest-api-description/raw/main/descriptions/api.github.com/api.github.com.json?raw=true'
@@ -18,3 +19,10 @@ GH_OPENAPI_URL = 'https://github.com/github/rest-api-description/raw/main/descri
18
19
  def build_spec(nm='ghapi/gh_spec.py', url=GH_OPENAPI_URL):
19
20
  "Regenerate the compact spec module `gh_spec.py` from GitHub's OpenAPI description."
20
21
  SpecParser.from_openapi(dict2obj(json.loads(urlread(url)))).save(nm)
22
+
23
+ # %% ../nbs/90_build_lib.ipynb #9aef0afb
24
+ def build_gql_spec(nm='ghapi/gql_spec.py', url='https://api.github.com/graphql'):
25
+ "Regenerate the distilled GraphQL schema tables shipped as `ghapi.gql_spec`."
26
+ r = httpx.post(url, json=dict(query=INTROSPECT), headers=dict(Authorization=f'bearer {os.environ["GITHUB_TOKEN"]}'), timeout=60)
27
+ r.raise_for_status()
28
+ GqlSpec.from_introspection(r.json()).save(nm)
@@ -242,11 +242,11 @@ async def upload_file(self:GhApi, rel, fn):
242
242
 
243
243
  # %% ../nbs/00_core.ipynb #3cad71a4
244
244
  @gh_patch
245
- async def create_release(self:GhApi, tag_name, branch='master', name=None, body='',
245
+ async def create_release(self:GhApi, tag_name, branch=None, name=None, body='',
246
246
  draft=False, prerelease=False, files=None, make_latest=UNSET):
247
- "Wrapper for `GhApi.repos.create_release` which also uploads `files`"
247
+ "Wrapper for `GhApi.repos.create_release` which also uploads `files`; `branch` defaults to the repo's default branch"
248
248
  if name is None: name = 'v'+tag_name
249
- rel = await self.repos.create_release(tag_name, target_commitish=branch, name=name, body=body,
249
+ rel = await self.repos.create_release(tag_name, target_commitish=branch or UNSET, name=name, body=body,
250
250
  draft=draft, prerelease=prerelease, make_latest=make_latest)
251
251
  for file in listify(files): await self.upload_file(rel, file)
252
252
  return rel
@@ -393,7 +393,7 @@ async def get_repo_contents(self:GhApi, owner, repo, branch='main',
393
393
  ):
394
394
  repo_files = await self.get_repo_files(owner, repo, branch, **kwargs)
395
395
  paths = repo_files.attrgot("path")
396
- return L(await parallel_async(self.get_file_content, paths, owner=owner, repo=repo, branch=branch, n_workers=n_workers))
396
+ return await parallel_async(self.get_file_content, paths, owner=owner, repo=repo, branch=branch, n_workers=n_workers)
397
397
 
398
398
  # %% ../nbs/00_core.ipynb #ac4ab4e0
399
399
  @gh_patch