diff --git a/samples/hello/hello.py b/samples/hello/hello.py index 262ccec..817618c 100755 --- a/samples/hello/hello.py +++ b/samples/hello/hello.py @@ -98,13 +98,13 @@ async def run_server() -> None: # TODO Move this code to SDK "runner" class # Map interface name to instance interfaces = dict() -for interface in extension.get_implemented_interfaces(): +for interface in extension.implemented_interfaces: interfaces[interface[0]] = interface[1] logging.info(f"Registering {interface[0]} to point to {interface[1]}") # If it's an ActionExtension it has this extension point # TODO This could perhaps be better with isinstance() if "ActionExtension" in interfaces.keys(): - for handler in getattr(interfaces["ActionExtension"], "get_extension_rest_handlers")(): + for handler in getattr(interfaces["ActionExtension"], "extension_rest_handlers"): ExtensionRestHandlers().register(handler) logging.info(f"Registering {handler}") diff --git a/samples/hello/hello_extension.py b/samples/hello/hello_extension.py index 37cb138..034341f 100644 --- a/samples/hello/hello_extension.py +++ b/samples/hello/hello_extension.py @@ -16,7 +16,8 @@ class HelloExtension(Extension, ActionExtension): - def get_implemented_interfaces(self) -> list[tuple]: + @property + def implemented_interfaces(self) -> list[tuple]: # TODO: This is lazy and temporary. # Really we should be using this class to call some SDK class run(), # passing an instance of ourself to the SDK and letting it parse out @@ -24,5 +25,6 @@ def get_implemented_interfaces(self) -> list[tuple]: # implemented functions from the interfaces. return [("Extension", self), ("ActionExtension", self)] - def get_extension_rest_handlers(self) -> list[ExtensionRestHandler]: + @property + def extension_rest_handlers(self) -> list[ExtensionRestHandler]: return [HelloRestHandler()] diff --git a/src/opensearch_sdk_py/api/action_extension.py b/src/opensearch_sdk_py/api/action_extension.py index 2d1e96d..d5af7fc 100644 --- a/src/opensearch_sdk_py/api/action_extension.py +++ b/src/opensearch_sdk_py/api/action_extension.py @@ -16,7 +16,7 @@ class ActionExtension(ABC): @abstractmethod - def get_extension_rest_handlers(self) -> list[ExtensionRestHandler]: + def extension_rest_handlers(self) -> list[ExtensionRestHandler]: """ Implementer should return a list of classes implementing ExtensionRestHandler """ diff --git a/src/opensearch_sdk_py/api/extension.py b/src/opensearch_sdk_py/api/extension.py index e02f14b..e43043b 100644 --- a/src/opensearch_sdk_py/api/extension.py +++ b/src/opensearch_sdk_py/api/extension.py @@ -13,8 +13,9 @@ class Extension(ABC): + @property @abstractmethod - def get_implemented_interfaces(self) -> list[tuple]: + def implemented_interfaces(self) -> list[tuple]: """ Implementer should return a list of tuples containing the implemented interface (such as Extension, ActionExtension, etc.) and the implementing class.