blob: 444d10c93dad8f78f1a841eb7b0cf871ede708a3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
from requests import get
from tomlkit import dumps
project_id = 11167699
per_page = 100
url = f"https://gitlab.com/api/v4/projects/{project_id}/issues?per_page={per_page}"
def pages_iterator(first):
current = first
while current.links.get('next'):
current.raise_for_status()
yield current
current = get(url = current.links.get('next').get('url'))
current.raise_for_status()
yield current
def main():
for response in pages_iterator(get(url = url)):
print(f"Current page: {response.headers['x-page']}")
data = response.json()
for i in data:
issue = {
"id": i['iid'],
"title": i['title'],
"state": i['state'],
"description": i['description'],
"created_at": i['created_at'],
"closed_at": i['closed_at'] if i['closed_at'] else "n/a",
"labels": i['labels'],
"url": i['web_url']
}
toml_string = dumps(issue)
print(toml_string)
if __name__ == "__main__":
main()
|