openspg/python/knext/common/restable.py

36 lines
1.2 KiB
Python
Raw Normal View History

2023-12-22 19:49:39 +08:00
# -*- coding: utf-8 -*-
# Copyright 2023 Ant Group CO., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied.
2023-12-08 11:25:26 +08:00
from abc import ABC
2023-12-22 19:49:39 +08:00
from typing import Type, List
2023-12-08 11:25:26 +08:00
from knext import rest
class RESTable(ABC):
@property
2023-12-22 19:49:39 +08:00
def upstream_types(self) -> List[Type["RESTable"]]:
return []
2023-12-08 11:25:26 +08:00
@property
2023-12-22 19:49:39 +08:00
def downstream_types(self) -> List[Type["RESTable"]]:
return []
2023-12-08 11:25:26 +08:00
2023-12-11 10:44:37 +08:00
def to_rest(self) -> rest.Node:
2023-12-22 19:49:39 +08:00
raise NotImplementedError(f"`to_rest` is not currently supported for {self.__class__.__name__}.")
2023-12-08 11:25:26 +08:00
@classmethod
def from_rest(cls, node: rest.Node):
2023-12-22 19:49:39 +08:00
raise NotImplementedError(f"`from_rest` is not currently supported for {cls.__name__}.")
2023-12-08 11:25:26 +08:00
def submit(self):
2023-12-22 19:49:39 +08:00
raise NotImplementedError(f"`submit` is not currently supported for {self.__class__.__name__}.")