Commit 81780eaa authored by Sander van Harmelen's avatar Sander van Harmelen

Tweak method names and run gofmt

parent 84bf518c
......@@ -21,8 +21,8 @@ import (
"time"
)
// ResourceLabelEventsService handles communication with the event related methods of
// the GitLab API.
// ResourceLabelEventsService handles communication with the event related
// methods of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html
type ResourceLabelEventsService struct {
......@@ -33,7 +33,7 @@ type ResourceLabelEventsService struct {
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-issue-label-event
type ResourceLabelEvent struct {
type LabelEvent struct {
ID int `json:"id"`
Action string `json:"action"`
CreatedAt *time.Time `json:"created_at"`
......@@ -56,21 +56,25 @@ type ResourceLabelEvent struct {
} `json:"label"`
}
// ListResourceLabelEventsOptions represents the options for resource label events services list functions.
type ListResourceLabelEventsOptions struct {
// ListLabelEventsOptions represents the options for all resource label events
// list methods.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#list-project-issue-label-events
type ListLabelEventsOptions struct {
ListOptions
}
// ListIssueResourceLabelEvents retrieves resource label events
// for the specified project and issue.
// ListIssueLabelEvents retrieves resource label events for the
// specified project and issue.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html#list-project-issue-label-events
func (s *ResourceLabelEventsService) ListIssueResourceLabelEvents(pid interface{}, issue int, opt *ListResourceLabelEventsOptions, options ...OptionFunc) ([]*ResourceLabelEvent, *Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#list-project-issue-label-events
func (s *ResourceLabelEventsService) ListIssueLabelEvents(pid interface{}, issue int, opt *ListLabelEventsOptions, options ...OptionFunc) ([]*LabelEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/issues/%d/resource_label_events", pathEscape(project), issue)
req, err := s.client.NewRequest("GET", u, opt, options)
......@@ -78,19 +82,20 @@ func (s *ResourceLabelEventsService) ListIssueResourceLabelEvents(pid interface{
return nil, nil, err
}
var rs []*ResourceLabelEvent
resp, err := s.client.Do(req, &rs)
var ls []*LabelEvent
resp, err := s.client.Do(req, &ls)
if err != nil {
return nil, resp, err
}
return rs, resp, err
return ls, resp, err
}
// GetIssueResourceLabelEvent gets a single issue-label-event.
// GetIssueLabelEvent gets a single issue-label-event.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-issue-label-event
func (s *ResourceLabelEventsService) GetIssueResourceLabelEvent(pid interface{}, issue int, event int, options ...OptionFunc) (*ResourceLabelEvent, *Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-issue-label-event
func (s *ResourceLabelEventsService) GetIssueLabelEvent(pid interface{}, issue int, event int, options ...OptionFunc) (*LabelEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
......@@ -102,25 +107,25 @@ func (s *ResourceLabelEventsService) GetIssueResourceLabelEvent(pid interface{},
return nil, nil, err
}
e := new(ResourceLabelEvent)
resp, err := s.client.Do(req, e)
l := new(LabelEvent)
resp, err := s.client.Do(req, l)
if err != nil {
return nil, resp, err
}
return e, resp, err
return l, resp, err
}
// ListGroupEpicResourceLabelEvents retrieves resource label events
// for the specified group and epic.
// ListGroupEpicLabelEvents retrieves resource label events for the specified
// group and epic.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html#list-group-epic-label-events
func (s *ResourceLabelEventsService) ListGroupEpicResourceLabelEvents(gid interface{}, epic int, opt *ListResourceLabelEventsOptions, options ...OptionFunc) ([]*ResourceLabelEvent, *Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#list-group-epic-label-events
func (s *ResourceLabelEventsService) ListGroupEpicLabelEvents(gid interface{}, epic int, opt *ListLabelEventsOptions, options ...OptionFunc) ([]*LabelEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/epics/%d/resource_label_events", pathEscape(group), epic)
req, err := s.client.NewRequest("GET", u, opt, options)
......@@ -128,19 +133,20 @@ func (s *ResourceLabelEventsService) ListGroupEpicResourceLabelEvents(gid interf
return nil, nil, err
}
var rs []*ResourceLabelEvent
resp, err := s.client.Do(req, &rs)
var ls []*LabelEvent
resp, err := s.client.Do(req, &ls)
if err != nil {
return nil, resp, err
}
return rs, resp, err
return ls, resp, err
}
// GetGroupEpicResourceLabelEvent gets a single group epic label event.
// GetGroupEpicLabelEvent gets a single group epic label event.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-epic-label-event
func (s *ResourceLabelEventsService) GetGroupEpicResourceLabelEvent(gid interface{}, epic int, event int, options ...OptionFunc) (*ResourceLabelEvent, *Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-epic-label-event
func (s *ResourceLabelEventsService) GetGroupEpicLabelEvent(gid interface{}, epic int, event int, options ...OptionFunc) (*LabelEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
......@@ -152,25 +158,25 @@ func (s *ResourceLabelEventsService) GetGroupEpicResourceLabelEvent(gid interfac
return nil, nil, err
}
e := new(ResourceLabelEvent)
resp, err := s.client.Do(req, e)
l := new(LabelEvent)
resp, err := s.client.Do(req, l)
if err != nil {
return nil, resp, err
}
return e, resp, err
return l, resp, err
}
// ListMergeRequestResourceLabelEvents retrieves resource label events
// for the specified project and merge request.
// ListMergeLabelEvents retrieves resource label events for the specified
// project and merge request.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html#list-project-merge-request-label-events
func (s *ResourceLabelEventsService) ListMergeRequestResourceLabelEvents(pid interface{}, request int, opt *ListResourceLabelEventsOptions, options ...OptionFunc) ([]*ResourceLabelEvent, *Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#list-project-merge-request-label-events
func (s *ResourceLabelEventsService) ListMergeLabelEvents(pid interface{}, request int, opt *ListLabelEventsOptions, options ...OptionFunc) ([]*LabelEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/merge_requests/%d/resource_label_events", pathEscape(project), request)
req, err := s.client.NewRequest("GET", u, opt, options)
......@@ -178,19 +184,20 @@ func (s *ResourceLabelEventsService) ListMergeRequestResourceLabelEvents(pid int
return nil, nil, err
}
var rs []*ResourceLabelEvent
resp, err := s.client.Do(req, &rs)
var ls []*LabelEvent
resp, err := s.client.Do(req, &ls)
if err != nil {
return nil, resp, err
}
return rs, resp, err
return ls, resp, err
}
// GetMergeRequestResourceLabelEvent gets a single merge request label event.
// GetMergeRequestLabelEvent gets a single merge request label event.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-merge-request-label-event
func (s *ResourceLabelEventsService) GetMergeRequestResourceLabelEvent(pid interface{}, request int, event int, options ...OptionFunc) (*ResourceLabelEvent, *Response, error) {
// GitLab API docs:
// https://docs.gitlab.com/ee/api/resource_label_events.html#get-single-merge-request-label-event
func (s *ResourceLabelEventsService) GetMergeRequestLabelEvent(pid interface{}, request int, event int, options ...OptionFunc) (*LabelEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
......@@ -202,11 +209,11 @@ func (s *ResourceLabelEventsService) GetMergeRequestResourceLabelEvent(pid inter
return nil, nil, err
}
e := new(ResourceLabelEvent)
resp, err := s.client.Do(req, e)
l := new(LabelEvent)
resp, err := s.client.Do(req, l)
if err != nil {
return nil, resp, err
}
return e, resp, err
return l, resp, err
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment