def get_list( project: "ogr_gitlab.GitlabProject", status: IssueStatus = IssueStatus.open, author: Optional[str] = None, assignee: Optional[str] = None, labels: Optional[List[str]] = None, ) -> List["Issue"]: if not project.has_issues: raise IssueTrackerDisabled() # Gitlab API has status 'opened', not 'open' parameters: Dict[str, Union[str, List[str], bool]] = { "state": status.name if status != IssueStatus.open else "opened", "order_by": "updated_at", "sort": "desc", "all": True, } if author: parameters["author_username"] = author if assignee: parameters["assignee_username"] = assignee if labels: parameters["labels"] = labels issues = project.gitlab_repo.issues.list(**parameters) return [GitlabIssue(issue, project) for issue in issues]
def create( project: "ogr_gitlab.GitlabProject", title: str, body: str, private: Optional[bool] = None, labels: Optional[List[str]] = None, assignees: Optional[List[str]] = None, ) -> "Issue": if not project.has_issues: raise IssueTrackerDisabled() assignee_ids = [] for user in assignees or []: users_list = project.service.gitlab_instance.users.list( username=user) if not users_list: raise GitlabAPIException(f"Unable to find '{user}' username") assignee_ids.append(str(users_list[0].id)) data = {"title": title, "description": body} if labels: data["labels"] = ",".join(labels) if assignees: data["assignee_ids"] = ",".join(assignee_ids) issue = project.gitlab_repo.issues.create(data, confidential=private) return GitlabIssue(issue, project)
def get_list( project: "ogr_pagure.PagureProject", status: IssueStatus = IssueStatus.open, author: Optional[str] = None, assignee: Optional[str] = None, labels: Optional[List[str]] = None, ) -> List["Issue"]: if not project.has_issues: raise IssueTrackerDisabled() payload: Dict[str, Union[str, List[str], int]] = { "status": status.name.capitalize(), "page": 1, "per_page": 100, } if author: payload["author"] = author if assignee: payload["assignee"] = assignee if labels: payload["tags"] = labels raw_issues: List[Any] = [] while True: issues_info = project._call_project_api("issues", params=payload) raw_issues += issues_info["issues"] if not issues_info["pagination"]["next"]: break payload["page"] = cast(int, payload["page"]) + 1 return [PagureIssue(issue_dict, project) for issue_dict in raw_issues]
def create( project: "ogr_pagure.PagureProject", title: str, body: str, private: Optional[bool] = None, labels: Optional[List[str]] = None, assignees: Optional[List[str]] = None, ) -> "Issue": if not project.has_issues: raise IssueTrackerDisabled() payload = {"title": title, "issue_content": body} if labels is not None: payload["tag"] = ",".join(labels) if private: payload["private"] = "true" if assignees and len(assignees) > 1: raise OperationNotSupported( "Pagure does not support multiple assignees") elif assignees: payload["assignee"] = assignees[0] new_issue = project._call_project_api("new_issue", data=payload, method="POST")["issue"] return PagureIssue(new_issue, project)
def get(project: "ogr_gitlab.GitlabProject", issue_id: int) -> "Issue": if not project.has_issues: raise IssueTrackerDisabled() try: return GitlabIssue(project.gitlab_repo.issues.get(issue_id), project) except gitlab.exceptions.GitlabGetError as ex: raise GitlabAPIException( f"Issue {issue_id} was not found. ") from ex
def create( project: "ogr_github.GithubProject", title: str, body: str, private: Optional[bool] = None, labels: Optional[List[str]] = None, assignees: Optional[list] = None, ) -> "Issue": if private: raise OperationNotSupported( "Private issues are not supported by Github") if not project.has_issues: raise IssueTrackerDisabled() github_issue = project.github_repo.create_issue(title=title, body=body, labels=labels or [], assignees=assignees or []) return GithubIssue(github_issue, project)
def get(project: "ogr_pagure.PagureProject", issue_id: int) -> "Issue": if not project.has_issues: raise IssueTrackerDisabled() raw_issue = project._call_project_api("issue", str(issue_id)) return PagureIssue(raw_issue, project)