mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
3549a8b64e
* move mgmt pkg * begin package restructure * rename auth package to authz * begin start api * move auth * move admin * fix merge * configs and interceptors * interceptor * revert generate-grpc.sh * some cleanups * console * move console * fix tests and merging * js linting * merge * merging and configs * change k8s base to current ports * fixes * cleanup * regenerate proto * remove unnecessary whitespace * missing param * go mod tidy * fix merging * move login pkg * cleanup * move api pkgs again * fix pkg naming * fix generate-static.sh for login * update workflow * fixes * logging * remove duplicate * comment for optional gateway interfaces * regenerate protos * fix proto imports for grpc web * protos * grpc web generate * grpc web generate * fix changes * add translation interceptor * fix merging * regenerate mgmt proto
67 lines
2.3 KiB
Go
67 lines
2.3 KiB
Go
package management
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
|
|
grpc_util "github.com/caos/zitadel/internal/api/grpc"
|
|
"github.com/caos/zitadel/internal/api/http"
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
|
)
|
|
|
|
func (s *Server) SearchProjectGrants(ctx context.Context, in *management.ProjectGrantSearchRequest) (*management.ProjectGrantSearchResponse, error) {
|
|
request := projectGrantSearchRequestsToModel(in)
|
|
orgID := grpc_util.GetHeader(ctx, http.ZitadelOrgID)
|
|
request.AppendMyResourceOwnerQuery(orgID)
|
|
request.AppendNotMyOrgQuery(orgID)
|
|
response, err := s.project.SearchProjectGrants(ctx, request)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return projectGrantSearchResponseFromModel(response), nil
|
|
}
|
|
|
|
func (s *Server) ProjectGrantByID(ctx context.Context, in *management.ProjectGrantID) (*management.ProjectGrantView, error) {
|
|
grant, err := s.project.ProjectGrantByID(ctx, in.Id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return projectGrantFromGrantedProjectModel(grant), nil
|
|
}
|
|
|
|
func (s *Server) CreateProjectGrant(ctx context.Context, in *management.ProjectGrantCreate) (*management.ProjectGrant, error) {
|
|
grant, err := s.project.AddProjectGrant(ctx, projectGrantCreateToModel(in))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return projectGrantFromModel(grant), nil
|
|
}
|
|
func (s *Server) UpdateProjectGrant(ctx context.Context, in *management.ProjectGrantUpdate) (*management.ProjectGrant, error) {
|
|
grant, err := s.project.ChangeProjectGrant(ctx, projectGrantUpdateToModel(in))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return projectGrantFromModel(grant), nil
|
|
}
|
|
func (s *Server) DeactivateProjectGrant(ctx context.Context, in *management.ProjectGrantID) (*management.ProjectGrant, error) {
|
|
grant, err := s.project.DeactivateProjectGrant(ctx, in.ProjectId, in.Id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return projectGrantFromModel(grant), nil
|
|
}
|
|
|
|
func (s *Server) ReactivateProjectGrant(ctx context.Context, in *management.ProjectGrantID) (*management.ProjectGrant, error) {
|
|
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 *management.ProjectGrantID) (*empty.Empty, error) {
|
|
err := s.project.RemoveProjectGrant(ctx, in.ProjectId, in.Id)
|
|
return &empty.Empty{}, err
|
|
}
|