-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathchanges_hashtags.go
53 lines (42 loc) · 1.54 KB
/
changes_hashtags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package gerrit
import (
"context"
"fmt"
)
// GetHashtags gets the hashtags associated with a change.
//
// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-hashtags
func (c *ChangesService) GetHashtags(ctx context.Context, changeID string) ([]string, *Response, error) {
u := fmt.Sprintf("changes/%s/hashtags", changeID)
req, err := c.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}
var hashtags []string
resp, err := c.client.Do(req, &hashtags)
return hashtags, resp, err
}
// HashtagsInput entity contains information about hashtags to add to, and/or remove from, a change.
//
// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#hashtags-input
type HashtagsInput struct {
// The list of hashtags to be added to the change.
Add []string `json:"add,omitempty"`
// The list of hashtags to be removed from the change.
Remove []string `json:"remove,omitempty"`
}
// SetHashtags adds and/or removes hashtags from a change.
//
// As response the change’s hashtags are returned as a list of strings.
//
// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-hashtags
func (c *ChangesService) SetHashtags(ctx context.Context, changeID string, input *HashtagsInput) ([]string, *Response, error) {
u := fmt.Sprintf("changes/%s/hashtags", changeID)
req, err := c.client.NewRequest(ctx, "POST", u, input)
if err != nil {
return nil, nil, err
}
var hashtags []string
resp, err := c.client.Do(req, &hashtags)
return hashtags, resp, err
}