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

Commit

Permalink
Make a few small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Sep 25, 2024
1 parent 7fc874b commit 0c8599a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ to add new and/or missing endpoints. Currently, the following services are suppo
- [x] Todos
- [x] Topics
- [x] Users
- [x] Users (ServiceAccounts)
- [x] Validate CI Configuration
- [x] Version
- [x] Wikis
Expand Down
37 changes: 18 additions & 19 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ type BasicUser struct {
WebURL string `json:"web_url"`
}

// ServiceAccount represents a GitLab service account.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/user_service_accounts.html
type ServiceAccount struct {
ID int `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
}

// User represents a GitLab user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/users.html
Expand Down Expand Up @@ -1543,9 +1553,10 @@ func (s *UsersService) CreateUserRunner(opts *CreateUserRunnerOptions, options .
return r, resp, nil
}

// CreateServiceAccountUser creates a new service account user. Note only administrators can create new service account users.
// CreateServiceAccountUser creates a new service account user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/users.html#create-service-account-user
// GitLab API docs:
// https://docs.gitlab.com/ee/api/users.html#create-service-account-user
func (s *UsersService) CreateServiceAccountUser(options ...RequestOptionFunc) (*User, *Response, error) {
req, err := s.client.NewRequest(http.MethodPost, "service_accounts", nil, options)
if err != nil {
Expand All @@ -1561,35 +1572,23 @@ func (s *UsersService) CreateServiceAccountUser(options ...RequestOptionFunc) (*
return usr, resp, nil
}

// ServiceAccount represents the available ServiceAccount options.
// ListServiceAccounts lists all service accounts.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/user_service_accounts.html#list-all-service-account-users

type ServiceAccount struct {
ID int `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
}

// ListServiceAccounts lists all service accounts. Note only administrators can list service accounts.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/users.html#create-service-account-user

// https://docs.gitlab.com/ee/api/users.html#create-service-account-user
func (s *UsersService) ListServiceAccounts(opt *ListServiceAccountsOptions, options ...RequestOptionFunc) ([]*ServiceAccount, *Response, error) {

req, err := s.client.NewRequest(http.MethodGet, "service_accounts", opt, options)
if err != nil {
return nil, nil, err
}

var serviceaccounts []*ServiceAccount
resp, err := s.client.Do(req, &serviceaccounts)
var sas []*ServiceAccount
resp, err := s.client.Do(req, &sas)
if err != nil {
return nil, resp, err
}

return serviceaccounts, resp, nil
return sas, resp, nil
}

// UploadAvatar uploads an avatar to the current user.
Expand Down

0 comments on commit 0c8599a

Please sign in to comment.