gitcode-api 1.2.20__py3-none-any.whl → 1.3.0__py3-none-any.whl
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.
- gitcode_api/__init__.py +8 -2
- gitcode_api/_base_client.py +7 -2
- gitcode_api/_exceptions.py +8 -0
- gitcode_api/exceptions.py +19 -0
- gitcode_api/llm/mcp.py +5 -5
- gitcode_api/models.py +205 -0
- gitcode_api/resources/__init__.py +1 -1
- gitcode_api/resources/_shared/__init__.py +18 -0
- gitcode_api/resources/_shared/base.py +129 -0
- gitcode_api/resources/{_shared.py → _shared/fetch_template.py} +133 -259
- gitcode_api/resources/account/__init__.py +17 -0
- gitcode_api/resources/account/oauth_resource_group.py +159 -0
- gitcode_api/resources/account/orgs_resource_group.py +422 -0
- gitcode_api/resources/account/search_resource_group.py +236 -0
- gitcode_api/resources/account/users_resource_group.py +249 -0
- gitcode_api/resources/collaboration/__init__.py +20 -0
- gitcode_api/resources/collaboration/_helpers.py +10 -0
- gitcode_api/resources/collaboration/issues_resource_group.py +855 -0
- gitcode_api/resources/collaboration/labels_resource_group.py +248 -0
- gitcode_api/resources/collaboration/members_resource_group.py +195 -0
- gitcode_api/resources/collaboration/milestones_resource_group.py +192 -0
- gitcode_api/resources/collaboration/pulls_resource_group.py +1300 -0
- gitcode_api/resources/misc/__init__.py +14 -0
- gitcode_api/resources/misc/releases_resource_group.py +445 -0
- gitcode_api/resources/misc/tags_resource_group.py +286 -0
- gitcode_api/resources/misc/webhooks_resource_group.py +192 -0
- gitcode_api/resources/repositories/__init__.py +17 -0
- gitcode_api/resources/repositories/branches_resource_group.py +151 -0
- gitcode_api/resources/repositories/commits_resource_group.py +333 -0
- gitcode_api/resources/repositories/repo_contents_resource_group.py +459 -0
- gitcode_api/resources/repositories/repos_resource_group.py +1279 -0
- gitcode_api/version.txt +1 -1
- {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/METADATA +3 -3
- gitcode_api-1.3.0.dist-info/RECORD +52 -0
- gitcode_api/resources/account.py +0 -1086
- gitcode_api/resources/collaboration.py +0 -2818
- gitcode_api/resources/misc.py +0 -901
- gitcode_api/resources/repositories.py +0 -2197
- gitcode_api-1.2.20.dist-info/RECORD +0 -31
- {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/WHEEL +0 -0
- {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/entry_points.txt +0 -0
- {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/licenses/LICENSE +0 -0
- {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1279 @@
|
|
|
1
|
+
"""AbstractReposResource, ReposResource, and AsyncReposResource resource group."""
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from typing import Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
from ..._models import (
|
|
7
|
+
APIObject,
|
|
8
|
+
ApiStatusResponse,
|
|
9
|
+
Contributor,
|
|
10
|
+
ContributorStatistics,
|
|
11
|
+
PullRequestSettings,
|
|
12
|
+
RepoMember,
|
|
13
|
+
Repository,
|
|
14
|
+
RepositoryCustomizedRole,
|
|
15
|
+
RepositoryDownloadStatistics,
|
|
16
|
+
RepositoryPermissionMode,
|
|
17
|
+
RepositoryPushConfig,
|
|
18
|
+
RepositoryReviewerSettingsUpdate,
|
|
19
|
+
RepositorySettings,
|
|
20
|
+
RepositoryTransferResult,
|
|
21
|
+
RepositoryUploadResult,
|
|
22
|
+
UserSummary,
|
|
23
|
+
as_model,
|
|
24
|
+
)
|
|
25
|
+
from .._shared import AsyncResource, SyncResource
|
|
26
|
+
|
|
27
|
+
# mypy: disable-error-code=override
|
|
28
|
+
# pylint: disable=invalid-overridden-method,protected-access,redefined-builtin
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AbstractReposResource(ABC):
|
|
32
|
+
"""Interface for Repos resource endpoints."""
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def get(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Repository:
|
|
36
|
+
"""Get a repository.
|
|
37
|
+
|
|
38
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
39
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
40
|
+
:returns: Repository metadata.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
@abstractmethod
|
|
44
|
+
def list_user(
|
|
45
|
+
self,
|
|
46
|
+
*,
|
|
47
|
+
visibility: Optional[str] = None,
|
|
48
|
+
affiliation: Optional[str] = None,
|
|
49
|
+
type: Optional[str] = None,
|
|
50
|
+
sort: Optional[str] = None,
|
|
51
|
+
direction: Optional[str] = None,
|
|
52
|
+
q: Optional[str] = None,
|
|
53
|
+
page: Optional[int] = None,
|
|
54
|
+
per_page: Optional[int] = None,
|
|
55
|
+
) -> List[Repository]:
|
|
56
|
+
"""List repositories visible to the authenticated user.
|
|
57
|
+
|
|
58
|
+
:param visibility: Visibility filter such as ``public``, ``private``, or ``all``.
|
|
59
|
+
:param affiliation: Ownership filter accepted by the REST API.
|
|
60
|
+
:param type: Repository type filter.
|
|
61
|
+
:param sort: Sort field such as ``created`` or ``full_name``.
|
|
62
|
+
:param direction: Sort direction.
|
|
63
|
+
:param q: Optional keyword filter.
|
|
64
|
+
:param page: Page number.
|
|
65
|
+
:param per_page: Page size.
|
|
66
|
+
:returns: Matching repositories.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
@abstractmethod
|
|
70
|
+
def list_for_owner(
|
|
71
|
+
self,
|
|
72
|
+
*,
|
|
73
|
+
owner: str,
|
|
74
|
+
type: Optional[str] = None,
|
|
75
|
+
sort: Optional[str] = None,
|
|
76
|
+
direction: Optional[str] = None,
|
|
77
|
+
page: Optional[int] = None,
|
|
78
|
+
per_page: Optional[int] = None,
|
|
79
|
+
) -> List[Repository]:
|
|
80
|
+
"""List public repositories for a user or owner path.
|
|
81
|
+
|
|
82
|
+
:param owner: Repository owner path or username.
|
|
83
|
+
:param type: Repository type filter.
|
|
84
|
+
:param sort: Sort field.
|
|
85
|
+
:param direction: Sort direction.
|
|
86
|
+
:param page: Page number.
|
|
87
|
+
:param per_page: Page size.
|
|
88
|
+
:returns: Matching repositories.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
@abstractmethod
|
|
92
|
+
def create_personal(
|
|
93
|
+
self,
|
|
94
|
+
*,
|
|
95
|
+
name: str,
|
|
96
|
+
description: Optional[str] = None,
|
|
97
|
+
path: Optional[str] = None,
|
|
98
|
+
private: Optional[bool] = None,
|
|
99
|
+
auto_init: Optional[bool] = None,
|
|
100
|
+
has_issues: Optional[bool] = None,
|
|
101
|
+
has_wiki: Optional[bool] = None,
|
|
102
|
+
default_branch: Optional[str] = None,
|
|
103
|
+
gitignore_template: Optional[str] = None,
|
|
104
|
+
license_template: Optional[str] = None,
|
|
105
|
+
) -> Repository:
|
|
106
|
+
"""Create a repository for the authenticated user.
|
|
107
|
+
|
|
108
|
+
:param name: Repository name.
|
|
109
|
+
:param description: Repository description.
|
|
110
|
+
:param path: Optional repository path.
|
|
111
|
+
:param private: Whether the repository should be private.
|
|
112
|
+
:param auto_init: Whether to initialize the repository with a README.
|
|
113
|
+
:param has_issues: Whether issues are enabled.
|
|
114
|
+
:param has_wiki: Whether wiki support is enabled.
|
|
115
|
+
:param default_branch: Default branch name when initializing.
|
|
116
|
+
:param gitignore_template: Optional gitignore template.
|
|
117
|
+
:param license_template: Optional license template.
|
|
118
|
+
:returns: Created repository metadata.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
@abstractmethod
|
|
122
|
+
def create_for_org(
|
|
123
|
+
self,
|
|
124
|
+
*,
|
|
125
|
+
org: str,
|
|
126
|
+
name: str,
|
|
127
|
+
description: Optional[str] = None,
|
|
128
|
+
homepage: Optional[str] = None,
|
|
129
|
+
path: Optional[str] = None,
|
|
130
|
+
private: Optional[bool] = None,
|
|
131
|
+
public: Optional[int] = None,
|
|
132
|
+
auto_init: Optional[bool] = None,
|
|
133
|
+
has_issues: Optional[bool] = None,
|
|
134
|
+
has_wiki: Optional[bool] = None,
|
|
135
|
+
can_comment: Optional[bool] = None,
|
|
136
|
+
default_branch: Optional[str] = None,
|
|
137
|
+
gitignore_template: Optional[str] = None,
|
|
138
|
+
license_template: Optional[str] = None,
|
|
139
|
+
) -> Repository:
|
|
140
|
+
"""Create a repository under an organization.
|
|
141
|
+
|
|
142
|
+
:param org: Organization path or login.
|
|
143
|
+
:param name: Repository name.
|
|
144
|
+
:param description: Repository description.
|
|
145
|
+
:param homepage: Repository homepage URL.
|
|
146
|
+
:param path: Optional repository path.
|
|
147
|
+
:param private: Whether the repository should be private.
|
|
148
|
+
:param public: Visibility mode used by the GitCode API.
|
|
149
|
+
:param auto_init: Whether to initialize the repository with a README.
|
|
150
|
+
:param has_issues: Whether issues are enabled.
|
|
151
|
+
:param has_wiki: Whether wiki support is enabled.
|
|
152
|
+
:param can_comment: Whether comments are enabled.
|
|
153
|
+
:param default_branch: Default branch name when initializing.
|
|
154
|
+
:param gitignore_template: Optional gitignore template.
|
|
155
|
+
:param license_template: Optional license template.
|
|
156
|
+
:returns: Created repository metadata.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
@abstractmethod
|
|
160
|
+
def update(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **changes) -> Repository:
|
|
161
|
+
"""Update repository metadata.
|
|
162
|
+
|
|
163
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
164
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
165
|
+
:param changes: Repository fields accepted by the update endpoint.
|
|
166
|
+
:returns: Updated repository metadata.
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
@abstractmethod
|
|
170
|
+
def delete(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> None:
|
|
171
|
+
"""Delete a repository.
|
|
172
|
+
|
|
173
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
174
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
@abstractmethod
|
|
178
|
+
def fork(
|
|
179
|
+
self,
|
|
180
|
+
*,
|
|
181
|
+
owner: Optional[str] = None,
|
|
182
|
+
repo: Optional[str] = None,
|
|
183
|
+
namespace: Optional[str] = None,
|
|
184
|
+
path: Optional[str] = None,
|
|
185
|
+
name: Optional[str] = None,
|
|
186
|
+
) -> Repository:
|
|
187
|
+
"""Fork a repository.
|
|
188
|
+
|
|
189
|
+
:param owner: Source repository owner path.
|
|
190
|
+
:param repo: Source repository name.
|
|
191
|
+
:param namespace: Optional destination namespace.
|
|
192
|
+
:param path: Optional destination repository path.
|
|
193
|
+
:param name: Optional destination repository name.
|
|
194
|
+
:returns: Forked repository metadata.
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
@abstractmethod
|
|
198
|
+
def list_forks(
|
|
199
|
+
self,
|
|
200
|
+
*,
|
|
201
|
+
owner: Optional[str] = None,
|
|
202
|
+
repo: Optional[str] = None,
|
|
203
|
+
sort: Optional[str] = None,
|
|
204
|
+
page: Optional[int] = None,
|
|
205
|
+
per_page: Optional[int] = None,
|
|
206
|
+
) -> List[Repository]:
|
|
207
|
+
"""List forks of a repository.
|
|
208
|
+
|
|
209
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
210
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
211
|
+
:param sort: Optional sort field.
|
|
212
|
+
:param page: Page number.
|
|
213
|
+
:param per_page: Page size.
|
|
214
|
+
:returns: Fork repositories.
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
@abstractmethod
|
|
218
|
+
def list_contributors(
|
|
219
|
+
self,
|
|
220
|
+
*,
|
|
221
|
+
owner: Optional[str] = None,
|
|
222
|
+
repo: Optional[str] = None,
|
|
223
|
+
page: Optional[int] = None,
|
|
224
|
+
per_page: Optional[int] = None,
|
|
225
|
+
) -> List[Contributor]:
|
|
226
|
+
"""List repository contributors.
|
|
227
|
+
|
|
228
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
229
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
230
|
+
:param page: Page number.
|
|
231
|
+
:param per_page: Page size.
|
|
232
|
+
:returns: Contributors for the repository.
|
|
233
|
+
"""
|
|
234
|
+
|
|
235
|
+
@abstractmethod
|
|
236
|
+
def list_languages(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Dict[str, int]:
|
|
237
|
+
"""List language statistics for a repository.
|
|
238
|
+
|
|
239
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
240
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
241
|
+
:returns: Mapping of language names to byte counts.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
@abstractmethod
|
|
245
|
+
def list_stargazers(
|
|
246
|
+
self,
|
|
247
|
+
*,
|
|
248
|
+
owner: Optional[str] = None,
|
|
249
|
+
repo: Optional[str] = None,
|
|
250
|
+
page: Optional[int] = None,
|
|
251
|
+
per_page: Optional[int] = None,
|
|
252
|
+
) -> List[UserSummary]:
|
|
253
|
+
"""List users who starred a repository.
|
|
254
|
+
|
|
255
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
256
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
257
|
+
:param page: Page number.
|
|
258
|
+
:param per_page: Page size.
|
|
259
|
+
:returns: Users who starred the repository.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
@abstractmethod
|
|
263
|
+
def list_subscribers(
|
|
264
|
+
self,
|
|
265
|
+
*,
|
|
266
|
+
owner: Optional[str] = None,
|
|
267
|
+
repo: Optional[str] = None,
|
|
268
|
+
page: Optional[int] = None,
|
|
269
|
+
per_page: Optional[int] = None,
|
|
270
|
+
) -> List[UserSummary]:
|
|
271
|
+
"""List users watching a repository.
|
|
272
|
+
|
|
273
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
274
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
275
|
+
:param page: Page number.
|
|
276
|
+
:param per_page: Page size.
|
|
277
|
+
:returns: Subscribers for the repository.
|
|
278
|
+
"""
|
|
279
|
+
|
|
280
|
+
@abstractmethod
|
|
281
|
+
def update_module_settings(
|
|
282
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **settings
|
|
283
|
+
) -> ApiStatusResponse:
|
|
284
|
+
"""Update repository module settings.
|
|
285
|
+
|
|
286
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
287
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
288
|
+
:param settings: Module settings accepted by the GitCode API.
|
|
289
|
+
:returns: API response payload.
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
@abstractmethod
|
|
293
|
+
def update_reviewer_settings(
|
|
294
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **settings
|
|
295
|
+
) -> RepositoryReviewerSettingsUpdate:
|
|
296
|
+
"""Update repository reviewer settings.
|
|
297
|
+
|
|
298
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
299
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
300
|
+
:param settings: Reviewer settings accepted by the GitCode API.
|
|
301
|
+
:returns: API response payload.
|
|
302
|
+
"""
|
|
303
|
+
|
|
304
|
+
@abstractmethod
|
|
305
|
+
def set_org_repo_status(self, *, org: str, repo: str, **payload) -> ApiStatusResponse:
|
|
306
|
+
"""Update organization repository status metadata.
|
|
307
|
+
|
|
308
|
+
:param org: Organization path.
|
|
309
|
+
:param repo: Repository path.
|
|
310
|
+
:param payload: Status fields accepted by the API.
|
|
311
|
+
:returns: API response payload.
|
|
312
|
+
"""
|
|
313
|
+
|
|
314
|
+
@abstractmethod
|
|
315
|
+
def transfer_to_org(self, *, org: str, repo: str, **payload) -> ApiStatusResponse:
|
|
316
|
+
"""Transfer a repository to an organization.
|
|
317
|
+
|
|
318
|
+
:param org: Destination organization path.
|
|
319
|
+
:param repo: Repository path.
|
|
320
|
+
:param payload: Transfer options accepted by the API.
|
|
321
|
+
:returns: API response payload.
|
|
322
|
+
"""
|
|
323
|
+
|
|
324
|
+
@abstractmethod
|
|
325
|
+
def get_transition(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositoryPermissionMode:
|
|
326
|
+
"""Get repository transition settings.
|
|
327
|
+
|
|
328
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
329
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
330
|
+
:returns: Transition configuration.
|
|
331
|
+
"""
|
|
332
|
+
|
|
333
|
+
@abstractmethod
|
|
334
|
+
def update_transition(
|
|
335
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
336
|
+
) -> ApiStatusResponse:
|
|
337
|
+
"""Update repository transition settings.
|
|
338
|
+
|
|
339
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
340
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
341
|
+
:param payload: Transition settings accepted by the API.
|
|
342
|
+
:returns: API response payload.
|
|
343
|
+
"""
|
|
344
|
+
|
|
345
|
+
@abstractmethod
|
|
346
|
+
def update_push_config(
|
|
347
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
348
|
+
) -> RepositoryPushConfig:
|
|
349
|
+
"""Update repository push configuration.
|
|
350
|
+
|
|
351
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
352
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
353
|
+
:param payload: Push configuration values accepted by the API.
|
|
354
|
+
:returns: API response payload.
|
|
355
|
+
"""
|
|
356
|
+
|
|
357
|
+
@abstractmethod
|
|
358
|
+
def get_push_config(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositoryPushConfig:
|
|
359
|
+
"""Get repository push configuration.
|
|
360
|
+
|
|
361
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
362
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
363
|
+
:returns: Push configuration payload.
|
|
364
|
+
"""
|
|
365
|
+
|
|
366
|
+
@abstractmethod
|
|
367
|
+
def upload_image(
|
|
368
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
369
|
+
) -> RepositoryUploadResult:
|
|
370
|
+
"""Upload an image asset for a repository.
|
|
371
|
+
|
|
372
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
373
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
374
|
+
:param payload: Upload fields accepted by the API.
|
|
375
|
+
:returns: Uploaded image metadata.
|
|
376
|
+
"""
|
|
377
|
+
|
|
378
|
+
@abstractmethod
|
|
379
|
+
def upload_file(
|
|
380
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
381
|
+
) -> RepositoryUploadResult:
|
|
382
|
+
"""Upload a file asset for a repository.
|
|
383
|
+
|
|
384
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
385
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
386
|
+
:param payload: Upload fields accepted by the API.
|
|
387
|
+
:returns: Uploaded file metadata.
|
|
388
|
+
"""
|
|
389
|
+
|
|
390
|
+
@abstractmethod
|
|
391
|
+
def update_repo_settings(
|
|
392
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
393
|
+
) -> RepositorySettings:
|
|
394
|
+
"""Update repository settings.
|
|
395
|
+
|
|
396
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
397
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
398
|
+
:param payload: Settings fields accepted by the API.
|
|
399
|
+
:returns: API response payload.
|
|
400
|
+
"""
|
|
401
|
+
|
|
402
|
+
@abstractmethod
|
|
403
|
+
def get_repo_settings(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositorySettings:
|
|
404
|
+
"""Get repository settings.
|
|
405
|
+
|
|
406
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
407
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
408
|
+
:returns: Repository settings payload.
|
|
409
|
+
"""
|
|
410
|
+
|
|
411
|
+
@abstractmethod
|
|
412
|
+
def get_pull_request_settings(
|
|
413
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
414
|
+
) -> PullRequestSettings:
|
|
415
|
+
"""Get pull request settings for a repository.
|
|
416
|
+
|
|
417
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
418
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
419
|
+
:returns: Pull request settings payload.
|
|
420
|
+
"""
|
|
421
|
+
|
|
422
|
+
@abstractmethod
|
|
423
|
+
def update_pull_request_settings(
|
|
424
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
425
|
+
) -> PullRequestSettings:
|
|
426
|
+
"""Update pull request settings for a repository.
|
|
427
|
+
|
|
428
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
429
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
430
|
+
:param payload: Pull request settings accepted by the API.
|
|
431
|
+
:returns: API response payload.
|
|
432
|
+
"""
|
|
433
|
+
|
|
434
|
+
@abstractmethod
|
|
435
|
+
def set_member_role(
|
|
436
|
+
self,
|
|
437
|
+
*,
|
|
438
|
+
username: str,
|
|
439
|
+
owner: Optional[str] = None,
|
|
440
|
+
repo: Optional[str] = None,
|
|
441
|
+
permission: Optional[str] = None,
|
|
442
|
+
) -> RepoMember:
|
|
443
|
+
"""Set a repository member role.
|
|
444
|
+
|
|
445
|
+
:param username: Member username or login.
|
|
446
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
447
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
448
|
+
:param permission: Permission or role name accepted by the API.
|
|
449
|
+
:returns: API response payload.
|
|
450
|
+
"""
|
|
451
|
+
|
|
452
|
+
@abstractmethod
|
|
453
|
+
def transfer(
|
|
454
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
455
|
+
) -> RepositoryTransferResult:
|
|
456
|
+
"""Transfer a repository to another owner or namespace.
|
|
457
|
+
|
|
458
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
459
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
460
|
+
:param payload: Transfer options accepted by the API.
|
|
461
|
+
:returns: API response payload.
|
|
462
|
+
"""
|
|
463
|
+
|
|
464
|
+
@abstractmethod
|
|
465
|
+
def list_customized_roles(
|
|
466
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
467
|
+
) -> List[RepositoryCustomizedRole]:
|
|
468
|
+
"""List customized roles for a repository.
|
|
469
|
+
|
|
470
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
471
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
472
|
+
:returns: Customized role definitions.
|
|
473
|
+
"""
|
|
474
|
+
|
|
475
|
+
@abstractmethod
|
|
476
|
+
def get_download_statistics(
|
|
477
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
|
|
478
|
+
) -> RepositoryDownloadStatistics:
|
|
479
|
+
"""Get download statistics for a repository.
|
|
480
|
+
|
|
481
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
482
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
483
|
+
:param params: Query parameters accepted by the statistics endpoint.
|
|
484
|
+
:returns: Download statistics payload.
|
|
485
|
+
"""
|
|
486
|
+
|
|
487
|
+
@abstractmethod
|
|
488
|
+
def get_contributor_statistics(
|
|
489
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
490
|
+
) -> List[ContributorStatistics]:
|
|
491
|
+
"""Get code contribution statistics for a repository.
|
|
492
|
+
|
|
493
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
494
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
495
|
+
:returns: Contributor statistics payload.
|
|
496
|
+
"""
|
|
497
|
+
|
|
498
|
+
@abstractmethod
|
|
499
|
+
def list_events(
|
|
500
|
+
self,
|
|
501
|
+
*,
|
|
502
|
+
owner: Optional[str] = None,
|
|
503
|
+
repo: Optional[str] = None,
|
|
504
|
+
page: Optional[int] = None,
|
|
505
|
+
per_page: Optional[int] = None,
|
|
506
|
+
) -> List[APIObject]:
|
|
507
|
+
"""List repository events.
|
|
508
|
+
|
|
509
|
+
:param owner: Repository owner path. Uses the client default when omitted.
|
|
510
|
+
:param repo: Repository name. Uses the client default when omitted.
|
|
511
|
+
:param page: Page number.
|
|
512
|
+
:param per_page: Page size.
|
|
513
|
+
:returns: Repository event payloads.
|
|
514
|
+
"""
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
class ReposResource(SyncResource, AbstractReposResource):
|
|
518
|
+
"""Synchronous repository endpoints."""
|
|
519
|
+
|
|
520
|
+
def get(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Repository:
|
|
521
|
+
return self._model("GET", self._client._repo_path(owner=owner, repo=repo), Repository)
|
|
522
|
+
|
|
523
|
+
def list_user(
|
|
524
|
+
self,
|
|
525
|
+
*,
|
|
526
|
+
visibility: Optional[str] = None,
|
|
527
|
+
affiliation: Optional[str] = None,
|
|
528
|
+
type: Optional[str] = None,
|
|
529
|
+
sort: Optional[str] = None,
|
|
530
|
+
direction: Optional[str] = None,
|
|
531
|
+
q: Optional[str] = None,
|
|
532
|
+
page: Optional[int] = None,
|
|
533
|
+
per_page: Optional[int] = None,
|
|
534
|
+
) -> List[Repository]:
|
|
535
|
+
return self._models(
|
|
536
|
+
"GET",
|
|
537
|
+
self._client._path("user", "repos"),
|
|
538
|
+
Repository,
|
|
539
|
+
params={
|
|
540
|
+
"visibility": visibility,
|
|
541
|
+
"affiliation": affiliation,
|
|
542
|
+
"type": type,
|
|
543
|
+
"sort": sort,
|
|
544
|
+
"direction": direction,
|
|
545
|
+
"q": q,
|
|
546
|
+
"page": page,
|
|
547
|
+
"per_page": per_page,
|
|
548
|
+
},
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
def list_for_owner(
|
|
552
|
+
self,
|
|
553
|
+
*,
|
|
554
|
+
owner: str,
|
|
555
|
+
type: Optional[str] = None,
|
|
556
|
+
sort: Optional[str] = None,
|
|
557
|
+
direction: Optional[str] = None,
|
|
558
|
+
page: Optional[int] = None,
|
|
559
|
+
per_page: Optional[int] = None,
|
|
560
|
+
) -> List[Repository]:
|
|
561
|
+
return self._models(
|
|
562
|
+
"GET",
|
|
563
|
+
self._client._path("users", owner, "repos"),
|
|
564
|
+
Repository,
|
|
565
|
+
params={
|
|
566
|
+
"type": type,
|
|
567
|
+
"sort": sort,
|
|
568
|
+
"direction": direction,
|
|
569
|
+
"page": page,
|
|
570
|
+
"per_page": per_page,
|
|
571
|
+
},
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
def create_personal(
|
|
575
|
+
self,
|
|
576
|
+
*,
|
|
577
|
+
name: str,
|
|
578
|
+
description: Optional[str] = None,
|
|
579
|
+
path: Optional[str] = None,
|
|
580
|
+
private: Optional[bool] = None,
|
|
581
|
+
auto_init: Optional[bool] = None,
|
|
582
|
+
has_issues: Optional[bool] = None,
|
|
583
|
+
has_wiki: Optional[bool] = None,
|
|
584
|
+
default_branch: Optional[str] = None,
|
|
585
|
+
gitignore_template: Optional[str] = None,
|
|
586
|
+
license_template: Optional[str] = None,
|
|
587
|
+
) -> Repository:
|
|
588
|
+
return self._model(
|
|
589
|
+
"POST",
|
|
590
|
+
self._client._path("user", "repos"),
|
|
591
|
+
Repository,
|
|
592
|
+
json={
|
|
593
|
+
"name": name,
|
|
594
|
+
"description": description,
|
|
595
|
+
"path": path,
|
|
596
|
+
"private": private,
|
|
597
|
+
"auto_init": auto_init,
|
|
598
|
+
"has_issues": has_issues,
|
|
599
|
+
"has_wiki": has_wiki,
|
|
600
|
+
"default_branch": default_branch,
|
|
601
|
+
"gitignore_template": gitignore_template,
|
|
602
|
+
"license_template": license_template,
|
|
603
|
+
},
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
def create_for_org(
|
|
607
|
+
self,
|
|
608
|
+
*,
|
|
609
|
+
org: str,
|
|
610
|
+
name: str,
|
|
611
|
+
description: Optional[str] = None,
|
|
612
|
+
homepage: Optional[str] = None,
|
|
613
|
+
path: Optional[str] = None,
|
|
614
|
+
private: Optional[bool] = None,
|
|
615
|
+
public: Optional[int] = None,
|
|
616
|
+
auto_init: Optional[bool] = None,
|
|
617
|
+
has_issues: Optional[bool] = None,
|
|
618
|
+
has_wiki: Optional[bool] = None,
|
|
619
|
+
can_comment: Optional[bool] = None,
|
|
620
|
+
default_branch: Optional[str] = None,
|
|
621
|
+
gitignore_template: Optional[str] = None,
|
|
622
|
+
license_template: Optional[str] = None,
|
|
623
|
+
) -> Repository:
|
|
624
|
+
return self._model(
|
|
625
|
+
"POST",
|
|
626
|
+
self._client._path("orgs", org, "repos"),
|
|
627
|
+
Repository,
|
|
628
|
+
json={
|
|
629
|
+
"name": name,
|
|
630
|
+
"description": description,
|
|
631
|
+
"homepage": homepage,
|
|
632
|
+
"path": path,
|
|
633
|
+
"private": private,
|
|
634
|
+
"public": public,
|
|
635
|
+
"auto_init": auto_init,
|
|
636
|
+
"has_issues": has_issues,
|
|
637
|
+
"has_wiki": has_wiki,
|
|
638
|
+
"can_comment": can_comment,
|
|
639
|
+
"default_branch": default_branch,
|
|
640
|
+
"gitignore_template": gitignore_template,
|
|
641
|
+
"license_template": license_template,
|
|
642
|
+
},
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
def update(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **changes) -> Repository:
|
|
646
|
+
return self._model("PATCH", self._client._repo_path(owner=owner, repo=repo), Repository, json=changes)
|
|
647
|
+
|
|
648
|
+
def delete(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> None:
|
|
649
|
+
self._request("DELETE", self._client._repo_path(owner=owner, repo=repo))
|
|
650
|
+
|
|
651
|
+
def fork(
|
|
652
|
+
self,
|
|
653
|
+
*,
|
|
654
|
+
owner: Optional[str] = None,
|
|
655
|
+
repo: Optional[str] = None,
|
|
656
|
+
namespace: Optional[str] = None,
|
|
657
|
+
path: Optional[str] = None,
|
|
658
|
+
name: Optional[str] = None,
|
|
659
|
+
) -> Repository:
|
|
660
|
+
return self._model(
|
|
661
|
+
"POST",
|
|
662
|
+
self._client._repo_path("forks", owner=owner, repo=repo),
|
|
663
|
+
Repository,
|
|
664
|
+
json={"namespace": namespace, "path": path, "name": name},
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
def list_forks(
|
|
668
|
+
self,
|
|
669
|
+
*,
|
|
670
|
+
owner: Optional[str] = None,
|
|
671
|
+
repo: Optional[str] = None,
|
|
672
|
+
sort: Optional[str] = None,
|
|
673
|
+
page: Optional[int] = None,
|
|
674
|
+
per_page: Optional[int] = None,
|
|
675
|
+
) -> List[Repository]:
|
|
676
|
+
return self._models(
|
|
677
|
+
"GET",
|
|
678
|
+
self._client._repo_path("forks", owner=owner, repo=repo),
|
|
679
|
+
Repository,
|
|
680
|
+
params={"sort": sort, "page": page, "per_page": per_page},
|
|
681
|
+
)
|
|
682
|
+
|
|
683
|
+
def list_contributors(
|
|
684
|
+
self,
|
|
685
|
+
*,
|
|
686
|
+
owner: Optional[str] = None,
|
|
687
|
+
repo: Optional[str] = None,
|
|
688
|
+
page: Optional[int] = None,
|
|
689
|
+
per_page: Optional[int] = None,
|
|
690
|
+
) -> List[Contributor]:
|
|
691
|
+
return self._models(
|
|
692
|
+
"GET",
|
|
693
|
+
self._client._repo_path("contributors", owner=owner, repo=repo),
|
|
694
|
+
Contributor,
|
|
695
|
+
params={"page": page, "per_page": per_page},
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
def list_languages(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Dict[str, int]:
|
|
699
|
+
return self._request("GET", self._client._repo_path("languages", owner=owner, repo=repo))
|
|
700
|
+
|
|
701
|
+
def list_stargazers(
|
|
702
|
+
self,
|
|
703
|
+
*,
|
|
704
|
+
owner: Optional[str] = None,
|
|
705
|
+
repo: Optional[str] = None,
|
|
706
|
+
page: Optional[int] = None,
|
|
707
|
+
per_page: Optional[int] = None,
|
|
708
|
+
) -> List[UserSummary]:
|
|
709
|
+
return self._models(
|
|
710
|
+
"GET",
|
|
711
|
+
self._client._repo_path("stargazers", owner=owner, repo=repo),
|
|
712
|
+
UserSummary,
|
|
713
|
+
params={"page": page, "per_page": per_page},
|
|
714
|
+
)
|
|
715
|
+
|
|
716
|
+
def list_subscribers(
|
|
717
|
+
self,
|
|
718
|
+
*,
|
|
719
|
+
owner: Optional[str] = None,
|
|
720
|
+
repo: Optional[str] = None,
|
|
721
|
+
page: Optional[int] = None,
|
|
722
|
+
per_page: Optional[int] = None,
|
|
723
|
+
) -> List[UserSummary]:
|
|
724
|
+
return self._models(
|
|
725
|
+
"GET",
|
|
726
|
+
self._client._repo_path("subscribers", owner=owner, repo=repo),
|
|
727
|
+
UserSummary,
|
|
728
|
+
params={"page": page, "per_page": per_page},
|
|
729
|
+
)
|
|
730
|
+
|
|
731
|
+
def update_module_settings(
|
|
732
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **settings
|
|
733
|
+
) -> ApiStatusResponse:
|
|
734
|
+
return self._model(
|
|
735
|
+
"PUT",
|
|
736
|
+
self._client._repo_path("module", "setting", owner=owner, repo=repo),
|
|
737
|
+
ApiStatusResponse,
|
|
738
|
+
json=settings,
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
def update_reviewer_settings(
|
|
742
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **settings
|
|
743
|
+
) -> RepositoryReviewerSettingsUpdate:
|
|
744
|
+
return self._model(
|
|
745
|
+
"PUT",
|
|
746
|
+
self._client._repo_path("reviewer", owner=owner, repo=repo),
|
|
747
|
+
RepositoryReviewerSettingsUpdate,
|
|
748
|
+
json=settings,
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
def set_org_repo_status(self, *, org: str, repo: str, **payload) -> ApiStatusResponse:
|
|
752
|
+
return self._model(
|
|
753
|
+
"PUT", self._client._path("org", org, "repo", repo, "status"), ApiStatusResponse, json=payload
|
|
754
|
+
)
|
|
755
|
+
|
|
756
|
+
def transfer_to_org(self, *, org: str, repo: str, **payload) -> ApiStatusResponse:
|
|
757
|
+
return self._model(
|
|
758
|
+
"POST", self._client._path("org", org, "projects", repo, "transfer"), ApiStatusResponse, json=payload
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
def get_transition(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositoryPermissionMode:
|
|
762
|
+
return self._model(
|
|
763
|
+
"GET", self._client._repo_path("transition", owner=owner, repo=repo), RepositoryPermissionMode
|
|
764
|
+
)
|
|
765
|
+
|
|
766
|
+
def update_transition(
|
|
767
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
768
|
+
) -> ApiStatusResponse:
|
|
769
|
+
return self._model(
|
|
770
|
+
"PUT", self._client._repo_path("transition", owner=owner, repo=repo), ApiStatusResponse, json=payload
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
def update_push_config(
|
|
774
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
775
|
+
) -> RepositoryPushConfig:
|
|
776
|
+
return self._model(
|
|
777
|
+
"PUT", self._client._repo_path("push_config", owner=owner, repo=repo), RepositoryPushConfig, json=payload
|
|
778
|
+
)
|
|
779
|
+
|
|
780
|
+
def get_push_config(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositoryPushConfig:
|
|
781
|
+
return self._model("GET", self._client._repo_path("push_config", owner=owner, repo=repo), RepositoryPushConfig)
|
|
782
|
+
|
|
783
|
+
def upload_image(
|
|
784
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
785
|
+
) -> RepositoryUploadResult:
|
|
786
|
+
return self._model(
|
|
787
|
+
"POST",
|
|
788
|
+
self._client._repo_path("img", "upload", owner=owner, repo=repo),
|
|
789
|
+
RepositoryUploadResult,
|
|
790
|
+
json=payload,
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
def upload_file(
|
|
794
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
795
|
+
) -> RepositoryUploadResult:
|
|
796
|
+
return self._model(
|
|
797
|
+
"POST",
|
|
798
|
+
self._client._repo_path("file", "upload", owner=owner, repo=repo),
|
|
799
|
+
RepositoryUploadResult,
|
|
800
|
+
json=payload,
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
def update_repo_settings(
|
|
804
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
805
|
+
) -> RepositorySettings:
|
|
806
|
+
return self._model(
|
|
807
|
+
"PUT", self._client._repo_path("repo_settings", owner=owner, repo=repo), RepositorySettings, json=payload
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
def get_repo_settings(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositorySettings:
|
|
811
|
+
return self._model("GET", self._client._repo_path("repo_settings", owner=owner, repo=repo), RepositorySettings)
|
|
812
|
+
|
|
813
|
+
def get_pull_request_settings(
|
|
814
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
815
|
+
) -> PullRequestSettings:
|
|
816
|
+
return self._model(
|
|
817
|
+
"GET", self._client._repo_path("pull_request_settings", owner=owner, repo=repo), PullRequestSettings
|
|
818
|
+
)
|
|
819
|
+
|
|
820
|
+
def update_pull_request_settings(
|
|
821
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
822
|
+
) -> PullRequestSettings:
|
|
823
|
+
return self._model(
|
|
824
|
+
"PUT",
|
|
825
|
+
self._client._repo_path("pull_request_settings", owner=owner, repo=repo),
|
|
826
|
+
PullRequestSettings,
|
|
827
|
+
json=payload,
|
|
828
|
+
)
|
|
829
|
+
|
|
830
|
+
def set_member_role(
|
|
831
|
+
self,
|
|
832
|
+
*,
|
|
833
|
+
username: str,
|
|
834
|
+
owner: Optional[str] = None,
|
|
835
|
+
repo: Optional[str] = None,
|
|
836
|
+
permission: Optional[str] = None,
|
|
837
|
+
) -> RepoMember:
|
|
838
|
+
return self._model(
|
|
839
|
+
"PUT",
|
|
840
|
+
self._client._repo_path("members", username, owner=owner, repo=repo),
|
|
841
|
+
RepoMember,
|
|
842
|
+
json={"permission": permission},
|
|
843
|
+
)
|
|
844
|
+
|
|
845
|
+
def transfer(
|
|
846
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
847
|
+
) -> RepositoryTransferResult:
|
|
848
|
+
return self._model(
|
|
849
|
+
"POST", self._client._repo_path("transfer", owner=owner, repo=repo), RepositoryTransferResult, json=payload
|
|
850
|
+
)
|
|
851
|
+
|
|
852
|
+
def list_customized_roles(
|
|
853
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
854
|
+
) -> List[RepositoryCustomizedRole]:
|
|
855
|
+
data = self._request("GET", self._client._repo_path("customized_roles", owner=owner, repo=repo))
|
|
856
|
+
return [as_model(item, RepositoryCustomizedRole) for item in data]
|
|
857
|
+
|
|
858
|
+
def get_download_statistics(
|
|
859
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
|
|
860
|
+
) -> RepositoryDownloadStatistics:
|
|
861
|
+
return self._model(
|
|
862
|
+
"GET",
|
|
863
|
+
self._client._repo_path("download_statistics", owner=owner, repo=repo),
|
|
864
|
+
RepositoryDownloadStatistics,
|
|
865
|
+
params=params,
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
def get_contributor_statistics(
|
|
869
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
870
|
+
) -> List[ContributorStatistics]:
|
|
871
|
+
return self._models(
|
|
872
|
+
"GET",
|
|
873
|
+
self._client._repo_path("contributors", "statistic", owner=owner, repo=repo),
|
|
874
|
+
ContributorStatistics,
|
|
875
|
+
)
|
|
876
|
+
|
|
877
|
+
def list_events(
|
|
878
|
+
self,
|
|
879
|
+
*,
|
|
880
|
+
owner: Optional[str] = None,
|
|
881
|
+
repo: Optional[str] = None,
|
|
882
|
+
page: Optional[int] = None,
|
|
883
|
+
per_page: Optional[int] = None,
|
|
884
|
+
) -> List[APIObject]:
|
|
885
|
+
data = self._request(
|
|
886
|
+
"GET",
|
|
887
|
+
self._client._repo_path("events", owner=owner, repo=repo),
|
|
888
|
+
params={"page": page, "per_page": per_page},
|
|
889
|
+
)
|
|
890
|
+
return [as_model(item, APIObject) for item in data]
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
class AsyncReposResource(AsyncResource, AbstractReposResource):
|
|
894
|
+
"""Asynchronous repository endpoints.
|
|
895
|
+
|
|
896
|
+
Mirrors :class:`ReposResource`; see that class for parameters and JSON fields
|
|
897
|
+
(Repository API in ``docs/rest_api/repos``).
|
|
898
|
+
"""
|
|
899
|
+
|
|
900
|
+
async def get(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Repository:
|
|
901
|
+
return await self._model("GET", self._client._repo_path(owner=owner, repo=repo), Repository)
|
|
902
|
+
|
|
903
|
+
async def list_user(
|
|
904
|
+
self,
|
|
905
|
+
*,
|
|
906
|
+
visibility: Optional[str] = None,
|
|
907
|
+
affiliation: Optional[str] = None,
|
|
908
|
+
type: Optional[str] = None,
|
|
909
|
+
sort: Optional[str] = None,
|
|
910
|
+
direction: Optional[str] = None,
|
|
911
|
+
q: Optional[str] = None,
|
|
912
|
+
page: Optional[int] = None,
|
|
913
|
+
per_page: Optional[int] = None,
|
|
914
|
+
) -> List[Repository]:
|
|
915
|
+
return await self._models(
|
|
916
|
+
"GET",
|
|
917
|
+
self._client._path("user", "repos"),
|
|
918
|
+
Repository,
|
|
919
|
+
params={
|
|
920
|
+
"visibility": visibility,
|
|
921
|
+
"affiliation": affiliation,
|
|
922
|
+
"type": type,
|
|
923
|
+
"sort": sort,
|
|
924
|
+
"direction": direction,
|
|
925
|
+
"q": q,
|
|
926
|
+
"page": page,
|
|
927
|
+
"per_page": per_page,
|
|
928
|
+
},
|
|
929
|
+
)
|
|
930
|
+
|
|
931
|
+
async def list_for_owner(
|
|
932
|
+
self,
|
|
933
|
+
*,
|
|
934
|
+
owner: str,
|
|
935
|
+
type: Optional[str] = None,
|
|
936
|
+
sort: Optional[str] = None,
|
|
937
|
+
direction: Optional[str] = None,
|
|
938
|
+
page: Optional[int] = None,
|
|
939
|
+
per_page: Optional[int] = None,
|
|
940
|
+
) -> List[Repository]:
|
|
941
|
+
return await self._models(
|
|
942
|
+
"GET",
|
|
943
|
+
self._client._path("users", owner, "repos"),
|
|
944
|
+
Repository,
|
|
945
|
+
params={
|
|
946
|
+
"type": type,
|
|
947
|
+
"sort": sort,
|
|
948
|
+
"direction": direction,
|
|
949
|
+
"page": page,
|
|
950
|
+
"per_page": per_page,
|
|
951
|
+
},
|
|
952
|
+
)
|
|
953
|
+
|
|
954
|
+
async def create_personal(
|
|
955
|
+
self,
|
|
956
|
+
*,
|
|
957
|
+
name: str,
|
|
958
|
+
description: Optional[str] = None,
|
|
959
|
+
path: Optional[str] = None,
|
|
960
|
+
private: Optional[bool] = None,
|
|
961
|
+
auto_init: Optional[bool] = None,
|
|
962
|
+
has_issues: Optional[bool] = None,
|
|
963
|
+
has_wiki: Optional[bool] = None,
|
|
964
|
+
default_branch: Optional[str] = None,
|
|
965
|
+
gitignore_template: Optional[str] = None,
|
|
966
|
+
license_template: Optional[str] = None,
|
|
967
|
+
) -> Repository:
|
|
968
|
+
return await self._model(
|
|
969
|
+
"POST",
|
|
970
|
+
self._client._path("user", "repos"),
|
|
971
|
+
Repository,
|
|
972
|
+
json={
|
|
973
|
+
"name": name,
|
|
974
|
+
"description": description,
|
|
975
|
+
"path": path,
|
|
976
|
+
"private": private,
|
|
977
|
+
"auto_init": auto_init,
|
|
978
|
+
"has_issues": has_issues,
|
|
979
|
+
"has_wiki": has_wiki,
|
|
980
|
+
"default_branch": default_branch,
|
|
981
|
+
"gitignore_template": gitignore_template,
|
|
982
|
+
"license_template": license_template,
|
|
983
|
+
},
|
|
984
|
+
)
|
|
985
|
+
|
|
986
|
+
async def create_for_org(
|
|
987
|
+
self,
|
|
988
|
+
*,
|
|
989
|
+
org: str,
|
|
990
|
+
name: str,
|
|
991
|
+
description: Optional[str] = None,
|
|
992
|
+
homepage: Optional[str] = None,
|
|
993
|
+
path: Optional[str] = None,
|
|
994
|
+
private: Optional[bool] = None,
|
|
995
|
+
public: Optional[int] = None,
|
|
996
|
+
auto_init: Optional[bool] = None,
|
|
997
|
+
has_issues: Optional[bool] = None,
|
|
998
|
+
has_wiki: Optional[bool] = None,
|
|
999
|
+
can_comment: Optional[bool] = None,
|
|
1000
|
+
default_branch: Optional[str] = None,
|
|
1001
|
+
gitignore_template: Optional[str] = None,
|
|
1002
|
+
license_template: Optional[str] = None,
|
|
1003
|
+
) -> Repository:
|
|
1004
|
+
return await self._model(
|
|
1005
|
+
"POST",
|
|
1006
|
+
self._client._path("orgs", org, "repos"),
|
|
1007
|
+
Repository,
|
|
1008
|
+
json={
|
|
1009
|
+
"name": name,
|
|
1010
|
+
"description": description,
|
|
1011
|
+
"homepage": homepage,
|
|
1012
|
+
"path": path,
|
|
1013
|
+
"private": private,
|
|
1014
|
+
"public": public,
|
|
1015
|
+
"auto_init": auto_init,
|
|
1016
|
+
"has_issues": has_issues,
|
|
1017
|
+
"has_wiki": has_wiki,
|
|
1018
|
+
"can_comment": can_comment,
|
|
1019
|
+
"default_branch": default_branch,
|
|
1020
|
+
"gitignore_template": gitignore_template,
|
|
1021
|
+
"license_template": license_template,
|
|
1022
|
+
},
|
|
1023
|
+
)
|
|
1024
|
+
|
|
1025
|
+
async def update(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **changes) -> Repository:
|
|
1026
|
+
return await self._model("PATCH", self._client._repo_path(owner=owner, repo=repo), Repository, json=changes)
|
|
1027
|
+
|
|
1028
|
+
async def delete(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> None:
|
|
1029
|
+
await self._request("DELETE", self._client._repo_path(owner=owner, repo=repo))
|
|
1030
|
+
|
|
1031
|
+
async def fork(
|
|
1032
|
+
self,
|
|
1033
|
+
*,
|
|
1034
|
+
owner: Optional[str] = None,
|
|
1035
|
+
repo: Optional[str] = None,
|
|
1036
|
+
namespace: Optional[str] = None,
|
|
1037
|
+
path: Optional[str] = None,
|
|
1038
|
+
name: Optional[str] = None,
|
|
1039
|
+
) -> Repository:
|
|
1040
|
+
return await self._model(
|
|
1041
|
+
"POST",
|
|
1042
|
+
self._client._repo_path("forks", owner=owner, repo=repo),
|
|
1043
|
+
Repository,
|
|
1044
|
+
json={"namespace": namespace, "path": path, "name": name},
|
|
1045
|
+
)
|
|
1046
|
+
|
|
1047
|
+
async def list_forks(
|
|
1048
|
+
self,
|
|
1049
|
+
*,
|
|
1050
|
+
owner: Optional[str] = None,
|
|
1051
|
+
repo: Optional[str] = None,
|
|
1052
|
+
sort: Optional[str] = None,
|
|
1053
|
+
page: Optional[int] = None,
|
|
1054
|
+
per_page: Optional[int] = None,
|
|
1055
|
+
) -> List[Repository]:
|
|
1056
|
+
return await self._models(
|
|
1057
|
+
"GET",
|
|
1058
|
+
self._client._repo_path("forks", owner=owner, repo=repo),
|
|
1059
|
+
Repository,
|
|
1060
|
+
params={"sort": sort, "page": page, "per_page": per_page},
|
|
1061
|
+
)
|
|
1062
|
+
|
|
1063
|
+
async def list_contributors(
|
|
1064
|
+
self,
|
|
1065
|
+
*,
|
|
1066
|
+
owner: Optional[str] = None,
|
|
1067
|
+
repo: Optional[str] = None,
|
|
1068
|
+
page: Optional[int] = None,
|
|
1069
|
+
per_page: Optional[int] = None,
|
|
1070
|
+
) -> List[Contributor]:
|
|
1071
|
+
return await self._models(
|
|
1072
|
+
"GET",
|
|
1073
|
+
self._client._repo_path("contributors", owner=owner, repo=repo),
|
|
1074
|
+
Contributor,
|
|
1075
|
+
params={"page": page, "per_page": per_page},
|
|
1076
|
+
)
|
|
1077
|
+
|
|
1078
|
+
async def list_languages(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Dict[str, int]:
|
|
1079
|
+
return await self._request("GET", self._client._repo_path("languages", owner=owner, repo=repo))
|
|
1080
|
+
|
|
1081
|
+
async def list_stargazers(
|
|
1082
|
+
self,
|
|
1083
|
+
*,
|
|
1084
|
+
owner: Optional[str] = None,
|
|
1085
|
+
repo: Optional[str] = None,
|
|
1086
|
+
page: Optional[int] = None,
|
|
1087
|
+
per_page: Optional[int] = None,
|
|
1088
|
+
) -> List[UserSummary]:
|
|
1089
|
+
return await self._models(
|
|
1090
|
+
"GET",
|
|
1091
|
+
self._client._repo_path("stargazers", owner=owner, repo=repo),
|
|
1092
|
+
UserSummary,
|
|
1093
|
+
params={"page": page, "per_page": per_page},
|
|
1094
|
+
)
|
|
1095
|
+
|
|
1096
|
+
async def list_subscribers(
|
|
1097
|
+
self,
|
|
1098
|
+
*,
|
|
1099
|
+
owner: Optional[str] = None,
|
|
1100
|
+
repo: Optional[str] = None,
|
|
1101
|
+
page: Optional[int] = None,
|
|
1102
|
+
per_page: Optional[int] = None,
|
|
1103
|
+
) -> List[UserSummary]:
|
|
1104
|
+
return await self._models(
|
|
1105
|
+
"GET",
|
|
1106
|
+
self._client._repo_path("subscribers", owner=owner, repo=repo),
|
|
1107
|
+
UserSummary,
|
|
1108
|
+
params={"page": page, "per_page": per_page},
|
|
1109
|
+
)
|
|
1110
|
+
|
|
1111
|
+
async def update_module_settings(
|
|
1112
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **settings
|
|
1113
|
+
) -> ApiStatusResponse:
|
|
1114
|
+
return await self._model(
|
|
1115
|
+
"PUT",
|
|
1116
|
+
self._client._repo_path("module", "setting", owner=owner, repo=repo),
|
|
1117
|
+
ApiStatusResponse,
|
|
1118
|
+
json=settings,
|
|
1119
|
+
)
|
|
1120
|
+
|
|
1121
|
+
async def update_reviewer_settings(
|
|
1122
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **settings
|
|
1123
|
+
) -> RepositoryReviewerSettingsUpdate:
|
|
1124
|
+
return await self._model(
|
|
1125
|
+
"PUT",
|
|
1126
|
+
self._client._repo_path("reviewer", owner=owner, repo=repo),
|
|
1127
|
+
RepositoryReviewerSettingsUpdate,
|
|
1128
|
+
json=settings,
|
|
1129
|
+
)
|
|
1130
|
+
|
|
1131
|
+
async def set_org_repo_status(self, *, org: str, repo: str, **payload) -> ApiStatusResponse:
|
|
1132
|
+
return await self._model(
|
|
1133
|
+
"PUT", self._client._path("org", org, "repo", repo, "status"), ApiStatusResponse, json=payload
|
|
1134
|
+
)
|
|
1135
|
+
|
|
1136
|
+
async def transfer_to_org(self, *, org: str, repo: str, **payload) -> ApiStatusResponse:
|
|
1137
|
+
return await self._model(
|
|
1138
|
+
"POST", self._client._path("org", org, "projects", repo, "transfer"), ApiStatusResponse, json=payload
|
|
1139
|
+
)
|
|
1140
|
+
|
|
1141
|
+
async def get_transition(
|
|
1142
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
1143
|
+
) -> RepositoryPermissionMode:
|
|
1144
|
+
return await self._model(
|
|
1145
|
+
"GET", self._client._repo_path("transition", owner=owner, repo=repo), RepositoryPermissionMode
|
|
1146
|
+
)
|
|
1147
|
+
|
|
1148
|
+
async def update_transition(
|
|
1149
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1150
|
+
) -> ApiStatusResponse:
|
|
1151
|
+
return await self._model(
|
|
1152
|
+
"PUT", self._client._repo_path("transition", owner=owner, repo=repo), ApiStatusResponse, json=payload
|
|
1153
|
+
)
|
|
1154
|
+
|
|
1155
|
+
async def update_push_config(
|
|
1156
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1157
|
+
) -> RepositoryPushConfig:
|
|
1158
|
+
return await self._model(
|
|
1159
|
+
"PUT",
|
|
1160
|
+
self._client._repo_path("push_config", owner=owner, repo=repo),
|
|
1161
|
+
RepositoryPushConfig,
|
|
1162
|
+
json=payload,
|
|
1163
|
+
)
|
|
1164
|
+
|
|
1165
|
+
async def get_push_config(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositoryPushConfig:
|
|
1166
|
+
return await self._model(
|
|
1167
|
+
"GET", self._client._repo_path("push_config", owner=owner, repo=repo), RepositoryPushConfig
|
|
1168
|
+
)
|
|
1169
|
+
|
|
1170
|
+
async def upload_image(
|
|
1171
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1172
|
+
) -> RepositoryUploadResult:
|
|
1173
|
+
return await self._model(
|
|
1174
|
+
"POST",
|
|
1175
|
+
self._client._repo_path("img", "upload", owner=owner, repo=repo),
|
|
1176
|
+
RepositoryUploadResult,
|
|
1177
|
+
json=payload,
|
|
1178
|
+
)
|
|
1179
|
+
|
|
1180
|
+
async def upload_file(
|
|
1181
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1182
|
+
) -> RepositoryUploadResult:
|
|
1183
|
+
return await self._model(
|
|
1184
|
+
"POST",
|
|
1185
|
+
self._client._repo_path("file", "upload", owner=owner, repo=repo),
|
|
1186
|
+
RepositoryUploadResult,
|
|
1187
|
+
json=payload,
|
|
1188
|
+
)
|
|
1189
|
+
|
|
1190
|
+
async def update_repo_settings(
|
|
1191
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1192
|
+
) -> RepositorySettings:
|
|
1193
|
+
return await self._model(
|
|
1194
|
+
"PUT", self._client._repo_path("repo_settings", owner=owner, repo=repo), RepositorySettings, json=payload
|
|
1195
|
+
)
|
|
1196
|
+
|
|
1197
|
+
async def get_repo_settings(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> RepositorySettings:
|
|
1198
|
+
return await self._model(
|
|
1199
|
+
"GET", self._client._repo_path("repo_settings", owner=owner, repo=repo), RepositorySettings
|
|
1200
|
+
)
|
|
1201
|
+
|
|
1202
|
+
async def get_pull_request_settings(
|
|
1203
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
1204
|
+
) -> PullRequestSettings:
|
|
1205
|
+
return await self._model(
|
|
1206
|
+
"GET", self._client._repo_path("pull_request_settings", owner=owner, repo=repo), PullRequestSettings
|
|
1207
|
+
)
|
|
1208
|
+
|
|
1209
|
+
async def update_pull_request_settings(
|
|
1210
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1211
|
+
) -> PullRequestSettings:
|
|
1212
|
+
return await self._model(
|
|
1213
|
+
"PUT",
|
|
1214
|
+
self._client._repo_path("pull_request_settings", owner=owner, repo=repo),
|
|
1215
|
+
PullRequestSettings,
|
|
1216
|
+
json=payload,
|
|
1217
|
+
)
|
|
1218
|
+
|
|
1219
|
+
async def set_member_role(
|
|
1220
|
+
self,
|
|
1221
|
+
*,
|
|
1222
|
+
username: str,
|
|
1223
|
+
owner: Optional[str] = None,
|
|
1224
|
+
repo: Optional[str] = None,
|
|
1225
|
+
permission: Optional[str] = None,
|
|
1226
|
+
) -> RepoMember:
|
|
1227
|
+
return await self._model(
|
|
1228
|
+
"PUT",
|
|
1229
|
+
self._client._repo_path("members", username, owner=owner, repo=repo),
|
|
1230
|
+
RepoMember,
|
|
1231
|
+
json={"permission": permission},
|
|
1232
|
+
)
|
|
1233
|
+
|
|
1234
|
+
async def transfer(
|
|
1235
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload
|
|
1236
|
+
) -> RepositoryTransferResult:
|
|
1237
|
+
return await self._model(
|
|
1238
|
+
"POST", self._client._repo_path("transfer", owner=owner, repo=repo), RepositoryTransferResult, json=payload
|
|
1239
|
+
)
|
|
1240
|
+
|
|
1241
|
+
async def list_customized_roles(
|
|
1242
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
1243
|
+
) -> List[RepositoryCustomizedRole]:
|
|
1244
|
+
data = await self._request("GET", self._client._repo_path("customized_roles", owner=owner, repo=repo))
|
|
1245
|
+
return [as_model(item, RepositoryCustomizedRole) for item in data]
|
|
1246
|
+
|
|
1247
|
+
async def get_download_statistics(
|
|
1248
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
|
|
1249
|
+
) -> RepositoryDownloadStatistics:
|
|
1250
|
+
return await self._model(
|
|
1251
|
+
"GET",
|
|
1252
|
+
self._client._repo_path("download_statistics", owner=owner, repo=repo),
|
|
1253
|
+
RepositoryDownloadStatistics,
|
|
1254
|
+
params=params,
|
|
1255
|
+
)
|
|
1256
|
+
|
|
1257
|
+
async def get_contributor_statistics(
|
|
1258
|
+
self, *, owner: Optional[str] = None, repo: Optional[str] = None
|
|
1259
|
+
) -> List[ContributorStatistics]:
|
|
1260
|
+
return await self._models(
|
|
1261
|
+
"GET",
|
|
1262
|
+
self._client._repo_path("contributors", "statistic", owner=owner, repo=repo),
|
|
1263
|
+
ContributorStatistics,
|
|
1264
|
+
)
|
|
1265
|
+
|
|
1266
|
+
async def list_events(
|
|
1267
|
+
self,
|
|
1268
|
+
*,
|
|
1269
|
+
owner: Optional[str] = None,
|
|
1270
|
+
repo: Optional[str] = None,
|
|
1271
|
+
page: Optional[int] = None,
|
|
1272
|
+
per_page: Optional[int] = None,
|
|
1273
|
+
) -> List[APIObject]:
|
|
1274
|
+
data = await self._request(
|
|
1275
|
+
"GET",
|
|
1276
|
+
self._client._repo_path("events", owner=owner, repo=repo),
|
|
1277
|
+
params={"page": page, "per_page": per_page},
|
|
1278
|
+
)
|
|
1279
|
+
return [as_model(item, APIObject) for item in data]
|