From ede2864c0e0936473f240cb29e74b21d9d1a3876 Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona <47326048+jloboescalona2@users.noreply.github.com> Date: Thu, 10 Sep 2020 10:51:30 +0200 Subject: [PATCH] B #3951: fix routes oneflow fireedge (#200) Signed-off-by: Jorge Lobo --- .../src/routes/api/routes/oneflow/index.js | 38 +++++-------------- .../src/routes/api/routes/oneflow/service.js | 19 +--------- .../api/routes/oneflow/service_template.js | 18 +-------- .../api/routes/oneflow/string-routes.js | 24 +++--------- 4 files changed, 18 insertions(+), 81 deletions(-) diff --git a/src/fireedge/src/routes/api/routes/oneflow/index.js b/src/fireedge/src/routes/api/routes/oneflow/index.js index d1ae7711a33..07792993e32 100644 --- a/src/fireedge/src/routes/api/routes/oneflow/index.js +++ b/src/fireedge/src/routes/api/routes/oneflow/index.js @@ -13,7 +13,6 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ const { - serviceAll, service, serviceDelete, serviceAddAction, @@ -21,7 +20,6 @@ const { serviceAddRoleAction } = require('./service'); const { - serviceTemplateAll, serviceTemplate, serviceTemplateDelete, serviceTemplateCreate, @@ -30,28 +28,17 @@ const { } = require('./service_template'); const { httpMethod } = require('../../../../utils/constants/defaults'); const { - SERVICE_ALL, SERVICE, - SERVICE_DELETE, - SERVICE_ADD_ACTION, - SERVICE_ADD_SCALE, - SERVICE_ADD_ROLE_ACTION, - SERVICE_TEMPLATE_ALL, + SERVICE_ACTION, + SERVICE_SCALE, + SERVICE_ROLE_ACTION, SERVICE_TEMPLATE, - SERVICE_TEMPLATE_DELETE, - SERVICE_TEMPLATE_CREATE, - SERVICE_TEMPLATE_UPDATE, SERVICE_TEMPLATE_ACTION } = require('./string-routes'); const { GET, POST, DELETE, PUT } = httpMethod; const privateRoutes = [ - { - httpMethod: GET, - endpoint: SERVICE_ALL, - action: serviceAll - }, { httpMethod: GET, endpoint: SERVICE, @@ -59,29 +46,24 @@ const privateRoutes = [ }, { httpMethod: DELETE, - endpoint: SERVICE_DELETE, + endpoint: SERVICE, action: serviceDelete }, { httpMethod: POST, - endpoint: SERVICE_ADD_ACTION, + endpoint: SERVICE_ACTION, action: serviceAddAction }, { httpMethod: POST, - endpoint: SERVICE_ADD_SCALE, + endpoint: SERVICE_SCALE, action: serviceAddScale }, { httpMethod: POST, - endpoint: SERVICE_ADD_ROLE_ACTION, + endpoint: SERVICE_ROLE_ACTION, action: serviceAddRoleAction }, - { - httpMethod: GET, - endpoint: SERVICE_TEMPLATE_ALL, - action: serviceTemplateAll - }, { httpMethod: GET, endpoint: SERVICE_TEMPLATE, @@ -89,17 +71,17 @@ const privateRoutes = [ }, { httpMethod: DELETE, - endpoint: SERVICE_TEMPLATE_DELETE, + endpoint: SERVICE_TEMPLATE, action: serviceTemplateDelete }, { httpMethod: POST, - endpoint: SERVICE_TEMPLATE_CREATE, + endpoint: SERVICE_TEMPLATE, action: serviceTemplateCreate }, { httpMethod: PUT, - endpoint: SERVICE_TEMPLATE_UPDATE, + endpoint: SERVICE_TEMPLATE, action: serviceTemplateUpdate }, { diff --git a/src/fireedge/src/routes/api/routes/oneflow/service.js b/src/fireedge/src/routes/api/routes/oneflow/service.js index 9eee1fd0d81..cf28f45686d 100644 --- a/src/fireedge/src/routes/api/routes/oneflow/service.js +++ b/src/fireedge/src/routes/api/routes/oneflow/service.js @@ -26,14 +26,6 @@ const { parsePostData, returnSchemaError } = require('./functions'); const { GET, POST, DELETE } = httpMethod; -const serviceAll = (req, res, next, connect, zone, user) => { - if (req && res && user && next) { - conectionOneFlow(res, next, GET, user, '/service'); - } else { - next(); - } -}; - const service = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -52,12 +44,7 @@ const service = (req, res, next, connect, zone, user) => { req[fromData.resource].method ); } else { - res.locals.httpCode = httpResponse( - methodNotAllowed, - '', - 'invalid id service' - ); - next(); + conectionOneFlow(res, next, GET, user, '/service'); } } else { next(); @@ -89,7 +76,6 @@ const serviceDelete = (req, res, next, connect, zone, user) => { } }; -// PROBAR oneflow-server.rb const serviceAddAction = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -135,7 +121,6 @@ const serviceAddAction = (req, res, next, connect, zone, user) => { } }; -// PROBAR const serviceAddScale = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -181,7 +166,6 @@ const serviceAddScale = (req, res, next, connect, zone, user) => { } }; -// PROBAR oneflow-server.rb const serviceAddRoleAction = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -229,7 +213,6 @@ const serviceAddRoleAction = (req, res, next, connect, zone, user) => { }; const serviceApi = { - serviceAll, service, serviceDelete, serviceAddAction, diff --git a/src/fireedge/src/routes/api/routes/oneflow/service_template.js b/src/fireedge/src/routes/api/routes/oneflow/service_template.js index 3948b9671be..ea66566b887 100644 --- a/src/fireedge/src/routes/api/routes/oneflow/service_template.js +++ b/src/fireedge/src/routes/api/routes/oneflow/service_template.js @@ -26,14 +26,6 @@ const { parsePostData, returnSchemaError } = require('./functions'); const { GET, POST, DELETE, PUT } = httpMethod; -const serviceTemplateAll = (req, res, next, connect, zone, user) => { - if (req && res && user && next) { - conectionOneFlow(res, next, GET, user, '/service_template'); - } else { - next(); - } -}; - const serviceTemplate = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -47,12 +39,7 @@ const serviceTemplate = (req, res, next, connect, zone, user) => { req[fromData.resource].method ]); } else { - res.locals.httpCode = httpResponse( - methodNotAllowed, - '', - 'invalid id service template' - ); - next(); + conectionOneFlow(res, next, GET, user, '/service_template'); } } else { next(); @@ -122,7 +109,6 @@ const serviceTemplateCreate = (req, res, next, connect, zone, user) => { } }; -// PROBAR const serviceTemplateUpdate = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -169,7 +155,6 @@ const serviceTemplateUpdate = (req, res, next, connect, zone, user) => { } }; -// PROBAR oneflow-server.rb const serviceTemplateAction = (req, res, next, connect, zone, user) => { if (req && res && user && next) { if ( @@ -216,7 +201,6 @@ const serviceTemplateAction = (req, res, next, connect, zone, user) => { }; const serviceTemplateApi = { - serviceTemplateAll, serviceTemplate, serviceTemplateDelete, serviceTemplateCreate, diff --git a/src/fireedge/src/routes/api/routes/oneflow/string-routes.js b/src/fireedge/src/routes/api/routes/oneflow/string-routes.js index a0a963807b3..5d3f59da230 100644 --- a/src/fireedge/src/routes/api/routes/oneflow/string-routes.js +++ b/src/fireedge/src/routes/api/routes/oneflow/string-routes.js @@ -1,28 +1,16 @@ -const SERVICE_ALL = 'service-all'; const SERVICE = 'service'; -const SERVICE_DELETE = 'service-delete'; -const SERVICE_ADD_ACTION = 'service-add-action'; -const SERVICE_ADD_SCALE = 'service-add-scale'; -const SERVICE_ADD_ROLE_ACTION = 'service-add-role-action'; -const SERVICE_TEMPLATE_ALL = 'service_template-all'; +const SERVICE_ACTION = 'service-action'; +const SERVICE_SCALE = 'service-scale'; +const SERVICE_ROLE_ACTION = 'service-role-action'; const SERVICE_TEMPLATE = 'service_template'; -const SERVICE_TEMPLATE_DELETE = 'service_template-delete'; -const SERVICE_TEMPLATE_CREATE = 'service_template-create'; -const SERVICE_TEMPLATE_UPDATE = 'service_template-update'; const SERVICE_TEMPLATE_ACTION = 'service_template-action'; const Actions = { - SERVICE_ALL, SERVICE, - SERVICE_DELETE, - SERVICE_ADD_ACTION, - SERVICE_ADD_SCALE, - SERVICE_ADD_ROLE_ACTION, - SERVICE_TEMPLATE_ALL, + SERVICE_ACTION, + SERVICE_SCALE, + SERVICE_ROLE_ACTION, SERVICE_TEMPLATE, - SERVICE_TEMPLATE_DELETE, - SERVICE_TEMPLATE_CREATE, - SERVICE_TEMPLATE_UPDATE, SERVICE_TEMPLATE_ACTION };