Skip to content
Snippets Groups Projects
Commit 8ccbd9e9 authored by Christopher Bohn's avatar Christopher Bohn 🤔
Browse files

added Milestones to gitlab api

parent bc31b709
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ from datetime import datetime ...@@ -2,7 +2,7 @@ from datetime import datetime
from typing import ClassVar, Dict, Iterable, List, Optional, Set, Union from typing import ClassVar, Dict, Iterable, List, Optional, Set, Union
from gitlab import Gitlab, MAINTAINER_ACCESS from gitlab import Gitlab, MAINTAINER_ACCESS
from gitlab.v4.objects import Issue, Project, ProjectCommit, User from gitlab.v4.objects import Issue, Project, ProjectCommit, ProjectMilestone, User
from config import Config from config import Config
...@@ -250,6 +250,24 @@ class GitlabCommit: ...@@ -250,6 +250,24 @@ class GitlabCommit:
# project_id # project_id
class GitlabMilestone:
gitlab_milestone: ProjectMilestone
def __init__(self, milestone: ProjectMilestone):
super().__init__()
self.gitlab_milestone = milestone
def get_issues(self) -> List[GitlabIssue]:
"""
:return: List of Issue objects representing project's issues
"""
gitlab_issues: Iterable[Issue] = self.gitlab_milestone.issues()
issues: List[GitlabIssue] = []
for issue in gitlab_issues:
issues.append(GitlabIssue(issue))
return issues
class GitlabProject: class GitlabProject:
git_project: Project git_project: Project
...@@ -390,6 +408,16 @@ class GitlabProject: ...@@ -390,6 +408,16 @@ class GitlabProject:
def add_user_as_maintainer(self, user: GitlabUser) -> None: def add_user_as_maintainer(self, user: GitlabUser) -> None:
self.git_project.members.create({'user_id': user.get_user_id(), 'access_level': MAINTAINER_ACCESS}) self.git_project.members.create({'user_id': user.get_user_id(), 'access_level': MAINTAINER_ACCESS})
def get_milestones(self) -> List[GitlabMilestone]:
"""
:return: List of Milestone objects representing the project's milestones
"""
gitlab_milestones: Iterable[ProjectMilestone] = self.git_project.milestones.list()
milestones: List[GitlabMilestone] = []
for milestone in gitlab_milestones:
milestones.append(GitlabMilestone(milestone))
return milestones
def get_issues(self) -> List[GitlabIssue]: def get_issues(self) -> List[GitlabIssue]:
""" """
:return: List of Issue objects representing project's issues, sorted by creation date :return: List of Issue objects representing project's issues, sorted by creation date
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment