@@ -6,36 +6,40 @@ import (
6
6
"time"
7
7
)
8
8
9
- // Org describes an Organization in Coder
10
- type Org struct {
9
+ // Organization describes an Organization in Coder
10
+ type Organization struct {
11
11
ID string `json:"id"`
12
12
Name string `json:"name"`
13
13
Members []OrganizationUser `json:"members"`
14
14
}
15
15
16
+ // OrganizationUser user wraps the basic User type and adds data specific to the user's membership of an organization
16
17
type OrganizationUser struct {
17
18
User
18
- OrganizationRoles []Role `json:"organization_roles"`
19
+ OrganizationRoles []OrganizationRole `json:"organization_roles"`
19
20
RolesUpdatedAt time.Time `json:"roles_updated_at"`
20
21
}
21
22
22
- type Role string
23
+ // OrganizationRole defines an organization OrganizationRole
24
+ type OrganizationRole string
23
25
26
+ // The OrganizationRole enum values
24
27
const (
25
- RoleOrgMember Role = "organization-member"
26
- RoleOrgAdmin Role = "organization-admin"
27
- RoleOrgManager Role = "organization-manager"
28
+ RoleOrgMember OrganizationRole = "organization-member"
29
+ RoleOrgAdmin OrganizationRole = "organization-admin"
30
+ RoleOrgManager OrganizationRole = "organization-manager"
28
31
)
29
32
30
- // Orgs gets all Organizations
31
- func (c Client ) Orgs (ctx context.Context ) ([]Org , error ) {
32
- var orgs []Org
33
+ // Organizations gets all Organizations
34
+ func (c Client ) Organizations (ctx context.Context ) ([]Organization , error ) {
35
+ var orgs []Organization
33
36
if err := c .requestBody (ctx , http .MethodGet , "/api/orgs" , nil , & orgs ); err != nil {
34
37
return nil , err
35
38
}
36
39
return orgs , nil
37
40
}
38
41
42
+ // OrgMembers get all members of the given organization
39
43
func (c Client ) OrgMembers (ctx context.Context , orgID string ) ([]OrganizationUser , error ) {
40
44
var members []OrganizationUser
41
45
if err := c .requestBody (ctx , http .MethodGet , "/api/orgs/" + orgID + "/members" , nil , & members ); err != nil {
0 commit comments