refactor all the api, offer a new syntax (BC broken)
The version 0.5 will be a completely re-factored version with a new Client class added.
The purpose is to separate concerns and apply the KISS principle.
-
Move Endpoints handling from
documents.peer
module to a newapi.endpoint
module. -
Create a new
ws2p
dedicated package. -
Create a new
elasticsearch
dedicated package.
Write a new Client class to simplify connection syntax.
Example :
BMAS_ENDPOINT = "BMAS node.domain.org 443"
# Create Client from endpoint string in Duniter format
client = Client(BMAS_ENDPOINT)
# Get the node summary infos by dedicated method (with json schema validation)
response = await client(bma.node.summary)
print(response)
# Get the money parameters located in the first block
response = await client(bma.blockchain.parameters)
print(response)
# Get the current block
response = await client(bma.blockchain.current)
print(response)
# Get the block number 10
response = await client(bma.blockchain.block, 10)
print(response)
# jsonschema validator
summary_schema = {
"type": "object",
"properties": {
"duniter": {
"type": "object",
"properties": {
"software": {
"type": "string"
},
"version": {
"type": "string",
},
"forkWindowSize": {
"type": "number"
}
},
"required": ["software", "version"]
},
},
"required": ["duniter"]
}
# Get the node summary infos (direct REST GET request)
response = await client.get('node/summary', rtype=RESPONSE_AIOHTTP, schema=summary_schema)
print(response)
# Close client aiohttp session
await client.close()