Skip to content

Commit

Permalink
feat: Add/delete/change roles to organization members- Including Team…
Browse files Browse the repository at this point in the history
… level roles
  • Loading branch information
jianyuan committed Dec 7, 2023
1 parent d6f394e commit 5b056fb
Show file tree
Hide file tree
Showing 2 changed files with 322 additions and 44 deletions.
49 changes: 29 additions & 20 deletions sentry/organization_members.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ import (
// OrganizationMember represents a User's membership to the organization.
// https://github.com/getsentry/sentry/blob/22.5.0/src/sentry/api/serializers/models/organization_member/response.py#L57-L69
type OrganizationMember struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
User User `json:"user"`
Role string `json:"role"`
RoleName string `json:"roleName"`
Pending bool `json:"pending"`
Expired bool `json:"expired"`
Flags map[string]bool `json:"flags"`
DateCreated time.Time `json:"dateCreated"`
InviteStatus string `json:"inviteStatus"`
InviterName *string `json:"inviterName"`
Teams []string `json:"teams"`
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
User User `json:"user"`
Role string `json:"role"` // Deprecated
RoleName string `json:"roleName"` // Deprecated
OrganizationRole string `json:"orgRole"`
Pending bool `json:"pending"`
Expired bool `json:"expired"`
Flags map[string]bool `json:"flags"`
DateCreated time.Time `json:"dateCreated"`
InviteStatus string `json:"inviteStatus"`
InviterName *string `json:"inviterName"`
Teams []string `json:"teams"`
TeamRoles []TeamRole `json:"teamRoles"`
}

const (
RoleMember string = "member"
RoleBilling string = "billing"
RoleAdmin string = "admin"
RoleOwner string = "owner"
RoleManager string = "manager"
OrganizationRoleBilling string = "billing"
OrganizationRoleMember string = "member"
OrganizationRoleManager string = "manager"
OrganizationRoleOwner string = "owner"

TeamRoleContributor string = "contributor"
TeamRoleAdmin string = "admin"
)

// OrganizationMembersService provides methods for accessing Sentry membership API endpoints.
Expand Down Expand Up @@ -92,9 +96,14 @@ func (s *OrganizationMembersService) Create(ctx context.Context, organizationSlu
return member, resp, nil
}

type TeamRole struct {
TeamSlug string `json:"teamSlug"`
Role string `json:"role"`
}

type UpdateOrganizationMemberParams struct {
Role string `json:"role"`
Teams []string `json:"teams,omitempty"`
OrganizationRole string `json:"role"`
TeamRoles []TeamRole `json:"teamRoles"`
}

func (s *OrganizationMembersService) Update(ctx context.Context, organizationSlug string, memberID string, params *UpdateOrganizationMemberParams) (*OrganizationMember, *Response, error) {
Expand Down
Loading

0 comments on commit 5b056fb

Please sign in to comment.