Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Reorder following the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Aug 26, 2021
1 parent 5d5bbfb commit de0117b
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions audit_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type AuditEvent struct {
}

// AuditEventDetails represents the details portion of an audit event for
// a group, a project or the instance. The exact fields that are returned for an audit event
// depend on the action being recorded.
// a group, a project or the instance. The exact fields that are returned
// for an audit event depend on the action being recorded.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
type AuditEventDetails struct {
Expand All @@ -41,8 +41,8 @@ type AuditEventDetails struct {
FailedLogin string `json:"failed_login"`
}

// AuditEventsService handles communication with the project/group/instance audit
// event related methods of the GitLab API.
// AuditEventsService handles communication with the project/group/instance
// audit event related methods of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
type AuditEventsService struct {
Expand All @@ -59,18 +59,12 @@ type ListAuditEventsOptions struct {
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"`
}

// ListGroupAuditEvents gets a list of audit events for the specified group
// viewable by the authenticated user.
// ListInstanceAuditEvents gets a list of audit events for instance.
// Authentication as Administrator is required.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) ListGroupAuditEvents(gid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/audit_events", pathEscape(group))

req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
func (s *AuditEventsService) ListInstanceAuditEvents(opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
req, err := s.client.NewRequest(http.MethodGet, "audit_events", opt, options)
if err != nil {
return nil, nil, err
}
Expand All @@ -84,15 +78,12 @@ func (s *AuditEventsService) ListGroupAuditEvents(gid interface{}, opt *ListAudi
return aes, resp, err
}

// GetGroupAuditEvent gets a specific group audit event.
// GetInstanceAuditEvent gets a specific instance audit event.
// Authentication as Administrator is required.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetGroupAuditEvent(gid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/audit_events/%d", pathEscape(group), event)
func (s *AuditEventsService) GetInstanceAuditEvent(event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
u := fmt.Sprintf("audit_events/%d", event)

req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
Expand All @@ -108,16 +99,16 @@ func (s *AuditEventsService) GetGroupAuditEvent(gid interface{}, event int, opti
return ae, resp, err
}

// ListProjectAuditEvents gets a list of audit events for the specified project
// ListGroupAuditEvents gets a list of audit events for the specified group
// viewable by the authenticated user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) ListProjectAuditEvents(pid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
project, err := parseID(pid)
func (s *AuditEventsService) ListGroupAuditEvents(gid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/audit_events", pathEscape(project))
u := fmt.Sprintf("groups/%s/audit_events", pathEscape(group))

req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
Expand All @@ -133,16 +124,15 @@ func (s *AuditEventsService) ListProjectAuditEvents(pid interface{}, opt *ListAu
return aes, resp, err
}

// GetProjectAuditEvent gets a specific project audit event.
// GetGroupAuditEvent gets a specific group audit event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetProjectAuditEvent(pid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
project, err := parseID(pid)
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetGroupAuditEvent(gid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/audit_events/%d", pathEscape(project), event)
u := fmt.Sprintf("groups/%s/audit_events/%d", pathEscape(group), event)

req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
Expand All @@ -158,12 +148,18 @@ func (s *AuditEventsService) GetProjectAuditEvent(pid interface{}, event int, op
return ae, resp, err
}

// ListInstanceAuditEvents gets a list of audit events for instance.
// Authentication as Administrator is required.
// ListProjectAuditEvents gets a list of audit events for the specified project
// viewable by the authenticated user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) ListInstanceAuditEvents(opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
req, err := s.client.NewRequest(http.MethodGet, "audit_events", opt, options)
func (s *AuditEventsService) ListProjectAuditEvents(pid interface{}, opt *ListAuditEventsOptions, options ...RequestOptionFunc) ([]*AuditEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/audit_events", pathEscape(project))

req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
if err != nil {
return nil, nil, err
}
Expand All @@ -177,12 +173,16 @@ func (s *AuditEventsService) ListInstanceAuditEvents(opt *ListAuditEventsOptions
return aes, resp, err
}

// GetInstanceAuditEvent gets a specific instance audit event.
// Authentication as Administrator is required.
// GetProjectAuditEvent gets a specific project audit event.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetInstanceAuditEvent(event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
u := fmt.Sprintf("audit_events/%d", event)
// GitLab API docs:
// https://docs.gitlab.com/ee/api/audit_events.html
func (s *AuditEventsService) GetProjectAuditEvent(pid interface{}, event int, options ...RequestOptionFunc) (*AuditEvent, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/audit_events/%d", pathEscape(project), event)

req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
Expand Down

0 comments on commit de0117b

Please sign in to comment.