diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ +Deprecated PyYAML systemd-python - diff --git a/swh/core/api/__init__.py b/swh/core/api/__init__.py --- a/swh/core/api/__init__.py +++ b/swh/core/api/__init__.py @@ -12,6 +12,7 @@ import requests import datetime +from deprecated import deprecated from flask import Flask, Request, Response, request, abort from .serializers import (decode_response, encode_data_client as encode_data, @@ -91,8 +92,8 @@ .format(self.args)) -class MetaSWHRemoteAPI(type): - """Metaclass for SWHRemoteAPI, which adds a method for each endpoint +class MetaRPCClient(type): + """Metaclass for RPCClient, which adds a method for each endpoint of the database it is designed to access. See for example :class:`swh.indexer.storage.api.client.RemoteStorage`""" @@ -134,8 +135,8 @@ attributes[meth_name] = meth_ -class SWHRemoteAPI(metaclass=MetaSWHRemoteAPI): - """Proxy to an internal SWH API +class RPCClient(metaclass=MetaRPCClient): + """Proxy to an internal SWH RPC """ @@ -293,7 +294,7 @@ return response -class SWHServerAPIApp(Flask): +class RPCServerApp(Flask): """For each endpoint of the given `backend_class`, tells app.route to call a function that decodes the request and sends it to the backend object provided by the factory. @@ -326,3 +327,16 @@ # Call the actual code obj_meth = getattr(backend_factory(), meth_name) return encode_data_server(obj_meth(**decode_request(request))) + + +SWHServerAPIApp = deprecated( + version='0.0.64', + reason='Use the RPCServerApp instead')(RPCServerApp) + +MetaSWHRemoteAPI = deprecated( + version='0.0.64', + reason='Use the MetaRPCClient instead')(MetaRPCClient) + +SWHRemoteAPI = deprecated( + version='0.0.64', + reason='Use the RPCClient instead')(RPCClient) diff --git a/swh/core/api/asynchronous.py b/swh/core/api/asynchronous.py --- a/swh/core/api/asynchronous.py +++ b/swh/core/api/asynchronous.py @@ -5,6 +5,7 @@ import traceback import aiohttp.web +from deprecated import deprecated import multidict from .serializers import msgpack_dumps, msgpack_loads, SWHJSONDecoder @@ -48,7 +49,12 @@ return middleware_handler -class SWHRemoteAPI(aiohttp.web.Application): +class RPCServerApp(aiohttp.web.Application): def __init__(self, *args, middlewares=(), **kwargs): middlewares = (error_middleware,) + middlewares super().__init__(*args, middlewares=middlewares, **kwargs) + + +SWHRemoteAPI = deprecated( + version='0.0.64', + reason='Use the RPCServerApp instead')(RPCServerApp)