diff --git a/cmd/api/src/api/error.go b/cmd/api/src/api/error.go index 3e7ea9dca..c59708cac 100644 --- a/cmd/api/src/api/error.go +++ b/cmd/api/src/api/error.go @@ -71,7 +71,8 @@ const ( ErrorResponseDetailsUniqueViolation = "unique constraint was violated" ErrorResponseDetailsNotImplemented = "All good things to those who wait. Not implemented." - FmtErrorResponseDetailsBadQueryParameters = "there are errors in the query parameters: %v" + FmtErrorResponseDetailsBadQueryParameters = "there are errors in the query parameters: %v" + FmtErrorResponseDetailsMissingRequiredQueryParameter = "missing required query parameter: %v" ) func IsErrorResponse(response *http.Response) bool { diff --git a/cmd/api/src/queries/graph.go b/cmd/api/src/queries/graph.go index f9847994c..c2ed87316 100644 --- a/cmd/api/src/queries/graph.go +++ b/cmd/api/src/queries/graph.go @@ -139,6 +139,7 @@ type Graph interface { GetNodesByKind(ctx context.Context, kinds ...graph.Kind) (graph.NodeSet, error) GetFilteredAndSortedNodes(orderCriteria model.OrderCriteria, filterCriteria graph.Criteria) (graph.NodeSet, error) FetchNodesByObjectIDs(ctx context.Context, objectIDs ...string) (graph.NodeSet, error) + FetchNodesByObjectIDsAndKinds(ctx context.Context, kinds graph.Kinds, objectIDs ...string) (graph.NodeSet, error) ValidateOUs(ctx context.Context, ous []string) ([]string, error) BatchNodeUpdate(ctx context.Context, nodeUpdate graph.NodeUpdate) error RawCypherQuery(ctx context.Context, pQuery PreparedQuery, includeProperties bool) (model.UnifiedGraph, error) @@ -726,6 +727,26 @@ func (s *GraphQuery) FetchNodesByObjectIDs(ctx context.Context, objectIDs ...str }) } +func (s *GraphQuery) FetchNodesByObjectIDsAndKinds(ctx context.Context, kinds graph.Kinds, objectIDs ...string) (graph.NodeSet, error) { + var nodes graph.NodeSet + + return nodes, s.Graph.ReadTransaction(ctx, func(tx graph.Transaction) error { + if fetchedNodes, err := ops.FetchNodeSet(tx.Nodes().Filterf( + func() graph.Criteria { + return query.And( + query.KindIn(query.Node(), kinds...), + query.In(query.NodeProperty(common.ObjectID.String()), objectIDs), + ) + }), + ); err != nil { + return err + } else { + nodes = fetchedNodes + return nil + } + }) +} + func (s *GraphQuery) ValidateOUs(ctx context.Context, ous []string) ([]string, error) { var validated = make([]string, 0)