Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/resolvers/visit_status.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from swh.graphql.errors import NullableObjectError | |||||
from swh.model.swhids import CoreSWHID, ObjectType | from swh.model.swhids import CoreSWHID, ObjectType | ||||
from swh.storage.interface import PagedResult | from swh.storage.interface import PagedResult | ||||
from .base_connection import BaseConnection | from .base_connection import BaseConnection | ||||
from .base_node import BaseNode | from .base_node import BaseNode | ||||
from .visit import BaseVisitNode | from .visit import BaseVisitNode | ||||
Show All 13 Lines | class LatestVisitStatusNode(BaseVisitStatusNode): | ||||
""" | """ | ||||
Node resolver for a visit-status requested from a visit | Node resolver for a visit-status requested from a visit | ||||
""" | """ | ||||
obj: BaseVisitNode | obj: BaseVisitNode | ||||
def _get_node_data(self): | def _get_node_data(self): | ||||
# self.obj.origin is the origin URL | # self.obj.origin is the origin URL | ||||
return self.archive.get_latest_visit_status(self.obj.origin, self.obj.visitId) | return self.archive.get_latest_visit_status( | ||||
origin_url=self.obj.origin, | |||||
visit_id=self.obj.visitId, | |||||
allowed_statuses=self.kwargs.get("allowedStatuses"), | |||||
require_snapshot=self.kwargs.get("requireSnapshot"), | |||||
) | |||||
def _handle_node_errors(self) -> None: | |||||
# This object can be null | |||||
if self._node is None: | |||||
raise NullableObjectError("") | |||||
class VisitStatusConnection(BaseConnection): | class VisitStatusConnection(BaseConnection): | ||||
""" | """ | ||||
Connection resolver for the visit-status objects in a visit | Connection resolver for the visit-status objects in a visit | ||||
""" | """ | ||||
obj: BaseVisitNode | obj: BaseVisitNode | ||||
Show All 10 Lines |