Skip to content

Commit 0f22970

Browse files
committed
ref: org role list and team role list
1 parent 01d0536 commit 0f22970

File tree

6 files changed

+354
-51
lines changed

6 files changed

+354
-51
lines changed

sentry/organization_members.go

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,24 @@ import (
66
"time"
77
)
88

9-
// https://github.com/getsentry/sentry/blob/8b683002ec84f9edd338348500937a480e49e61c/src/sentry/api/serializers/models/role.py#L32
10-
type RoleListItem struct {
11-
ID string `json:"id"`
12-
Name string `json:"name"`
13-
IsAllowed bool `json:"isAllowed"`
14-
}
15-
169
// OrganizationMember represents a User's membership to the organization.
1710
// https://github.com/getsentry/sentry/blob/22.5.0/src/sentry/api/serializers/models/organization_member/response.py#L57-L69
1811
type OrganizationMember struct {
19-
ID string `json:"id"`
20-
Email string `json:"email"`
21-
Name string `json:"name"`
22-
User User `json:"user"`
23-
OrganizationRole string `json:"orgRole"`
24-
OrganizationRoleList []RoleListItem `json:"orgRoleList"`
25-
Pending bool `json:"pending"`
26-
Expired bool `json:"expired"`
27-
Flags map[string]bool `json:"flags"`
28-
DateCreated time.Time `json:"dateCreated"`
29-
InviteStatus string `json:"inviteStatus"`
30-
InviterName *string `json:"inviterName"`
31-
TeamRoleList []RoleListItem `json:"teamRoleList"`
32-
TeamRoles []TeamRole `json:"teamRoles"`
33-
Teams []string `json:"teams"`
12+
ID string `json:"id"`
13+
Email string `json:"email"`
14+
Name string `json:"name"`
15+
User User `json:"user"`
16+
OrgRole string `json:"orgRole"`
17+
OrgRoleList []OrganizationRoleListItem `json:"orgRoleList"`
18+
Pending bool `json:"pending"`
19+
Expired bool `json:"expired"`
20+
Flags map[string]bool `json:"flags"`
21+
DateCreated time.Time `json:"dateCreated"`
22+
InviteStatus string `json:"inviteStatus"`
23+
InviterName *string `json:"inviterName"`
24+
TeamRoleList []TeamRoleListItem `json:"teamRoleList"`
25+
TeamRoles []TeamRole `json:"teamRoles"`
26+
Teams []string `json:"teams"`
3427
}
3528

3629
const (
@@ -104,8 +97,8 @@ func (s *OrganizationMembersService) Create(ctx context.Context, organizationSlu
10497
}
10598

10699
type TeamRole struct {
107-
TeamSlug string `json:"teamSlug"`
108-
Role string `json:"role"`
100+
TeamSlug string `json:"teamSlug"`
101+
Role *string `json:"role"`
109102
}
110103

111104
type UpdateOrganizationMemberParams struct {

sentry/organization_members_test.go

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -590,32 +590,57 @@ func TestOrganizationMembersService_Update(t *testing.T) {
590590
},
591591
},
592592
},
593-
OrganizationRole: OrganizationRoleMember,
594-
OrganizationRoleList: []RoleListItem{
593+
OrgRole: OrganizationRoleMember,
594+
OrgRoleList: []OrganizationRoleListItem{
595595
{
596-
ID: "billing",
597-
Name: "Billing",
598-
IsAllowed: true,
596+
ID: "billing",
597+
Name: "Billing",
598+
Desc: "Can manage subscription and billing details.",
599+
Scopes: []string{"org:billing"},
600+
IsAllowed: true,
601+
IsRetired: false,
602+
IsGlobal: false,
603+
MinimumTeamRole: "contributor",
599604
},
600605
{
601-
ID: "member",
602-
Name: "Member",
603-
IsAllowed: true,
606+
ID: "member",
607+
Name: "Member",
608+
Desc: "Members can view and act on events, as well as view most other data within the organization.",
609+
Scopes: []string{"team:read", "project:releases", "org:read", "event:read", "alerts:write", "member:read", "alerts:read", "event:admin", "project:read", "event:write"},
610+
IsAllowed: true,
611+
IsRetired: false,
612+
IsGlobal: false,
613+
MinimumTeamRole: "contributor",
604614
},
605615
{
606-
ID: "admin",
607-
Name: "Admin",
608-
IsAllowed: true,
616+
ID: "admin",
617+
Name: "Admin",
618+
Desc: "Admin privileges on any teams of which they're a member. They can create new teams and projects, as well as remove teams and projects on which they already hold membership (or all teams, if open membership is enabled). Additionally, they can manage memberships of teams that they are members of. They cannot invite members to the organization.",
619+
Scopes: []string{"team:admin", "org:integrations", "project:admin", "team:read", "project:releases", "org:read", "team:write", "event:read", "alerts:write", "member:read", "alerts:read", "event:admin", "project:read", "event:write", "project:write"},
620+
IsAllowed: true,
621+
IsRetired: true,
622+
IsGlobal: false,
623+
MinimumTeamRole: "admin",
609624
},
610625
{
611-
ID: "manager",
612-
Name: "Manager",
613-
IsAllowed: true,
626+
ID: "manager",
627+
Name: "Manager",
628+
Desc: "Gains admin access on all teams as well as the ability to add and remove members.",
629+
Scopes: []string{"team:admin", "org:integrations", "project:releases", "team:write", "member:read", "org:write", "project:write", "project:admin", "team:read", "org:read", "event:read", "member:write", "alerts:write", "alerts:read", "event:admin", "project:read", "event:write", "member:admin"},
630+
IsAllowed: true,
631+
IsRetired: false,
632+
IsGlobal: true,
633+
MinimumTeamRole: "admin",
614634
},
615635
{
616-
ID: "owner",
617-
Name: "Owner",
618-
IsAllowed: true,
636+
ID: "owner",
637+
Name: "Owner",
638+
Desc: "Unrestricted access to the organization, its data, and its settings. Can add, modify, and delete projects and members, as well as make billing and plan changes.",
639+
Scopes: []string{"team:admin", "org:integrations", "project:releases", "org:admin", "team:write", "member:read", "org:write", "project:write", "project:admin", "team:read", "org:read", "event:read", "member:write", "alerts:write", "org:billing", "alerts:read", "event:admin", "project:read", "event:write", "member:admin"},
640+
IsAllowed: true,
641+
IsRetired: false,
642+
IsGlobal: true,
643+
MinimumTeamRole: "admin",
619644
},
620645
},
621646
Pending: false,
@@ -631,26 +656,34 @@ func TestOrganizationMembersService_Update(t *testing.T) {
631656
DateCreated: mustParseTime("2021-07-06T21:13:01.120263Z"),
632657
InviteStatus: "approved",
633658
InviterName: &inviterName,
634-
TeamRoleList: []RoleListItem{
659+
TeamRoleList: []TeamRoleListItem{
635660
{
636-
ID: "contributor",
637-
Name: "Contributor",
638-
IsAllowed: false,
661+
ID: "contributor",
662+
Name: "Contributor",
663+
Desc: "Contributors can view and act on events, as well as view most other data within the team's projects.",
664+
Scopes: []string{"team:read", "project:releases", "org:read", "event:read", "member:read", "alerts:read", "project:read", "event:write"},
665+
IsAllowed: false,
666+
IsRetired: false,
667+
IsMinimumRoleFor: nil,
639668
},
640669
{
641-
ID: "admin",
642-
Name: "Team Admin",
643-
IsAllowed: false,
670+
ID: "admin",
671+
Name: "Team Admin",
672+
Desc: "Admin privileges on the team. They can create and remove projects, and can manage the team's memberships. They cannot invite members to the organization.",
673+
Scopes: []string{"team:admin", "org:integrations", "project:admin", "team:read", "project:releases", "org:read", "team:write", "event:read", "alerts:write", "member:read", "alerts:read", "event:admin", "project:read", "event:write", "project:write"},
674+
IsAllowed: false,
675+
IsRetired: false,
676+
IsMinimumRoleFor: String("admin"),
644677
},
645678
},
646679
TeamRoles: []TeamRole{
647680
{
648681
TeamSlug: "ancient-gabelers",
649-
Role: TeamRoleAdmin,
682+
Role: String(TeamRoleAdmin),
650683
},
651684
{
652685
TeamSlug: "powerful-abolitionist",
653-
Role: TeamRoleContributor,
686+
Role: String(TeamRoleContributor),
654687
},
655688
},
656689
Teams: []string{

sentry/organizations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ type Organization struct {
4747
IsDefault *bool `json:"isDefault,omitempty"`
4848
DefaultRole *string `json:"defaultRole,omitempty"`
4949
AvailableRoles []OrganizationAvailableRole `json:"availableRoles,omitempty"`
50+
OrgRoleList []OrganizationRoleListItem `json:"orgRoleList,omitempty"`
51+
TeamRoleList []TeamRoleListItem `json:"teamRoleList,omitempty"`
5052
OpenMembership *bool `json:"openMembership,omitempty"`
5153
AllowSharedIssues *bool `json:"allowSharedIssues,omitempty"`
5254
EnhancedPrivacy *bool `json:"enhancedPrivacy,omitempty"`

0 commit comments

Comments
 (0)