github.com/crosbymichael/octokat@v0.0.0-20160826194511-076a32289ed5/label.go (about) 1 package octokat 2 3 import ( 4 "fmt" 5 ) 6 7 type Label struct { 8 URL string `json:"url,omitempty"` 9 Name string `json:"name,omitempty"` 10 Color string `json:"color,omitempty"` 11 } 12 13 func (c *Client) Labels(repo Repo) (labels []*Label, err error) { 14 path := fmt.Sprintf("repos/%s/labels", repo) 15 err = c.jsonGet(path, &Options{}, &labels) 16 return 17 } 18 19 func (c *Client) ApplyLabel(repo Repo, issue *Issue, labels []string) error { 20 path := fmt.Sprintf("repos/%s/issues/%d/labels", repo, issue.Number) 21 out := []*Label{} 22 return c.jsonPost(path, &Options{Params: labels}, &out) 23 } 24 25 func (c *Client) RemoveLabel(repo Repo, issue *Issue, label string) error { 26 path := fmt.Sprintf("repos/%s/issues/%d/labels/%s", repo, issue.Number, label) 27 _, err := c.request("DELETE", path, nil, nil) 28 return err 29 }