main
1package gitlab
2
3import (
4 "fmt"
5 "io"
6 "time"
7
8 "github.com/xlgmokha/x/pkg/serde"
9)
10
11type IssueState string
12type IssueType string
13
14const (
15 IssueClosed IssueState = "closed"
16 IssueOpened IssueState = "opened"
17)
18
19const (
20 IssueTypeIncident IssueType = "incident"
21 IssueTypeIssue IssueType = "issue"
22 IssueTypeTask IssueType = "task"
23 IssueTypeTestCase IssueType = "test_case"
24)
25
26type Issue struct {
27 ID int `json:"id" yaml:"id"`
28 IID int `json:"iid" yaml:"iid"`
29 ProjectID int `json:"project_id" yaml:"project_id"`
30 Title string `json:"title" yaml:"title"`
31 Description string `json:"description" yaml:"description"`
32 State IssueState `json:"state" yaml:"state"`
33 CreatedAt time.Time `json:"created_at" yaml:"created_at"`
34 UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
35 ClosedAt time.Time `json:"closed_at" yaml:"closed_at"`
36 ClosedBy User `json:"closed_by" yaml:"closed_by"`
37 Labels []string `json:"labels" yaml:"labels"`
38 Milestone *Milestone `json:"milestone" yaml:"milestone"`
39 Assignees []User `json:"assignees" yaml:"assignees"`
40 Author User `json:"author" yaml:"author"`
41 Type IssueType `json:"issue_type" yaml:"issue_type"`
42 Assignee *User `json:"assignee" yaml:"assignee"`
43 UserNotesCount int `json:"user_notes_count" yaml:"user_notes_count"`
44 MergeRequestsCount int `json:"merge_requests_count" yaml:"merge_requests_count"`
45 Upvotes int `json:"upvotes" yaml:"upvotes"`
46 Downvotes int `json:"downvotes" yaml:"downvotes"`
47 DueDate *string `json:"due_date" yaml:"due_date"`
48 Confidential bool `json:"confidential" yaml:"confidential"`
49 DiscussionLocked *bool `json:"discussion_locked" yaml:"discussion_locked"`
50 WebUrl string `json:"web_url" yaml:"web_url"`
51 BlockingIssuesCount int `json:"blocking_issues_count" yaml:"blocking_issues_count"`
52 HasTasks bool `json:"has_tasks" yaml:"has_tasks"`
53 TaskStatus string `json:"task_status" yaml:"task_status"`
54}
55
56func (issue *Issue) Identifier() string {
57 return fmt.Sprintf("%v", issue.ID)
58}
59
60func FromIssues(r io.Reader) ([]Issue, error) {
61 return serde.From[[]Issue](r, serde.JSON)
62}