-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganizations.go
More file actions
41 lines (33 loc) · 1.09 KB
/
organizations.go
File metadata and controls
41 lines (33 loc) · 1.09 KB
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
package scaleway
import "fmt"
// OrganizationsService handles communication with the account API.
type OrganizationsService struct {
client *Client
}
// Organization represents a Scaleway organization.
type Organization struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Users []*User `json:"users,omitempty"`
}
// organizationListResponse represents a Scaleway organization list response.
type organizationListResponse struct {
Organizations []*Organization `json:"organizations"`
}
// List returns a list of all organisation associate to your account.
func (s *OrganizationsService) List() ([]*Organization, *Response, error) {
return s.listOrganizations()
}
func (s *OrganizationsService) listOrganizations() ([]*Organization, *Response, error) {
u := fmt.Sprintf("/organizations")
req, err := s.client.NewRequestAccount("GET", u, nil)
if err != nil {
return nil, nil, err
}
organizations := new(organizationListResponse)
resp, err := s.client.Do(req, organizations)
if err != nil {
return nil, nil, err
}
return organizations.Organizations, resp, nil
}