2020-03-24 09:14:39 +00:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) GetProjectGrantMemberRoles(ctx context.Context, _ *empty.Empty) (*ProjectGrantMemberRoles, error) {
|
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-mGo89", "Not implemented")
|
|
|
|
}
|
|
|
|
|
2020-04-23 05:54:40 +00:00
|
|
|
func (s *Server) SearchProjectGrants(ctx context.Context, in *ProjectGrantSearchRequest) (*ProjectGrantSearchResponse, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
request := projectGrantSearchRequestsToModel(in)
|
|
|
|
request.AppendMyResourceOwnerQuery(ctx)
|
|
|
|
request.AppendNotMyOrgQuery(ctx)
|
|
|
|
response, err := s.project.SearchGrantedProjects(ctx, request)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectGrantSearchResponseFromModel(response), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-23 05:54:40 +00:00
|
|
|
func (s *Server) ProjectGrantByID(ctx context.Context, in *ProjectGrantID) (*ProjectGrant, error) {
|
|
|
|
grant, err := s.project.ProjectGrantByID(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectGrantFromModel(grant), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) CreateProjectGrant(ctx context.Context, in *ProjectGrantCreate) (*ProjectGrant, error) {
|
2020-04-23 05:54:40 +00:00
|
|
|
grant, err := s.project.AddProjectGrant(ctx, projectGrantCreateToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectGrantFromModel(grant), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) UpdateProjectGrant(ctx context.Context, in *ProjectGrantUpdate) (*ProjectGrant, error) {
|
2020-04-23 05:54:40 +00:00
|
|
|
grant, err := s.project.ChangeProjectGrant(ctx, projectGrantUpdateToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectGrantFromModel(grant), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) DeactivateProjectGrant(ctx context.Context, in *ProjectGrantID) (*ProjectGrant, error) {
|
2020-04-23 05:54:40 +00:00
|
|
|
grant, err := s.project.DeactivateProjectGrant(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectGrantFromModel(grant), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
2020-04-23 05:54:40 +00:00
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
func (s *Server) ReactivateProjectGrant(ctx context.Context, in *ProjectGrantID) (*ProjectGrant, error) {
|
2020-04-23 05:54:40 +00:00
|
|
|
grant, err := s.project.ReactivateProjectGrant(ctx, in.ProjectId, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectGrantFromModel(grant), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RemoveProjectGrant(ctx context.Context, in *ProjectGrantID) (*empty.Empty, error) {
|
|
|
|
err := s.project.RemoveProjectGrant(ctx, in.ProjectId, in.Id)
|
|
|
|
return &empty.Empty{}, err
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|