-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.go
More file actions
39 lines (33 loc) · 987 Bytes
/
users.go
File metadata and controls
39 lines (33 loc) · 987 Bytes
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
package scaleway
import "fmt"
// UsersService handles communication with the account API.
type UsersService struct {
client *Client
}
// User represents a Scaleway user.
type User struct {
Email string `json:"email,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Fullname string `json:"fullname,omitempty"`
ID string `json:"id,omitempty"`
SSHPubKeys []string `json:"ssh_public_keys,omitempty"`
}
// userResponse represents a Scaleway token creation response.
type userResponse struct {
User *User `json:"user"`
}
// Get returns info for a specific user.
func (s *UsersService) Get(id string) (*User, *Response, error) {
u := fmt.Sprintf("/users/%s", id)
req, err := s.client.NewRequestAccount("GET", u, nil)
if err != nil {
return nil, nil, err
}
user := new(userResponse)
resp, err := s.client.Do(req, user)
if err != nil {
return nil, nil, err
}
return user.User, resp, nil
}