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) CreateProject(ctx context.Context, in *ProjectCreateRequest) (*Project, error) {
|
2020-04-07 11:23:04 +00:00
|
|
|
project, err := s.project.CreateProject(ctx, in.Name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectFromModel(project), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) UpdateProject(ctx context.Context, in *ProjectUpdateRequest) (*Project, error) {
|
2020-04-07 11:23:04 +00:00
|
|
|
project, err := s.project.UpdateProject(ctx, projectUpdateToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectFromModel(project), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) DeactivateProject(ctx context.Context, in *ProjectID) (*Project, error) {
|
2020-04-07 11:23:04 +00:00
|
|
|
project, err := s.project.DeactivateProject(ctx, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectFromModel(project), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
func (s *Server) ReactivateProject(ctx context.Context, in *ProjectID) (*Project, error) {
|
2020-04-07 11:23:04 +00:00
|
|
|
project, err := s.project.ReactivateProject(ctx, in.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectFromModel(project), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) SearchProjects(ctx context.Context, in *ProjectSearchRequest) (*ProjectSearchResponse, error) {
|
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-2sFvd", "Not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, error) {
|
2020-04-07 11:23:04 +00:00
|
|
|
project, err := s.project.ProjectByID(ctx, id.Id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectFromModel(project), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) GetGrantedProjectGrantByID(ctx context.Context, request *GrantedGrantID) (*ProjectGrant, error) {
|
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-974vd", "Not implemented")
|
|
|
|
}
|
|
|
|
|
2020-04-21 15:00:32 +00:00
|
|
|
func (s *Server) AddProjectRole(ctx context.Context, in *ProjectRoleAdd) (*ProjectRole, error) {
|
|
|
|
role, err := s.project.AddProjectRole(ctx, projectRoleAddToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectRoleFromModel(role), nil
|
|
|
|
}
|
|
|
|
func (s *Server) ChangeProjectRole(ctx context.Context, in *ProjectRoleChange) (*ProjectRole, error) {
|
|
|
|
role, err := s.project.ChangeProjectRole(ctx, projectRoleChangeToModel(in))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return projectRoleFromModel(role), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
2020-04-21 15:00:32 +00:00
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
func (s *Server) RemoveProjectRole(ctx context.Context, in *ProjectRoleRemove) (*empty.Empty, error) {
|
2020-04-21 15:00:32 +00:00
|
|
|
err := s.project.RemoveProjectRole(ctx, in.Id, in.Key)
|
|
|
|
return &empty.Empty{}, err
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) SearchProjectRoles(ctx context.Context, in *ProjectRoleSearchRequest) (*ProjectRoleSearchResponse, error) {
|
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-plV56", "Not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ProjectChanges(ctx context.Context, changesRequest *ChangeRequest) (*Changes, error) {
|
|
|
|
return nil, errors.ThrowUnimplemented(nil, "GRPC-mci3f", "Not implemented")
|
|
|
|
}
|