Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7122971
D1670.id5664.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D1670.id5664.diff
View Options
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)
diff --git a/swh/core/api/tests/test_api.py b/swh/core/api/tests/test_api.py
--- a/swh/core/api/tests/test_api.py
+++ b/swh/core/api/tests/test_api.py
@@ -11,7 +11,7 @@
from swh.core.api import (
error_handler, encode_data_server,
- remote_api_endpoint, SWHRemoteAPI, SWHServerAPIApp)
+ remote_api_endpoint, RPCClient, RPCServerApp)
class ApiTest(unittest.TestCase):
@@ -28,9 +28,9 @@
testcase.assertEqual(test_data, 'spam')
return 'egg'
- app = SWHServerAPIApp('testapp',
- backend_class=TestStorage,
- backend_factory=lambda: TestStorage())
+ app = RPCServerApp('testapp',
+ backend_class=TestStorage,
+ backend_factory=lambda: TestStorage())
@app.errorhandler(Exception)
def my_error_handler(exception):
@@ -67,13 +67,13 @@
'mock://example.com/test_endpoint_url',
content=callback)
- class Testclient(SWHRemoteAPI):
+ class Testclient(RPCClient):
backend_class = TestStorage
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# we need to mount the mock adapter on the base url to override
- # SWHRemoteAPI's mechanism that also mounts an HTTPAdapter
+ # RPCClient's mechanism that also mounts an HTTPAdapter
# (for configuration purpose)
self.session.mount('mock://example.com/', adapter)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 17 2024, 1:57 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3226462
Attached To
D1670: api: rename several API related classes
Event Timeline
Log In to Comment