Skip to content

Commit

Permalink
B #3951: fix routes oneflow fireedge (#200)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Lobo <[email protected]>
  • Loading branch information
jloboescalona2 authored and rsmontero committed Sep 14, 2020
1 parent 6b9af3e commit ede2864
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 81 deletions.
38 changes: 10 additions & 28 deletions src/fireedge/src/routes/api/routes/oneflow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
const {
serviceAll,
service,
serviceDelete,
serviceAddAction,
serviceAddScale,
serviceAddRoleAction
} = require('./service');
const {
serviceTemplateAll,
serviceTemplate,
serviceTemplateDelete,
serviceTemplateCreate,
Expand All @@ -30,76 +28,60 @@ 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,
action: service
},
{
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,
action: serviceTemplate
},
{
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
},
{
Expand Down
19 changes: 1 addition & 18 deletions src/fireedge/src/routes/api/routes/oneflow/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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();
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -229,7 +213,6 @@ const serviceAddRoleAction = (req, res, next, connect, zone, user) => {
};

const serviceApi = {
serviceAll,
service,
serviceDelete,
serviceAddAction,
Expand Down
18 changes: 1 addition & 17 deletions src/fireedge/src/routes/api/routes/oneflow/service_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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();
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -216,7 +201,6 @@ const serviceTemplateAction = (req, res, next, connect, zone, user) => {
};

const serviceTemplateApi = {
serviceTemplateAll,
serviceTemplate,
serviceTemplateDelete,
serviceTemplateCreate,
Expand Down
24 changes: 6 additions & 18 deletions src/fireedge/src/routes/api/routes/oneflow/string-routes.js
Original file line number Diff line number Diff line change
@@ -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
};

Expand Down

0 comments on commit ede2864

Please sign in to comment.