@@ -16,11 +16,6 @@ type Label struct {
16
16
Color string `json:"color"`
17
17
}
18
18
19
- type LabelOption struct {
20
- Name string `json:"name"`
21
- Color string `json:"color"`
22
- }
23
-
24
19
func (c * Client ) ListRepoLabels (owner , repo string ) ([]* Label , error ) {
25
20
labels := make ([]* Label , 0 , 10 )
26
21
return labels , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/labels" , owner , repo ), nil , nil , & labels )
@@ -31,7 +26,12 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
31
26
return label , c .getParsedResponse ("GET" , fmt .Sprintf ("/repos/%s/%s/labels/%d" , owner , repo , id ), nil , nil , label )
32
27
}
33
28
34
- func (c * Client ) CreateLabel (owner , repo string , opt LabelOption ) (* Label , error ) {
29
+ type CreateLabelOption struct {
30
+ Name string `json:"name" binding:"Required"`
31
+ Color string `json:"color" binding:"Required;Size(7)"`
32
+ }
33
+
34
+ func (c * Client ) CreateLabel (owner , repo string , opt CreateLabelOption ) (* Label , error ) {
35
35
body , err := json .Marshal (& opt )
36
36
if err != nil {
37
37
return nil , err
@@ -41,7 +41,12 @@ func (c *Client) CreateLabel(owner, repo string, opt LabelOption) (*Label, error
41
41
jsonHeader , bytes .NewReader (body ), label )
42
42
}
43
43
44
- func (c * Client ) EditLabel (owner , repo string , id int64 , opt LabelOption ) (* Label , error ) {
44
+ type EditLabelOption struct {
45
+ Name * string `json:"name"`
46
+ Color * string `json:"color"`
47
+ }
48
+
49
+ func (c * Client ) EditLabel (owner , repo string , id int64 , opt EditLabelOption ) (* Label , error ) {
45
50
body , err := json .Marshal (& opt )
46
51
if err != nil {
47
52
return nil , err
0 commit comments