2020-03-24 09:14:39 +00:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-26 14:46:16 +00:00
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) GetProjectMemberRoles(ctx context.Context, _ *empty.Empty) (*ProjectMemberRoles, error) {
|
2020-05-26 14:46:16 +00:00
|
|
|
return &ProjectMemberRoles{Roles: s.project.GetProjectMemberRoles()}, nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-05-11 10:16:29 +00:00
|
|
|
func (s *Server) SearchProjectMembers(ctx context.Context, in *ProjectMemberSearchRequest) (*ProjectMemberSearchResponse, error) {
|
|
|
|
response, err := s.project.SearchProjectMembers(ctx, projectMemberSearchRequestsToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectMemberSearchResponseFromModel(response), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 15:11:42 +00:00
|
|
|
func (s *Server) AddProjectMember(ctx context.Context, in *ProjectMemberAdd) (*ProjectMember, error) {
|
|
|
|
member, err := s.project.AddProjectMember(ctx, projectMemberAddToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectMemberFromModel(member), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 15:11:42 +00:00
|
|
|
func (s *Server) ChangeProjectMember(ctx context.Context, in *ProjectMemberChange) (*ProjectMember, error) {
|
|
|
|
member, err := s.project.ChangeProjectMember(ctx, projectMemberChangeToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectMemberFromModel(member), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RemoveProjectMember(ctx context.Context, in *ProjectMemberRemove) (*empty.Empty, error) {
|
2020-04-15 15:11:42 +00:00
|
|
|
err := s.project.RemoveProjectMember(ctx, in.Id, in.UserId)
|
|
|
|
return &empty.Empty{}, err
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|