2020-07-08 11:56:37 +00:00
|
|
|
package admin
|
2020-06-25 06:12:29 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
2020-07-08 11:56:37 +00:00
|
|
|
|
|
|
|
"github.com/caos/zitadel/pkg/grpc/admin"
|
2020-06-25 06:12:29 +00:00
|
|
|
)
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) GetIamMemberRoles(ctx context.Context, _ *empty.Empty) (*admin.IamMemberRoles, error) {
|
|
|
|
return &admin.IamMemberRoles{Roles: s.iam.GetIamMemberRoles()}, nil
|
2020-06-25 06:12:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) SearchIamMembers(ctx context.Context, in *admin.IamMemberSearchRequest) (*admin.IamMemberSearchResponse, error) {
|
2020-06-25 06:12:29 +00:00
|
|
|
members, err := s.iam.SearchIamMembers(ctx, iamMemberSearchRequestToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return iamMemberSearchResponseFromModel(members), nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) AddIamMember(ctx context.Context, member *admin.AddIamMemberRequest) (*admin.IamMember, error) {
|
2020-06-25 06:12:29 +00:00
|
|
|
addedMember, err := s.iam.AddIamMember(ctx, addIamMemberToModel(member))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return iamMemberFromModel(addedMember), nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) ChangeIamMember(ctx context.Context, member *admin.ChangeIamMemberRequest) (*admin.IamMember, error) {
|
2020-06-25 06:12:29 +00:00
|
|
|
changedMember, err := s.iam.ChangeIamMember(ctx, changeIamMemberToModel(member))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return iamMemberFromModel(changedMember), nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) RemoveIamMember(ctx context.Context, member *admin.RemoveIamMemberRequest) (*empty.Empty, error) {
|
2020-06-25 06:12:29 +00:00
|
|
|
err := s.iam.RemoveIamMember(ctx, member.UserId)
|
|
|
|
return &empty.Empty{}, err
|
|
|
|
}
|