1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13
14
15
16
17 func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
18 u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo)
19 u, err := addOptions(u, opts)
20 if err != nil {
21 return nil, nil, err
22 }
23
24 req, err := s.client.NewRequest("GET", u, nil)
25 if err != nil {
26 return nil, nil, err
27 }
28 var assignees []*User
29 resp, err := s.client.Do(ctx, req, &assignees)
30 if err != nil {
31 return nil, resp, err
32 }
33
34 return assignees, resp, nil
35 }
36
37
38
39
40 func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) {
41 u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user)
42 req, err := s.client.NewRequest("GET", u, nil)
43 if err != nil {
44 return false, nil, err
45 }
46 resp, err := s.client.Do(ctx, req, nil)
47 assignee, err := parseBoolResponse(err)
48 return assignee, resp, err
49 }
50
51
52
53
54 func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
55 users := &struct {
56 Assignees []string `json:"assignees,omitempty"`
57 }{Assignees: assignees}
58 u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
59 req, err := s.client.NewRequest("POST", u, users)
60 if err != nil {
61 return nil, nil, err
62 }
63
64 issue := &Issue{}
65 resp, err := s.client.Do(ctx, req, issue)
66 return issue, resp, err
67 }
68
69
70
71
72 func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
73 users := &struct {
74 Assignees []string `json:"assignees,omitempty"`
75 }{Assignees: assignees}
76 u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
77 req, err := s.client.NewRequest("DELETE", u, users)
78 if err != nil {
79 return nil, nil, err
80 }
81
82 issue := &Issue{}
83 resp, err := s.client.Do(ctx, req, issue)
84 return issue, resp, err
85 }
86
View as plain text