diff --git a/fedn/network/api/v1/graphql/__init__.py b/fedn/network/api/v1/graphql/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/fedn/network/api/v1/graphql/schema.py b/fedn/network/api/v1/graphql/schema.py index dfb2a2b6..d824464f 100644 --- a/fedn/network/api/v1/graphql/schema.py +++ b/fedn/network/api/v1/graphql/schema.py @@ -1,7 +1,7 @@ import graphene import pymongo -from fedn.network.api.v1.shared import model_store, session_store, validation_store +from fedn.network.api.v1.shared import model_store, session_store, status_store, validation_store class ActorType(graphene.ObjectType): @@ -9,6 +9,18 @@ class ActorType(graphene.ObjectType): role = graphene.String() +class StatusType(graphene.ObjectType): + data = graphene.String() + extra = graphene.String() + id = graphene.String() + logLevel = graphene.String() # noqa: N815 + sender = graphene.Field(ActorType) + sessionId = graphene.String() # noqa: N815 + status = graphene.String() + timestamp = graphene.String() + type = graphene.String() + + class ValidationType(graphene.ObjectType): correlationId = graphene.String() # noqa: N815 data = graphene.String() @@ -65,6 +77,7 @@ class SessionType(graphene.ObjectType): session_config = graphene.Field(SessionConfigType) model = graphene.List(ModelType) validation = graphene.List(ValidationType) + status = graphene.List(StatusType) def resolve_session_config(self, info): return self["session_config"] @@ -83,6 +96,13 @@ def resolve_validation(self, info): return result + def resolve_status(self, info): + kwargs = {"sessionId": self["session_id"]} + response = status_store.list(0, 0, None, sort_order=pymongo.DESCENDING, use_typing=False, **kwargs) + result = response["result"] + + return result + class Query(graphene.ObjectType): session = graphene.List( @@ -103,6 +123,12 @@ class Query(graphene.ObjectType): session_id=graphene.String(), ) + status = graphene.List( + StatusType, + id=graphene.String(), + session_id=graphene.String(), + ) + def resolve_session(root, info, id: str = None, name: str = None): result = None if id: @@ -151,5 +177,21 @@ def resolve_validation(root, info, id: str = None, session_id: str = None): return result + def resolve_status(root, info, id: str = None, session_id: str = None): + result = None + if id: + response = status_store.get(id) + result = [] + result.append(response) + elif session_id: + kwargs = {"sessionId": session_id} + response = status_store.list(0, 0, None, sort_order=pymongo.DESCENDING, use_typing=False, **kwargs) + result = response["result"] + else: + response = status_store.list(0, 0, None) + result = response["result"] + + return result + schema = graphene.Schema(query=Query)