feat: all project grant search query (#2581)

* feat: all project grant search query

* feat: all project grant search query
This commit is contained in:
Fabi
2021-10-27 11:26:01 +02:00
committed by GitHub
parent 802fbf175b
commit cd65fd8c17
7 changed files with 196 additions and 7 deletions

View File

@@ -41,6 +41,27 @@ func (s *Server) ListProjectGrants(ctx context.Context, req *mgmt_pb.ListProject
}, nil
}
func (s *Server) ListAllProjectGrants(ctx context.Context, req *mgmt_pb.ListAllProjectGrantsRequest) (*mgmt_pb.ListAllProjectGrantsResponse, error) {
queries, err := listAllProjectGrantsRequestToModel(req)
if err != nil {
return nil, err
}
queries.AppendMyResourceOwnerQuery(authz.GetCtxData(ctx).OrgID)
queries.AppendPermissionQueries(authz.GetRequestPermissionsFromCtx(ctx))
grants, err := s.query.SearchProjectGrants(ctx, queries)
if err != nil {
return nil, err
}
return &mgmt_pb.ListAllProjectGrantsResponse{
Result: proj_grpc.GrantedProjectViewsToPb(grants.ProjectGrants),
Details: object_grpc.ToListDetails(
grants.Count,
grants.Sequence,
grants.Timestamp,
),
}, nil
}
func (s *Server) AddProjectGrant(ctx context.Context, req *mgmt_pb.AddProjectGrantRequest) (*mgmt_pb.AddProjectGrantResponse, error) {
grant, err := s.command.AddProjectGrant(ctx, AddProjectGrantRequestToDomain(req), authz.GetCtxData(ctx).OrgID)
if err != nil {