flatten the result structure

flat is better than nested
This commit is contained in:
Jean-Paul Calderone 2017-07-27 15:32:47 -04:00
parent e0ee726d22
commit 1f16a173f0
3 changed files with 25 additions and 33 deletions

View File

@ -1861,13 +1861,11 @@ of the introducer(s) and storage server(s), here's an example::
},
"servers": [{
"nodeid": "other_nodeid",
"description": {
"available_space": 123456,
"nickname": "George \u263b",
"version": "1.0",
"connection_status": "summary",
"last_received_data": 1487811257
}
}]
}
@ -1875,15 +1873,15 @@ of the introducer(s) and storage server(s), here's an example::
The above json ``introducers`` section includes a list of
introducer connectivity status messages.
The above json ``servers`` section is a map
where the key is a storage server node ID and the value
is a map of properties with the following usage for each key:
The above json ``servers`` section is an array with map elements. Each map
has the following properties:
1. ``available_space`` - the available space in bytes expressed as an integer
2. ``nickname`` - the storage server nickname
3. ``version`` - the storage server Tahoe-LAFS version
4. ``connection_status`` - connectivity status
5. ``last_received_data`` - the time when data was last received,
1. ``nodeid`` - an identifier derived from the node's public key
2. ``available_space`` - the available space in bytes expressed as an integer
3. ``nickname`` - the storage server nickname
4. ``version`` - the storage server Tahoe-LAFS version
5. ``connection_status`` - connectivity status
6. ``last_received_data`` - the time when data was last received,
expressed in seconds since epoch
``GET /status/``

View File

@ -754,23 +754,19 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
},
u'servers': sorted([
{u"nodeid": u'other_nodeid',
u"description": {
u'available_space': 123456,
u'connection_status': u'summary',
u'last_received_data': None,
u'nickname': u'other_nickname \u263b',
u'version': u'1.0',
},
},
{u"nodeid": u'disconnected_nodeid',
u"description": {
u'available_space': 123456,
u'connection_status': u'summary',
u'last_received_data': None,
u'nickname': u'disconnected_nickname \u263b',
u'version': u'1.0',
},
},
]),
}
self.assertEqual(expected, decoded)

View File

@ -214,10 +214,7 @@ class Root(MultiFormatPage):
def _describe_known_servers(self, broker):
return sorted(list(
{
u"nodeid": server.get_serverid(),
u"description": self._describe_server(server),
}
self._describe_server(server)
for server
in broker.get_known_servers()
))
@ -225,6 +222,7 @@ class Root(MultiFormatPage):
def _describe_server(self, server):
description = {
u"nodeid": server.get_serverid(),
u"connection_status": server.get_connection_status().summary,
u"available_space": server.get_available_space(),
u"nickname": server.get_nickname(),