Remove support for SPORE protcol
Yet another one bites the dust. Change-Id: I604a6bfd0dbc39495a4dc2e66175d0d5408c472f Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
4ea5f92704
commit
128f591b7e
@ -8,6 +8,7 @@ Changes
|
||||
* Remove support for cornice
|
||||
* Remove support for ExtDirect
|
||||
* Remove support for SOAP
|
||||
* Remove support for the SPORE protocol
|
||||
* Remove SQLAlchemy support. It has never actually worked to begin with.
|
||||
|
||||
0.9.2 (2017-02-14)
|
||||
|
@ -1,18 +0,0 @@
|
||||
import spyre
|
||||
import spyre.middleware
|
||||
|
||||
|
||||
class CTypeHeader(spyre.middleware.Middleware):
|
||||
def __call__(self, env):
|
||||
env.setdefault('spore.headers', [])
|
||||
env['spore.headers'].extend([
|
||||
('Accept', 'application/json'),
|
||||
('Content-Type', 'application/json')
|
||||
])
|
||||
|
||||
|
||||
demo = spyre.new_from_url('http://127.0.0.1:8080/ws/api.spore')
|
||||
demo.enable(CTypeHeader)
|
||||
demo.enable('format.Json')
|
||||
|
||||
print demo.helloworld().content
|
@ -10,7 +10,6 @@ import webob
|
||||
from wsme.exc import ClientSideError, UnknownFunction
|
||||
from wsme.protocol import getprotocol
|
||||
from wsme.rest import scan_api
|
||||
from wsme import spore
|
||||
import wsme.api
|
||||
import wsme.types
|
||||
|
||||
@ -232,11 +231,6 @@ class WSRoot(object):
|
||||
res.content_type = func._cfg['content-type']
|
||||
return res
|
||||
|
||||
if request.path == self._webpath + '/api.spore':
|
||||
res.body = spore.getdesc(self, request.host_url)
|
||||
res.content_type = 'application/json'
|
||||
return res
|
||||
|
||||
try:
|
||||
msg = None
|
||||
error_status = 500
|
||||
|
@ -1,64 +0,0 @@
|
||||
from wsme import types
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json # noqa
|
||||
|
||||
|
||||
def getdesc(root, host_url=''):
|
||||
methods = {}
|
||||
|
||||
for path, funcdef in root.getapi():
|
||||
method = funcdef.extra_options.get('method', None)
|
||||
name = '_'.join(path)
|
||||
if method is not None:
|
||||
path = path[:-1]
|
||||
else:
|
||||
method = 'GET'
|
||||
for argdef in funcdef.arguments:
|
||||
if types.iscomplex(argdef.datatype) \
|
||||
or types.isarray(argdef.datatype) \
|
||||
or types.isdict(argdef.datatype):
|
||||
method = 'POST'
|
||||
break
|
||||
|
||||
required_params = []
|
||||
optional_params = []
|
||||
for argdef in funcdef.arguments:
|
||||
if method == 'GET' and argdef.mandatory:
|
||||
required_params.append(argdef.name)
|
||||
else:
|
||||
optional_params.append(argdef.name)
|
||||
|
||||
methods[name] = {
|
||||
'method': method,
|
||||
'path': '/'.join(path)
|
||||
}
|
||||
if required_params:
|
||||
methods[name]['required_params'] = required_params
|
||||
if optional_params:
|
||||
methods[name]['optional_params'] = optional_params
|
||||
if funcdef.doc:
|
||||
methods[name]['documentation'] = funcdef.doc
|
||||
|
||||
formats = []
|
||||
for p in root.protocols:
|
||||
if p.name == 'restxml':
|
||||
formats.append('xml')
|
||||
if p.name == 'restjson':
|
||||
formats.append('json')
|
||||
|
||||
api = {
|
||||
'base_url': host_url + root._webpath,
|
||||
'version': '0.1',
|
||||
'name': getattr(root, 'name', 'name'),
|
||||
'authority': '',
|
||||
'formats': [
|
||||
'json',
|
||||
'xml'
|
||||
],
|
||||
'methods': methods
|
||||
}
|
||||
|
||||
return json.dumps(api, indent=4)
|
@ -1,51 +0,0 @@
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
from wsme.tests.protocol import WSTestRoot
|
||||
import wsme.tests.test_restjson
|
||||
import wsme.spore
|
||||
|
||||
|
||||
class TestSpore(unittest.TestCase):
|
||||
def test_spore(self):
|
||||
spore = wsme.spore.getdesc(WSTestRoot())
|
||||
|
||||
print(spore)
|
||||
|
||||
spore = json.loads(spore)
|
||||
|
||||
assert len(spore['methods']) == 51, str(len(spore['methods']))
|
||||
|
||||
m = spore['methods']['argtypes_setbytesarray']
|
||||
assert m['path'] == 'argtypes/setbytesarray', m['path']
|
||||
assert m['optional_params'] == ['value']
|
||||
assert m['method'] == 'POST'
|
||||
|
||||
m = spore['methods']['argtypes_setdecimal']
|
||||
assert m['path'] == 'argtypes/setdecimal'
|
||||
assert m['required_params'] == ['value']
|
||||
assert m['method'] == 'GET'
|
||||
|
||||
m = spore['methods']['crud_create']
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'PUT'
|
||||
assert m['optional_params'] == ['data']
|
||||
|
||||
m = spore['methods']['crud_read']
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'GET'
|
||||
assert m['required_params'] == ['ref']
|
||||
|
||||
m = spore['methods']['crud_update']
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'POST'
|
||||
assert m['optional_params'] == ['data']
|
||||
|
||||
m = spore['methods']['crud_delete']
|
||||
assert m['path'] == 'crud'
|
||||
assert m['method'] == 'DELETE'
|
||||
assert m['optional_params'] == ['ref']
|
Loading…
Reference in New Issue
Block a user