k2hr3-api
Version:
K2HR3 REST API is K2hdkc based Resource and Roles and policy Rules
104 lines (103 loc) • 3.3 kB
JavaScript
;
/*
* K2HR3 REST API
*
* Copyright 2017 Yahoo Japan Corporation.
*
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
* common management information for the cloud.
* K2HR3 can dynamically manage information as "who", "what", "operate".
* These are stored as roles, resources, policies in K2hdkc, and the
* client system can dynamically read and modify these information.
*
* For the full copyright and license information, please view
* the license file that was distributed with this source code.
*
* AUTHOR: Takeshi Nakatani
* CREATE: Wed Jun 8 2017
* REVISION:
*
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dbglogging_1 = __importDefault(require("../lib/dbglogging"));
const express_1 = __importDefault(require("express"));
const router = express_1.default.Router();
//
// GET '/' : get all API version
// output : {'version': 'v1'}
//
router.get('/', (req, res, _) => {
dbglogging_1.default.dlog('CALL:', req.method, req.url);
const result = { 'version': ['v1'] };
res.type('application/json; charset=utf-8');
res.send(result);
});
//
// GET '/v1': get all API for version 1
// output : {'type': {'uri': ['method', ...], ...}, ...}
//
router.get('/v1', (req, res, _) => {
dbglogging_1.default.dlog('CALL:', req.method, req.url);
res.type('application/json; charset=utf-8');
const result = {
'version': {
'/': ['GET'],
'/v1': ['GET']
},
'user token': {
'/v1/user/tokens': ['HEAD', 'GET', 'POST']
},
'host': {
'/v1/host': ['GET', 'PUT', 'POST', 'DELETE'],
'/v1/host/{port}': ['PUT', 'POST', 'DELETE'],
'/v1/host/FQDN': ['DELETE'],
'/v1/host/FQDN:{port}': ['DELETE'],
'/v1/host/IP': ['DELETE'],
'/v1/host/IP:{port}': ['DELETE']
},
'service': {
'/v1/service': ['PUT', 'POST'],
'/v1/service/{service}': ['GET', 'HEAD', 'PUT', 'POST', 'DELETE']
},
'role': {
'/v1/role': ['PUT', 'POST'],
'/v1/role/{role}': ['HEAD', 'GET', 'PUT', 'POST', 'DELETE'],
'/v1/role/token/{role}': ['GET']
},
'resource': {
'/v1/resource': ['PUT', 'POST'],
'/v1/resource/{resource}': ['HEAD', 'GET', 'DELETE']
},
'policy': {
'/v1/policy': ['PUT', 'POST'],
'/v1/policy/{policy}': ['HEAD', 'GET', 'DELETE']
},
'list': {
'/v1/list': ['HEAD', 'GET'],
'/v1/list/{role, resource, policy}/{path}': ['HEAD', 'GET']
},
'acr': {
'/v1/acr/{service}': ['GET', 'PUT', 'POST', 'DELETE']
}
};
res.status(200); // 200: OK
res.send(JSON.stringify(result));
});
//---------------------------------------------------------
// Exports
//---------------------------------------------------------
//
// Functions
//
exports.default = router;
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noexpandtab sw=4 ts=4 fdm=marker
* vim<600: noexpandtab sw=4 ts=4
*/