lupaxa-github-extractor 0.1.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.
- lupaxa/github_extractor/__init__.py +98 -0
- lupaxa/github_extractor/__main__.py +10 -0
- lupaxa/github_extractor/cli.py +383 -0
- lupaxa/github_extractor/client.py +390 -0
- lupaxa/github_extractor/constants.py +10 -0
- lupaxa/github_extractor/convert.py +182 -0
- lupaxa/github_extractor/errors.py +76 -0
- lupaxa/github_extractor/filters.py +47 -0
- lupaxa/github_extractor/http.py +289 -0
- lupaxa/github_extractor/models.py +362 -0
- lupaxa/github_extractor/pool.py +34 -0
- lupaxa/github_extractor/resources.py +66 -0
- lupaxa/github_extractor/version.py +10 -0
- lupaxa_github_extractor-0.1.0.dist-info/METADATA +175 -0
- lupaxa_github_extractor-0.1.0.dist-info/RECORD +19 -0
- lupaxa_github_extractor-0.1.0.dist-info/WHEEL +5 -0
- lupaxa_github_extractor-0.1.0.dist-info/entry_points.txt +2 -0
- lupaxa_github_extractor-0.1.0.dist-info/licenses/LICENCE +21 -0
- lupaxa_github_extractor-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Glob include and ignore filters for organisations and repositories."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping, Sequence
|
|
6
|
+
import fnmatch
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def selected(value: str, include: Sequence[str], ignore: Sequence[str]) -> bool:
|
|
11
|
+
"""Return whether a value passes include and ignore globs."""
|
|
12
|
+
folded = value.casefold()
|
|
13
|
+
for pattern in ignore:
|
|
14
|
+
if fnmatch.fnmatch(folded, pattern.casefold()):
|
|
15
|
+
return False
|
|
16
|
+
if not include:
|
|
17
|
+
return True
|
|
18
|
+
return any(fnmatch.fnmatch(folded, pattern.casefold()) for pattern in include)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# fmt: off
|
|
22
|
+
def keep_repo(repo: Mapping[str, Any], *, include: Sequence[str], ignore: Sequence[str], include_names: Sequence[str], ignore_names: Sequence[str], skip_private: bool) -> bool: # noqa: E501
|
|
23
|
+
# fmt: on
|
|
24
|
+
"""Return whether a repository dict passes repository-level filters."""
|
|
25
|
+
if skip_private and repo.get("private") is True:
|
|
26
|
+
return False
|
|
27
|
+
full_name = str(repo.get("full_name") or "")
|
|
28
|
+
name = str(repo.get("name") or "")
|
|
29
|
+
return selected(full_name, include, ignore) and selected(name, include_names, ignore_names)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# fmt: off
|
|
33
|
+
def filter_repositories(rows: Sequence[Mapping[str, Any]], *, include: Sequence[str], ignore: Sequence[str], include_names: Sequence[str], ignore_names: Sequence[str], skip_private: bool) -> list[dict[str, Any]]: # noqa: E501
|
|
34
|
+
# fmt: on
|
|
35
|
+
"""Copy repository rows that pass all repository filters."""
|
|
36
|
+
return [
|
|
37
|
+
dict(row)
|
|
38
|
+
for row in rows
|
|
39
|
+
if keep_repo(
|
|
40
|
+
row,
|
|
41
|
+
include=include,
|
|
42
|
+
ignore=ignore,
|
|
43
|
+
include_names=include_names,
|
|
44
|
+
ignore_names=ignore_names,
|
|
45
|
+
skip_private=skip_private,
|
|
46
|
+
)
|
|
47
|
+
]
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"""Synchronous GitHub HTTP access with paging and safe domain errors."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import UTC
|
|
6
|
+
from email.utils import parsedate_to_datetime
|
|
7
|
+
import threading
|
|
8
|
+
import time
|
|
9
|
+
from typing import Any, cast
|
|
10
|
+
from urllib.parse import parse_qsl, urlsplit
|
|
11
|
+
|
|
12
|
+
import requests
|
|
13
|
+
|
|
14
|
+
from .constants import API_ACCEPT, API_ROOT, API_VERSION, PER_PAGE, USER_AGENT
|
|
15
|
+
from .errors import (
|
|
16
|
+
AuthenticationError,
|
|
17
|
+
ForbiddenError,
|
|
18
|
+
NotFoundError,
|
|
19
|
+
RateLimitExceededError,
|
|
20
|
+
RequestError,
|
|
21
|
+
RequestTimeoutError,
|
|
22
|
+
ResourceStatusError,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _normalise_api_root(api_root: str) -> str:
|
|
27
|
+
"""Return an https API root, or reject it."""
|
|
28
|
+
root = api_root.strip().rstrip("/")
|
|
29
|
+
parts = urlsplit(root)
|
|
30
|
+
if parts.scheme != "https" or not parts.hostname or parts.username or parts.password:
|
|
31
|
+
raise ValueError("api_root must be an https URL")
|
|
32
|
+
return root
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _copy_session_settings(source: requests.Session, target: requests.Session) -> None:
|
|
36
|
+
"""Copy transport settings. Skip attributes the source does not have."""
|
|
37
|
+
if hasattr(source, "proxies"):
|
|
38
|
+
target.proxies = dict(source.proxies)
|
|
39
|
+
for name in ("verify", "cert", "trust_env", "max_redirects"):
|
|
40
|
+
if hasattr(source, name):
|
|
41
|
+
setattr(target, name, getattr(source, name))
|
|
42
|
+
cookies = getattr(source, "cookies", None)
|
|
43
|
+
if cookies is not None and hasattr(cookies, "copy") and hasattr(target, "cookies"):
|
|
44
|
+
target.cookies = cookies.copy()
|
|
45
|
+
adapters = getattr(source, "adapters", None)
|
|
46
|
+
if isinstance(adapters, dict) and hasattr(target, "mount"):
|
|
47
|
+
for prefix, adapter in adapters.items():
|
|
48
|
+
target.mount(prefix, adapter)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _same_api_host(url: str, api_root: str) -> bool:
|
|
52
|
+
"""Return whether a URL is https on the API root host with no userinfo."""
|
|
53
|
+
parts = urlsplit(url)
|
|
54
|
+
root = urlsplit(api_root)
|
|
55
|
+
return parts.scheme == "https" and parts.hostname == root.hostname and parts.username is None and parts.password is None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class GitHubHttp:
|
|
59
|
+
"""Send authenticated requests to the GitHub REST API."""
|
|
60
|
+
|
|
61
|
+
# fmt: off
|
|
62
|
+
def __init__(self, token: str, timeout: float, session: requests.Session | None = None, *, max_pages: int | None = None, api_root: str = API_ROOT) -> None: # noqa: E501
|
|
63
|
+
# fmt: on
|
|
64
|
+
"""Store request settings and create a session when needed."""
|
|
65
|
+
if max_pages is not None and (type(max_pages) is not int or max_pages <= 0):
|
|
66
|
+
raise ValueError("max_pages must be a positive integer")
|
|
67
|
+
self._api_root = _normalise_api_root(api_root)
|
|
68
|
+
self._owner_thread = threading.get_ident()
|
|
69
|
+
self._local = threading.local()
|
|
70
|
+
self._timeout = timeout
|
|
71
|
+
self._session = session or requests.Session()
|
|
72
|
+
self._lock = threading.Lock()
|
|
73
|
+
self._max_pages = max_pages
|
|
74
|
+
self._headers = {
|
|
75
|
+
"Authorization": f"Bearer {token}",
|
|
76
|
+
"Accept": API_ACCEPT,
|
|
77
|
+
"X-GitHub-Api-Version": API_VERSION,
|
|
78
|
+
"User-Agent": USER_AGENT,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
def get_response(self, path: str) -> requests.Response:
|
|
82
|
+
"""Return one checked response without following pagination."""
|
|
83
|
+
return self._get(path, params=None)
|
|
84
|
+
|
|
85
|
+
def get_json(self, path: str, *, params: dict[str, Any] | None = None, merge_key: str | None = None) -> Any: # noqa: ANN401 - JSON may contain any valid JSON value.
|
|
86
|
+
"""Return JSON, following list or selected dictionary pagination."""
|
|
87
|
+
query_names = {key for key, _value in parse_qsl(urlsplit(path).query, keep_blank_values=True)}
|
|
88
|
+
request_params = dict(params or {})
|
|
89
|
+
if "per_page" not in query_names and "per_page" not in request_params:
|
|
90
|
+
request_params["per_page"] = PER_PAGE
|
|
91
|
+
response = self._get(path, params=request_params)
|
|
92
|
+
body = _response_json(response)
|
|
93
|
+
if merge_key is not None:
|
|
94
|
+
return self._merge_pages(response, body, merge_key)
|
|
95
|
+
if isinstance(body, list):
|
|
96
|
+
return self._merge_list_pages(response, body)
|
|
97
|
+
if isinstance(body, dict) and _list_keys(body) and _next_url(response) is not None:
|
|
98
|
+
return self._merge_object_pages(response, body)
|
|
99
|
+
return body
|
|
100
|
+
|
|
101
|
+
def _request_url(self, path: str) -> str:
|
|
102
|
+
"""Join a relative path, or reject an absolute URL on another host."""
|
|
103
|
+
if path.startswith("/") and not path.startswith("//"):
|
|
104
|
+
return f"{self._api_root}{path}"
|
|
105
|
+
if _same_api_host(path, self._api_root):
|
|
106
|
+
return path
|
|
107
|
+
raise RequestError("Request failed")
|
|
108
|
+
|
|
109
|
+
def _get(self, path: str, *, params: dict[str, Any] | None, retried: bool = False) -> requests.Response:
|
|
110
|
+
"""Send one GET request and map transport and HTTP failures."""
|
|
111
|
+
url = self._request_url(path)
|
|
112
|
+
try:
|
|
113
|
+
response = self._session_for_request().get(
|
|
114
|
+
url,
|
|
115
|
+
headers=self._headers,
|
|
116
|
+
params=params,
|
|
117
|
+
timeout=self._timeout,
|
|
118
|
+
)
|
|
119
|
+
except requests.Timeout:
|
|
120
|
+
raise RequestTimeoutError("Request timed out") from None
|
|
121
|
+
except requests.RequestException:
|
|
122
|
+
raise RequestError("Request failed") from None
|
|
123
|
+
if not retried and _is_rate_limited(response):
|
|
124
|
+
wait = _rate_limit_wait(response, time.time())
|
|
125
|
+
if wait is None:
|
|
126
|
+
raise RateLimitExceededError("Rate limit exceeded")
|
|
127
|
+
time.sleep(wait)
|
|
128
|
+
return self._get(path, params=params, retried=True)
|
|
129
|
+
self._check_status(response)
|
|
130
|
+
return response
|
|
131
|
+
|
|
132
|
+
def _session_for_request(self) -> requests.Session:
|
|
133
|
+
"""Use the caller session on its thread and a private session on workers."""
|
|
134
|
+
if threading.get_ident() == self._owner_thread:
|
|
135
|
+
return self._session
|
|
136
|
+
existing = getattr(self._local, "session", None)
|
|
137
|
+
if existing is not None:
|
|
138
|
+
return cast(requests.Session, existing)
|
|
139
|
+
with self._lock:
|
|
140
|
+
existing = getattr(self._local, "session", None)
|
|
141
|
+
if existing is None:
|
|
142
|
+
existing = requests.Session()
|
|
143
|
+
_copy_session_settings(self._session, existing)
|
|
144
|
+
self._local.session = existing
|
|
145
|
+
return cast(requests.Session, existing)
|
|
146
|
+
|
|
147
|
+
def _merge_list_pages(self, response: requests.Response, body: list[Any]) -> list[Any]:
|
|
148
|
+
"""Follow list pages and concatenate their items."""
|
|
149
|
+
items = list(body)
|
|
150
|
+
pages = 1
|
|
151
|
+
next_url = _next_url(response)
|
|
152
|
+
while next_url is not None and (self._max_pages is None or pages < self._max_pages):
|
|
153
|
+
response = self._get(next_url, params=None)
|
|
154
|
+
pages += 1
|
|
155
|
+
items.extend(cast(list[Any], _response_json(response)))
|
|
156
|
+
next_url = _next_url(response)
|
|
157
|
+
return items
|
|
158
|
+
|
|
159
|
+
def _merge_object_pages(self, response: requests.Response, body: dict[str, Any]) -> dict[str, Any]:
|
|
160
|
+
"""Concatenate list fields and keep scalars from the first page."""
|
|
161
|
+
merged = dict(body)
|
|
162
|
+
keys = _list_keys(body)
|
|
163
|
+
for key in keys:
|
|
164
|
+
merged[key] = list(merged[key])
|
|
165
|
+
pages = 1
|
|
166
|
+
next_url = _next_url(response)
|
|
167
|
+
while next_url is not None and (self._max_pages is None or pages < self._max_pages):
|
|
168
|
+
response = self._get(next_url, params=None)
|
|
169
|
+
pages += 1
|
|
170
|
+
page = _response_json(response)
|
|
171
|
+
if isinstance(page, dict):
|
|
172
|
+
for key in keys:
|
|
173
|
+
extra = page.get(key, [])
|
|
174
|
+
if isinstance(extra, list):
|
|
175
|
+
cast(list[Any], merged[key]).extend(extra)
|
|
176
|
+
next_url = _next_url(response)
|
|
177
|
+
return merged
|
|
178
|
+
|
|
179
|
+
def _merge_pages(self, response: requests.Response, body: object, merge_key: str) -> dict[str, Any]:
|
|
180
|
+
"""Follow dictionary pages and merge one selected item list."""
|
|
181
|
+
items = _items_for_key(body, merge_key)
|
|
182
|
+
pages = 1
|
|
183
|
+
next_url = _next_url(response)
|
|
184
|
+
while next_url is not None and (self._max_pages is None or pages < self._max_pages):
|
|
185
|
+
response = self._get(next_url, params=None)
|
|
186
|
+
pages += 1
|
|
187
|
+
items.extend(_items_for_key(_response_json(response), merge_key))
|
|
188
|
+
next_url = _next_url(response)
|
|
189
|
+
return {"total_count": len(items), merge_key: items}
|
|
190
|
+
|
|
191
|
+
@staticmethod
|
|
192
|
+
def _check_status(response: requests.Response) -> None:
|
|
193
|
+
"""Raise a safe domain error for a failed HTTP status."""
|
|
194
|
+
if response.status_code < 400:
|
|
195
|
+
return
|
|
196
|
+
if response.status_code == 401:
|
|
197
|
+
raise AuthenticationError("Authentication failed")
|
|
198
|
+
if response.status_code == 403:
|
|
199
|
+
if _is_rate_limited(response):
|
|
200
|
+
raise RateLimitExceededError("Rate limit exceeded")
|
|
201
|
+
raise ForbiddenError("Forbidden")
|
|
202
|
+
if response.status_code == 404:
|
|
203
|
+
raise NotFoundError("Not found")
|
|
204
|
+
if response.status_code == 409:
|
|
205
|
+
raise ResourceStatusError(409, "Conflict")
|
|
206
|
+
if response.status_code == 410:
|
|
207
|
+
raise ResourceStatusError(410, "Gone")
|
|
208
|
+
if response.status_code == 429:
|
|
209
|
+
raise RateLimitExceededError("Rate limit exceeded")
|
|
210
|
+
raise RequestError("Request failed")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def _response_json(response: requests.Response) -> Any: # noqa: ANN401
|
|
214
|
+
"""Return successful JSON while mapping empty or invalid bodies safely."""
|
|
215
|
+
if response.status_code == 204:
|
|
216
|
+
return []
|
|
217
|
+
if not response.content:
|
|
218
|
+
raise RequestError("Request returned an empty response")
|
|
219
|
+
try:
|
|
220
|
+
return response.json()
|
|
221
|
+
except ValueError:
|
|
222
|
+
raise RequestError("Request returned invalid JSON") from None
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _list_keys(body: dict[str, Any]) -> list[str]:
|
|
226
|
+
"""Return keys whose first-page value is a list."""
|
|
227
|
+
return [key for key, value in body.items() if isinstance(value, list)]
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _items_for_key(body: object, merge_key: str) -> list[Any]:
|
|
231
|
+
"""Read a merge list from a dictionary response body."""
|
|
232
|
+
response_body = cast(dict[str, Any], body)
|
|
233
|
+
return list(cast(list[Any], response_body.get(merge_key, [])))
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def _is_rate_limited(response: requests.Response) -> bool:
|
|
237
|
+
"""Return whether a forbidden response represents rate limiting."""
|
|
238
|
+
if response.status_code == 429:
|
|
239
|
+
return True
|
|
240
|
+
if response.status_code != 403:
|
|
241
|
+
return False
|
|
242
|
+
if response.headers.get("X-RateLimit-Remaining") == "0":
|
|
243
|
+
return True
|
|
244
|
+
if response.headers.get("Retry-After") is not None:
|
|
245
|
+
return True
|
|
246
|
+
try:
|
|
247
|
+
body = response.json()
|
|
248
|
+
except ValueError:
|
|
249
|
+
return False
|
|
250
|
+
if not isinstance(body, dict):
|
|
251
|
+
return False
|
|
252
|
+
message = body.get("message")
|
|
253
|
+
return isinstance(message, str) and "rate limit" in message.casefold()
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _rate_limit_wait(response: requests.Response, now: float) -> float | None:
|
|
257
|
+
"""Return the non-negative seconds to wait, or None when no wait is known."""
|
|
258
|
+
retry_after = response.headers.get("Retry-After")
|
|
259
|
+
if retry_after is not None:
|
|
260
|
+
try:
|
|
261
|
+
return max(0.0, float(retry_after))
|
|
262
|
+
except ValueError:
|
|
263
|
+
try:
|
|
264
|
+
parsed = parsedate_to_datetime(retry_after)
|
|
265
|
+
if parsed.tzinfo is None:
|
|
266
|
+
parsed = parsed.replace(tzinfo=UTC)
|
|
267
|
+
return max(0.0, parsed.timestamp() - now)
|
|
268
|
+
except (ValueError, TypeError):
|
|
269
|
+
pass
|
|
270
|
+
reset = response.headers.get("X-RateLimit-Reset")
|
|
271
|
+
if reset is None:
|
|
272
|
+
return None
|
|
273
|
+
try:
|
|
274
|
+
return max(0.0, float(reset) - now)
|
|
275
|
+
except ValueError:
|
|
276
|
+
return None
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _next_url(response: requests.Response) -> str | None:
|
|
280
|
+
"""Extract the next-page URL from a GitHub Link header."""
|
|
281
|
+
link = response.headers.get("Link", "")
|
|
282
|
+
for part in link.split(","):
|
|
283
|
+
if 'rel="next"' not in part:
|
|
284
|
+
continue
|
|
285
|
+
start = part.find("<")
|
|
286
|
+
end = part.find(">", start + 1)
|
|
287
|
+
if start >= 0 and end > start:
|
|
288
|
+
return part[start + 1 : end]
|
|
289
|
+
return None
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"""Dataclass models for GitHub objects."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from typing import Any, ClassVar
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class GitHubObject:
|
|
11
|
+
"""A GitHub object backed by its raw JSON."""
|
|
12
|
+
|
|
13
|
+
raw: dict[str, Any] = field(default_factory=dict)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class ResourceError:
|
|
18
|
+
"""An error recorded while fetching an attached resource."""
|
|
19
|
+
|
|
20
|
+
addon: str
|
|
21
|
+
status: int
|
|
22
|
+
message: str
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _optional(key: str) -> property:
|
|
26
|
+
"""Read a JSON key, or None when GitHub omitted it."""
|
|
27
|
+
|
|
28
|
+
def getter(self: GitHubObject) -> Any: # noqa: ANN401
|
|
29
|
+
return self.raw.get(key)
|
|
30
|
+
|
|
31
|
+
return property(getter)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _required(key: str) -> property:
|
|
35
|
+
"""Read a JSON key the client already requires."""
|
|
36
|
+
|
|
37
|
+
def getter(self: GitHubObject) -> Any: # noqa: ANN401
|
|
38
|
+
return self.raw[key]
|
|
39
|
+
|
|
40
|
+
return property(getter)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class TokenInformation(GitHubObject):
|
|
45
|
+
"""Token metadata and rate-limit information."""
|
|
46
|
+
|
|
47
|
+
scopes = _optional("scopes")
|
|
48
|
+
rate_limit_limit = _optional("rate_limit_limit")
|
|
49
|
+
rate_limit_remaining = _optional("rate_limit_remaining")
|
|
50
|
+
rate_limit_used = _optional("rate_limit_used")
|
|
51
|
+
rate_limit_reset = _optional("rate_limit_reset")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class Email(GitHubObject):
|
|
56
|
+
"""One email address."""
|
|
57
|
+
|
|
58
|
+
email = _optional("email")
|
|
59
|
+
primary = _optional("primary")
|
|
60
|
+
verified = _optional("verified")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class GpgKey(GitHubObject):
|
|
65
|
+
"""One GPG key."""
|
|
66
|
+
|
|
67
|
+
key_id = _optional("key_id")
|
|
68
|
+
public_key = _optional("public_key")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass
|
|
72
|
+
class SshKey(GitHubObject):
|
|
73
|
+
"""One SSH key."""
|
|
74
|
+
|
|
75
|
+
id = _optional("id")
|
|
76
|
+
key = _optional("key")
|
|
77
|
+
title = _optional("title")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass
|
|
81
|
+
class Branch(GitHubObject):
|
|
82
|
+
"""One repository branch."""
|
|
83
|
+
|
|
84
|
+
name = _optional("name")
|
|
85
|
+
protected = _optional("protected")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass
|
|
89
|
+
class Contributor(GitHubObject):
|
|
90
|
+
"""One repository contributor."""
|
|
91
|
+
|
|
92
|
+
login = _optional("login")
|
|
93
|
+
contributions = _optional("contributions")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass
|
|
97
|
+
class Release(GitHubObject):
|
|
98
|
+
"""One repository release."""
|
|
99
|
+
|
|
100
|
+
tag_name = _optional("tag_name")
|
|
101
|
+
name = _optional("name")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@dataclass
|
|
105
|
+
class Tag(GitHubObject):
|
|
106
|
+
"""One repository tag."""
|
|
107
|
+
|
|
108
|
+
name = _optional("name")
|
|
109
|
+
commit = _optional("commit")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@dataclass
|
|
113
|
+
class Topics(GitHubObject):
|
|
114
|
+
"""Repository topic names."""
|
|
115
|
+
|
|
116
|
+
names = _optional("names")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@dataclass
|
|
120
|
+
class Workflow(GitHubObject):
|
|
121
|
+
"""One GitHub Actions workflow."""
|
|
122
|
+
|
|
123
|
+
id = _optional("id")
|
|
124
|
+
name = _optional("name")
|
|
125
|
+
state = _optional("state")
|
|
126
|
+
path = _optional("path")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@dataclass
|
|
130
|
+
class Commit(GitHubObject):
|
|
131
|
+
"""One repository commit."""
|
|
132
|
+
|
|
133
|
+
sha = _optional("sha")
|
|
134
|
+
commit = _optional("commit")
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass
|
|
138
|
+
class Issue(GitHubObject):
|
|
139
|
+
"""One repository issue."""
|
|
140
|
+
|
|
141
|
+
number = _optional("number")
|
|
142
|
+
title = _optional("title")
|
|
143
|
+
state = _optional("state")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@dataclass
|
|
147
|
+
class PullRequest(GitHubObject):
|
|
148
|
+
"""One pull request."""
|
|
149
|
+
|
|
150
|
+
number = _optional("number")
|
|
151
|
+
title = _optional("title")
|
|
152
|
+
state = _optional("state")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@dataclass
|
|
156
|
+
class Milestone(GitHubObject):
|
|
157
|
+
"""One repository milestone."""
|
|
158
|
+
|
|
159
|
+
number = _optional("number")
|
|
160
|
+
title = _optional("title")
|
|
161
|
+
state = _optional("state")
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass
|
|
165
|
+
class Fork(GitHubObject):
|
|
166
|
+
"""One repository fork."""
|
|
167
|
+
|
|
168
|
+
full_name = _required("full_name")
|
|
169
|
+
name = _optional("name")
|
|
170
|
+
private = _optional("private")
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@dataclass
|
|
174
|
+
class Stargazer(GitHubObject):
|
|
175
|
+
"""One repository stargazer."""
|
|
176
|
+
|
|
177
|
+
login = _required("login")
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@dataclass
|
|
181
|
+
class Subscriber(GitHubObject):
|
|
182
|
+
"""One repository subscriber."""
|
|
183
|
+
|
|
184
|
+
login = _required("login")
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@dataclass
|
|
188
|
+
class Team(GitHubObject):
|
|
189
|
+
"""One organisation team."""
|
|
190
|
+
|
|
191
|
+
name = _optional("name")
|
|
192
|
+
slug = _optional("slug")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dataclass
|
|
196
|
+
class Event(GitHubObject):
|
|
197
|
+
"""One organisation event."""
|
|
198
|
+
|
|
199
|
+
id = _optional("id")
|
|
200
|
+
type = _optional("type")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@dataclass
|
|
204
|
+
class Hook(GitHubObject):
|
|
205
|
+
"""One organisation hook."""
|
|
206
|
+
|
|
207
|
+
id = _optional("id")
|
|
208
|
+
name = _optional("name")
|
|
209
|
+
active = _optional("active")
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@dataclass
|
|
213
|
+
class Collaborator(GitHubObject):
|
|
214
|
+
"""One repository collaborator."""
|
|
215
|
+
|
|
216
|
+
login = _required("login")
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@dataclass
|
|
220
|
+
class Label(GitHubObject):
|
|
221
|
+
"""One issue label."""
|
|
222
|
+
|
|
223
|
+
name = _optional("name")
|
|
224
|
+
color = _optional("color")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@dataclass
|
|
228
|
+
class WorkflowRun(GitHubObject):
|
|
229
|
+
"""One GitHub Actions workflow run."""
|
|
230
|
+
|
|
231
|
+
id = _optional("id")
|
|
232
|
+
name = _optional("name")
|
|
233
|
+
status = _optional("status")
|
|
234
|
+
conclusion = _optional("conclusion")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@dataclass
|
|
238
|
+
class Deployment(GitHubObject):
|
|
239
|
+
"""One repository deployment."""
|
|
240
|
+
|
|
241
|
+
id = _optional("id")
|
|
242
|
+
environment = _optional("environment")
|
|
243
|
+
sha = _optional("sha")
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
@dataclass
|
|
247
|
+
class Environment(GitHubObject):
|
|
248
|
+
"""One repository environment."""
|
|
249
|
+
|
|
250
|
+
name = _optional("name")
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@dataclass
|
|
254
|
+
class Content(GitHubObject):
|
|
255
|
+
"""One file or directory from the contents list."""
|
|
256
|
+
|
|
257
|
+
name = _optional("name")
|
|
258
|
+
path = _optional("path")
|
|
259
|
+
type = _optional("type")
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
@dataclass
|
|
263
|
+
class Notification(GitHubObject):
|
|
264
|
+
"""One notification for the authenticated user."""
|
|
265
|
+
|
|
266
|
+
id = _optional("id")
|
|
267
|
+
reason = _optional("reason")
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@dataclass
|
|
271
|
+
class AuditEvent(GitHubObject):
|
|
272
|
+
"""One organisation audit-log event."""
|
|
273
|
+
|
|
274
|
+
action = _optional("action")
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@dataclass
|
|
278
|
+
class Repository(GitHubObject):
|
|
279
|
+
"""One repository plus the resources that were requested."""
|
|
280
|
+
|
|
281
|
+
branches: list[Branch] | None = None
|
|
282
|
+
contributors: list[Contributor] | None = None
|
|
283
|
+
languages: dict[str, int] | list[Any] | None = None
|
|
284
|
+
releases: list[Release] | None = None
|
|
285
|
+
tags: list[Tag] | None = None
|
|
286
|
+
topics: Topics | list[Any] | None = None
|
|
287
|
+
workflows: list[Workflow] | None = None
|
|
288
|
+
commits: list[Commit] | None = None
|
|
289
|
+
issues: list[Issue] | None = None
|
|
290
|
+
pulls: list[PullRequest] | None = None
|
|
291
|
+
milestones: list[Milestone] | None = None
|
|
292
|
+
forks: list[Fork] | None = None
|
|
293
|
+
stargazers: list[Stargazer] | None = None
|
|
294
|
+
subscribers: list[Subscriber] | None = None
|
|
295
|
+
collaborators: list[Collaborator] | None = None
|
|
296
|
+
labels: list[Label] | None = None
|
|
297
|
+
workflow_runs: list[WorkflowRun] | None = None
|
|
298
|
+
deployments: list[Deployment] | None = None
|
|
299
|
+
environments: list[Environment] | None = None
|
|
300
|
+
contents: list[Content] | None = None
|
|
301
|
+
errors: list[ResourceError] = field(default_factory=list)
|
|
302
|
+
attached: ClassVar[tuple[str, ...]] = (
|
|
303
|
+
"branches",
|
|
304
|
+
"contributors",
|
|
305
|
+
"languages",
|
|
306
|
+
"releases",
|
|
307
|
+
"tags",
|
|
308
|
+
"topics",
|
|
309
|
+
"workflows",
|
|
310
|
+
"commits",
|
|
311
|
+
"issues",
|
|
312
|
+
"pulls",
|
|
313
|
+
"milestones",
|
|
314
|
+
"forks",
|
|
315
|
+
"stargazers",
|
|
316
|
+
"subscribers",
|
|
317
|
+
"collaborators",
|
|
318
|
+
"labels",
|
|
319
|
+
"workflow_runs",
|
|
320
|
+
"deployments",
|
|
321
|
+
"environments",
|
|
322
|
+
"contents",
|
|
323
|
+
)
|
|
324
|
+
full_name = _required("full_name")
|
|
325
|
+
name = _optional("name")
|
|
326
|
+
private = _optional("private")
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
@dataclass
|
|
330
|
+
class Organisation(GitHubObject):
|
|
331
|
+
"""One organisation plus the resources that were requested."""
|
|
332
|
+
|
|
333
|
+
members: list[User] | None = None
|
|
334
|
+
teams: list[Team] | None = None
|
|
335
|
+
events: list[Event] | None = None
|
|
336
|
+
hooks: list[Hook] | None = None
|
|
337
|
+
audit_log: list[AuditEvent] | None = None
|
|
338
|
+
errors: list[ResourceError] = field(default_factory=list)
|
|
339
|
+
attached: ClassVar[tuple[str, ...]] = ("members", "teams", "events", "hooks", "audit_log")
|
|
340
|
+
login = _required("login")
|
|
341
|
+
id = _optional("id")
|
|
342
|
+
description = _optional("description")
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
@dataclass
|
|
346
|
+
class User(GitHubObject):
|
|
347
|
+
"""One user plus the resources that were requested."""
|
|
348
|
+
|
|
349
|
+
emails: list[Email] | None = None
|
|
350
|
+
followers: list[User] | None = None
|
|
351
|
+
following: list[User] | None = None
|
|
352
|
+
gpg_keys: list[GpgKey] | None = None
|
|
353
|
+
ssh_keys: list[SshKey] | None = None
|
|
354
|
+
repos: list[Repository] | None = None
|
|
355
|
+
starred: list[Repository] | None = None
|
|
356
|
+
subscriptions: list[Repository] | None = None
|
|
357
|
+
notifications: list[Notification] | None = None
|
|
358
|
+
errors: list[ResourceError] = field(default_factory=list)
|
|
359
|
+
attached: ClassVar[tuple[str, ...]] = ("emails", "followers", "following", "gpg_keys", "ssh_keys", "repos", "starred", "subscriptions", "notifications")
|
|
360
|
+
login = _required("login")
|
|
361
|
+
id = _optional("id")
|
|
362
|
+
name = _optional("name")
|