API: Adding the stroage service stub
The storage service API will hold the equivelent information of the StorageServiceMBean. This adds the API with one stubed method the get local hostid. After the patch the storage_service doc will be available at: http://localhost:10000/api-doc/storage_service/ And the stubed local host id will be under: http://localhost:10000/storage_service/local_hostid and will return an empty string Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
29
api/api-doc/storage_service.json
Normal file
29
api/api-doc/storage_service.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"apiVersion":"0.0.1",
|
||||
"swaggerVersion":"1.2",
|
||||
"basePath":"{{Protocol}}://{{Host}}",
|
||||
"resourcePath":"/storage_service",
|
||||
"produces":[
|
||||
"application/json"
|
||||
],
|
||||
"apis":[
|
||||
{
|
||||
"path":"/storage_service/hostid/local",
|
||||
"operations":[
|
||||
{
|
||||
"method":"GET",
|
||||
"summary":"Returns the local host id",
|
||||
"type":"string",
|
||||
"nickname":"local_hostid",
|
||||
"produces":[
|
||||
"application/json"
|
||||
],
|
||||
"parameters":[
|
||||
{
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4,13 +4,20 @@
|
||||
|
||||
#include "api.hh"
|
||||
#include "http/api_docs.hh"
|
||||
#include "storage_service.hh"
|
||||
|
||||
namespace api {
|
||||
|
||||
future<> set_server(http_context& ctx) {
|
||||
auto rb = std::make_shared < api_registry_builder > ("api/api-doc/");
|
||||
|
||||
return ctx.http_server.set_routes(rb->set_api_doc());
|
||||
return ctx.http_server.set_routes(rb->set_api_doc()).then([&ctx, rb] {
|
||||
ctx.http_server.set_routes(rb->register_function("storage_service",
|
||||
"The storage service API"))
|
||||
.then([&ctx] {
|
||||
return set_storage_service(ctx);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
18
api/storage_service.cc
Normal file
18
api/storage_service.cc
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2015 Cloudius Systems
|
||||
*/
|
||||
|
||||
#include "storage_service.hh"
|
||||
#include "api/api-doc/storage_service.json.hh"
|
||||
|
||||
namespace api {
|
||||
|
||||
future<> set_storage_service(http_context& ctx) {
|
||||
return ctx.http_server.set_routes([] (routes& r) {
|
||||
httpd::storage_service_json::local_hostid.set(r, [](const_req req) {
|
||||
return "";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
16
api/storage_service.hh
Normal file
16
api/storage_service.hh
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2015 Cloudius Systems
|
||||
*/
|
||||
|
||||
#ifndef API_STORAGE_SERVICE_HH_
|
||||
#define API_STORAGE_SERVICE_HH_
|
||||
|
||||
#include "api.hh"
|
||||
|
||||
namespace api {
|
||||
|
||||
future<> set_storage_service(http_context& ctx);
|
||||
|
||||
}
|
||||
|
||||
#endif /* API_APP_HH_ */
|
||||
@@ -261,6 +261,8 @@ http = ['http/transformers.cc',
|
||||
]
|
||||
|
||||
api = ['api/api.cc',
|
||||
'api/api-doc/storage_service.json',
|
||||
'api/storage_service.cc',
|
||||
]
|
||||
defines = []
|
||||
libs = '-laio -lboost_program_options -lboost_system -lstdc++ -lm -lboost_unit_test_framework -lboost_thread -lcryptopp -lrt'
|
||||
|
||||
Reference in New Issue
Block a user