67 lines
1.3 KiB
Python
67 lines
1.3 KiB
Python
import json
|
|
import logging
|
|
|
|
from .utils import get, gitlab_url
|
|
|
|
|
|
def get_user(args):
|
|
logging.debug("get_user called")
|
|
|
|
url = gitlab_url("/user")
|
|
|
|
result = get(url, args)
|
|
|
|
return result
|
|
|
|
|
|
def list_projects(args):
|
|
logging.debug("list_projects called")
|
|
user_id = get_user(args)["id"]
|
|
|
|
url = gitlab_url(
|
|
f"/users/{user_id}/projects?pagination=offset&per_page=500&"
|
|
"order_by=name&sort=asc"
|
|
)
|
|
|
|
result = get(url, args)
|
|
|
|
return result
|
|
|
|
|
|
def get_project_details(args):
|
|
user_id = get_user(args)["id"]
|
|
url = gitlab_url(
|
|
f"/users/{user_id}/projects?pagination=offset&per_page=500&"
|
|
"order_by=name&sort=asc"
|
|
)
|
|
|
|
response = get(url, args)
|
|
|
|
project = [
|
|
project
|
|
for project in response
|
|
if (project["name"] == args.project or project["id"] == args.project)
|
|
][0]
|
|
|
|
if not project:
|
|
raise KeyError(f"Project {args.project} not found")
|
|
|
|
print(json.dumps(project))
|
|
|
|
|
|
def get_issues(args):
|
|
project_id = args.project_id
|
|
url = gitlab_url(
|
|
f"/projects/{project_id}/issues?pagination=offset&per_page=500&"
|
|
)
|
|
|
|
response = get(url, args)
|
|
|
|
return response
|
|
|
|
|
|
def get_wiki(args):
|
|
url = gitlab_url(f"/projects/{args.project_id}/wikis?with_content=1")
|
|
response = get(url, args)
|
|
|
|
return response
|