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.
Files changed (43) hide show
  1. gitcode_api/__init__.py +8 -2
  2. gitcode_api/_base_client.py +7 -2
  3. gitcode_api/_exceptions.py +8 -0
  4. gitcode_api/exceptions.py +19 -0
  5. gitcode_api/llm/mcp.py +5 -5
  6. gitcode_api/models.py +205 -0
  7. gitcode_api/resources/__init__.py +1 -1
  8. gitcode_api/resources/_shared/__init__.py +18 -0
  9. gitcode_api/resources/_shared/base.py +129 -0
  10. gitcode_api/resources/{_shared.py → _shared/fetch_template.py} +133 -259
  11. gitcode_api/resources/account/__init__.py +17 -0
  12. gitcode_api/resources/account/oauth_resource_group.py +159 -0
  13. gitcode_api/resources/account/orgs_resource_group.py +422 -0
  14. gitcode_api/resources/account/search_resource_group.py +236 -0
  15. gitcode_api/resources/account/users_resource_group.py +249 -0
  16. gitcode_api/resources/collaboration/__init__.py +20 -0
  17. gitcode_api/resources/collaboration/_helpers.py +10 -0
  18. gitcode_api/resources/collaboration/issues_resource_group.py +855 -0
  19. gitcode_api/resources/collaboration/labels_resource_group.py +248 -0
  20. gitcode_api/resources/collaboration/members_resource_group.py +195 -0
  21. gitcode_api/resources/collaboration/milestones_resource_group.py +192 -0
  22. gitcode_api/resources/collaboration/pulls_resource_group.py +1300 -0
  23. gitcode_api/resources/misc/__init__.py +14 -0
  24. gitcode_api/resources/misc/releases_resource_group.py +445 -0
  25. gitcode_api/resources/misc/tags_resource_group.py +286 -0
  26. gitcode_api/resources/misc/webhooks_resource_group.py +192 -0
  27. gitcode_api/resources/repositories/__init__.py +17 -0
  28. gitcode_api/resources/repositories/branches_resource_group.py +151 -0
  29. gitcode_api/resources/repositories/commits_resource_group.py +333 -0
  30. gitcode_api/resources/repositories/repo_contents_resource_group.py +459 -0
  31. gitcode_api/resources/repositories/repos_resource_group.py +1279 -0
  32. gitcode_api/version.txt +1 -1
  33. {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/METADATA +3 -3
  34. gitcode_api-1.3.0.dist-info/RECORD +52 -0
  35. gitcode_api/resources/account.py +0 -1086
  36. gitcode_api/resources/collaboration.py +0 -2818
  37. gitcode_api/resources/misc.py +0 -901
  38. gitcode_api/resources/repositories.py +0 -2197
  39. gitcode_api-1.2.20.dist-info/RECORD +0 -31
  40. {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/WHEEL +0 -0
  41. {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/entry_points.txt +0 -0
  42. {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/licenses/LICENSE +0 -0
  43. {gitcode_api-1.2.20.dist-info → gitcode_api-1.3.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,333 @@
1
+ """AbstractCommitsResource, CommitsResource, and AsyncCommitsResource resource group."""
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import List, Optional, Union
5
+
6
+ from ..._models import (
7
+ Commit,
8
+ CommitComment,
9
+ CommitComparison,
10
+ CommitSummary,
11
+ )
12
+ from .._shared import AsyncResource, SyncResource
13
+
14
+ # mypy: disable-error-code=override
15
+ # pylint: disable=invalid-overridden-method,protected-access,redefined-builtin
16
+
17
+
18
+ class AbstractCommitsResource(ABC):
19
+ """Interface for Commits resource endpoints."""
20
+
21
+ @abstractmethod
22
+ def list(
23
+ self,
24
+ *,
25
+ owner: Optional[str] = None,
26
+ repo: Optional[str] = None,
27
+ sha: Optional[str] = None,
28
+ path: Optional[str] = None,
29
+ page: Optional[int] = None,
30
+ per_page: Optional[int] = None,
31
+ ) -> List[CommitSummary]:
32
+ """List commits in a repository.
33
+
34
+ :param owner: Repository owner path. Uses the client default when omitted.
35
+ :param repo: Repository name. Uses the client default when omitted.
36
+ :param sha: Optional starting SHA or ref.
37
+ :param path: Optional file path filter.
38
+ :param page: Page number.
39
+ :param per_page: Page size.
40
+ :returns: Matching commits.
41
+ """
42
+
43
+ @abstractmethod
44
+ def get(self, *, sha: str, owner: Optional[str] = None, repo: Optional[str] = None) -> Commit:
45
+ """Get a single commit.
46
+
47
+ :param sha: Commit SHA or branch name accepted by the API.
48
+ :param owner: Repository owner path. Uses the client default when omitted.
49
+ :param repo: Repository name. Uses the client default when omitted.
50
+ :returns: Commit details.
51
+ """
52
+
53
+ @abstractmethod
54
+ def compare(
55
+ self, *, base: str, head: str, owner: Optional[str] = None, repo: Optional[str] = None
56
+ ) -> CommitComparison:
57
+ """Compare two refs in a repository.
58
+
59
+ :param base: Base commit SHA, branch, or tag.
60
+ :param head: Head commit SHA, branch, or tag.
61
+ :param owner: Repository owner path. Uses the client default when omitted.
62
+ :param repo: Repository name. Uses the client default when omitted.
63
+ :returns: Commit comparison payload.
64
+ """
65
+
66
+ @abstractmethod
67
+ def list_comments(
68
+ self,
69
+ *,
70
+ owner: Optional[str] = None,
71
+ repo: Optional[str] = None,
72
+ page: Optional[int] = None,
73
+ per_page: Optional[int] = None,
74
+ ) -> List[CommitComment]:
75
+ """List commit comments for a repository.
76
+
77
+ :param owner: Repository owner path. Uses the client default when omitted.
78
+ :param repo: Repository name. Uses the client default when omitted.
79
+ :param page: Page number.
80
+ :param per_page: Page size.
81
+ :returns: Commit comments.
82
+ """
83
+
84
+ @abstractmethod
85
+ def get_comment(
86
+ self,
87
+ *,
88
+ comment_id: Union[int, str],
89
+ owner: Optional[str] = None,
90
+ repo: Optional[str] = None,
91
+ ) -> CommitComment:
92
+ """Get a single commit comment.
93
+
94
+ :param comment_id: Commit comment identifier.
95
+ :param owner: Repository owner path. Uses the client default when omitted.
96
+ :param repo: Repository name. Uses the client default when omitted.
97
+ :returns: Commit comment details.
98
+ """
99
+
100
+ @abstractmethod
101
+ def create_comment(
102
+ self,
103
+ *,
104
+ sha: str,
105
+ body: str,
106
+ owner: Optional[str] = None,
107
+ repo: Optional[str] = None,
108
+ path: Optional[str] = None,
109
+ position: Optional[int] = None,
110
+ ) -> CommitComment:
111
+ """Create a comment on a commit.
112
+
113
+ :param sha: Commit SHA.
114
+ :param body: Comment body.
115
+ :param owner: Repository owner path. Uses the client default when omitted.
116
+ :param repo: Repository name. Uses the client default when omitted.
117
+ :param path: Optional file path associated with the comment.
118
+ :param position: Optional diff position.
119
+ :returns: Created commit comment.
120
+ """
121
+
122
+ @abstractmethod
123
+ def update_comment(
124
+ self,
125
+ *,
126
+ comment_id: Union[int, str],
127
+ body: str,
128
+ owner: Optional[str] = None,
129
+ repo: Optional[str] = None,
130
+ ) -> CommitComment:
131
+ """Update a commit comment.
132
+
133
+ :param comment_id: Commit comment identifier.
134
+ :param body: Updated comment body.
135
+ :param owner: Repository owner path. Uses the client default when omitted.
136
+ :param repo: Repository name. Uses the client default when omitted.
137
+ :returns: Updated commit comment.
138
+ """
139
+
140
+ @abstractmethod
141
+ def delete_comment(
142
+ self, *, comment_id: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None
143
+ ) -> None:
144
+ """Delete a commit comment.
145
+
146
+ :param comment_id: Commit comment identifier.
147
+ :param owner: Repository owner path. Uses the client default when omitted.
148
+ :param repo: Repository name. Uses the client default when omitted.
149
+ """
150
+
151
+
152
+ class CommitsResource(SyncResource, AbstractCommitsResource):
153
+ """Synchronous commit endpoints."""
154
+
155
+ def list(
156
+ self,
157
+ *,
158
+ owner: Optional[str] = None,
159
+ repo: Optional[str] = None,
160
+ sha: Optional[str] = None,
161
+ path: Optional[str] = None,
162
+ page: Optional[int] = None,
163
+ per_page: Optional[int] = None,
164
+ ) -> List[CommitSummary]:
165
+ return self._models(
166
+ "GET",
167
+ self._client._repo_path("commits", owner=owner, repo=repo),
168
+ CommitSummary,
169
+ params={"sha": sha, "path": path, "page": page, "per_page": per_page},
170
+ )
171
+
172
+ def get(self, *, sha: str, owner: Optional[str] = None, repo: Optional[str] = None) -> Commit:
173
+ return self._model("GET", self._client._repo_path("commits", sha, owner=owner, repo=repo), Commit)
174
+
175
+ def compare(
176
+ self, *, base: str, head: str, owner: Optional[str] = None, repo: Optional[str] = None
177
+ ) -> CommitComparison:
178
+ return self._model(
179
+ "GET",
180
+ self._client._repo_path("compare", f"{base}...{head}", owner=owner, repo=repo),
181
+ CommitComparison,
182
+ )
183
+
184
+ def list_comments(
185
+ self,
186
+ *,
187
+ owner: Optional[str] = None,
188
+ repo: Optional[str] = None,
189
+ page: Optional[int] = None,
190
+ per_page: Optional[int] = None,
191
+ ) -> List[CommitComment]:
192
+ return self._models(
193
+ "GET",
194
+ self._client._repo_path("comments", owner=owner, repo=repo),
195
+ CommitComment,
196
+ params={"page": page, "per_page": per_page},
197
+ )
198
+
199
+ def get_comment(
200
+ self,
201
+ *,
202
+ comment_id: Union[int, str],
203
+ owner: Optional[str] = None,
204
+ repo: Optional[str] = None,
205
+ ) -> CommitComment:
206
+ return self._model(
207
+ "GET", self._client._repo_path("comments", comment_id, owner=owner, repo=repo), CommitComment
208
+ )
209
+
210
+ def create_comment(
211
+ self,
212
+ *,
213
+ sha: str,
214
+ body: str,
215
+ owner: Optional[str] = None,
216
+ repo: Optional[str] = None,
217
+ path: Optional[str] = None,
218
+ position: Optional[int] = None,
219
+ ) -> CommitComment:
220
+ return self._model(
221
+ "POST",
222
+ self._client._repo_path("commits", sha, "comments", owner=owner, repo=repo),
223
+ CommitComment,
224
+ json={"body": body, "path": path, "position": position},
225
+ )
226
+
227
+ def update_comment(
228
+ self,
229
+ *,
230
+ comment_id: Union[int, str],
231
+ body: str,
232
+ owner: Optional[str] = None,
233
+ repo: Optional[str] = None,
234
+ ) -> CommitComment:
235
+ return self._model(
236
+ "PATCH",
237
+ self._client._repo_path("comments", comment_id, owner=owner, repo=repo),
238
+ CommitComment,
239
+ json={"body": body},
240
+ )
241
+
242
+ def delete_comment(
243
+ self, *, comment_id: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None
244
+ ) -> None:
245
+ self._request("DELETE", self._client._repo_path("comments", comment_id, owner=owner, repo=repo))
246
+
247
+
248
+ class AsyncCommitsResource(AsyncResource, AbstractCommitsResource):
249
+ """Asynchronous commit endpoints.
250
+
251
+ Mirrors :class:`CommitsResource` (``docs/rest_api/repos/commit``).
252
+ """
253
+
254
+ async def list(
255
+ self,
256
+ *,
257
+ owner: Optional[str] = None,
258
+ repo: Optional[str] = None,
259
+ sha: Optional[str] = None,
260
+ path: Optional[str] = None,
261
+ page: Optional[int] = None,
262
+ per_page: Optional[int] = None,
263
+ ) -> List[CommitSummary]:
264
+ return await self._models(
265
+ "GET",
266
+ self._client._repo_path("commits", owner=owner, repo=repo),
267
+ CommitSummary,
268
+ params={"sha": sha, "path": path, "page": page, "per_page": per_page},
269
+ )
270
+
271
+ async def get(self, *, sha: str, owner: Optional[str] = None, repo: Optional[str] = None) -> Commit:
272
+ return await self._model("GET", self._client._repo_path("commits", sha, owner=owner, repo=repo), Commit)
273
+
274
+ async def compare(
275
+ self, *, base: str, head: str, owner: Optional[str] = None, repo: Optional[str] = None
276
+ ) -> CommitComparison:
277
+ return await self._model(
278
+ "GET", self._client._repo_path("compare", f"{base}...{head}", owner=owner, repo=repo), CommitComparison
279
+ )
280
+
281
+ async def list_comments(
282
+ self,
283
+ *,
284
+ owner: Optional[str] = None,
285
+ repo: Optional[str] = None,
286
+ page: Optional[int] = None,
287
+ per_page: Optional[int] = None,
288
+ ) -> List[CommitComment]:
289
+ return await self._models(
290
+ "GET",
291
+ self._client._repo_path("comments", owner=owner, repo=repo),
292
+ CommitComment,
293
+ params={"page": page, "per_page": per_page},
294
+ )
295
+
296
+ async def get_comment(
297
+ self, *, comment_id: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None
298
+ ) -> CommitComment:
299
+ return await self._model(
300
+ "GET", self._client._repo_path("comments", comment_id, owner=owner, repo=repo), CommitComment
301
+ )
302
+
303
+ async def create_comment(
304
+ self,
305
+ *,
306
+ sha: str,
307
+ body: str,
308
+ owner: Optional[str] = None,
309
+ repo: Optional[str] = None,
310
+ path: Optional[str] = None,
311
+ position: Optional[int] = None,
312
+ ) -> CommitComment:
313
+ return await self._model(
314
+ "POST",
315
+ self._client._repo_path("commits", sha, "comments", owner=owner, repo=repo),
316
+ CommitComment,
317
+ json={"body": body, "path": path, "position": position},
318
+ )
319
+
320
+ async def update_comment(
321
+ self, *, comment_id: Union[int, str], body: str, owner: Optional[str] = None, repo: Optional[str] = None
322
+ ) -> CommitComment:
323
+ return await self._model(
324
+ "PATCH",
325
+ self._client._repo_path("comments", comment_id, owner=owner, repo=repo),
326
+ CommitComment,
327
+ json={"body": body},
328
+ )
329
+
330
+ async def delete_comment(
331
+ self, *, comment_id: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None
332
+ ) -> None:
333
+ await self._request("DELETE", self._client._repo_path("comments", comment_id, owner=owner, repo=repo))