Comparing version 1.2.17 to 1.2.18
@@ -57,5 +57,5 @@ 'use strict'; | ||
function addApiPlugin(apiName, pluginName, params) { | ||
function addApiPlugin(apiId, pluginName, params) { | ||
return { | ||
endpoint: { name: 'api-plugins', params: { apiName: apiName, pluginName: pluginName } }, | ||
endpoint: { name: 'api-plugins', params: { apiId: apiId, pluginName: pluginName } }, | ||
method: 'POST', | ||
@@ -66,5 +66,5 @@ body: (0, _objectAssign2.default)({}, params, { name: pluginName }) | ||
function removeApiPlugin(apiName, pluginId) { | ||
function removeApiPlugin(apiId, pluginId) { | ||
return { | ||
endpoint: { name: 'api-plugin', params: { apiName: apiName, pluginId: pluginId } }, | ||
endpoint: { name: 'api-plugin', params: { apiId: apiId, pluginId: pluginId } }, | ||
method: 'DELETE' | ||
@@ -74,5 +74,5 @@ }; | ||
function updateApiPlugin(apiName, pluginId, params) { | ||
function updateApiPlugin(apiId, pluginId, params) { | ||
return { | ||
endpoint: { name: 'api-plugin', params: { apiName: apiName, pluginId: pluginId } }, | ||
endpoint: { name: 'api-plugin', params: { apiId: apiId, pluginId: pluginId } }, | ||
method: 'PATCH', | ||
@@ -79,0 +79,0 @@ body: params |
@@ -221,2 +221,11 @@ 'use strict'; | ||
}, | ||
getApiId: function getApiId(apiName) { | ||
var id = world.getApi(apiName).id; | ||
if (!id) { | ||
throw new Error('API ' + apiName + ' doesn\'t have an Id'); | ||
} | ||
return id; | ||
}, | ||
getGlobalPlugin: function getGlobalPlugin(pluginName) { | ||
@@ -459,2 +468,6 @@ var plugin = plugins.find(function (plugin) { | ||
function validateApiRequiredAttributes(api) { | ||
if (false == api.hasOwnProperty('name')) { | ||
throw Error('"Api name is required: ' + JSON.stringify(api, null, ' ')); | ||
} | ||
if (false == api.hasOwnProperty('attributes')) { | ||
@@ -475,3 +488,3 @@ throw Error('"' + api.name + '" api has to declare "upstream_url" attribute'); | ||
if (world.hasPlugin(apiName, plugin.name)) { | ||
return (0, _actions.removeApiPlugin)(apiName, world.getPluginId(apiName, plugin.name)); | ||
return (0, _actions.removeApiPlugin)(world.getApiId(apiName), world.getPluginId(apiName, plugin.name)); | ||
} | ||
@@ -489,6 +502,6 @@ | ||
return (0, _actions.updateApiPlugin)(apiName, world.getPluginId(apiName, plugin.name), plugin.attributes); | ||
return (0, _actions.updateApiPlugin)(world.getApiId(apiName), world.getPluginId(apiName, plugin.name), plugin.attributes); | ||
} | ||
return (0, _actions.addApiPlugin)(apiName, plugin.name, plugin.attributes); | ||
return (0, _actions.addApiPlugin)(world.getApiId(apiName), plugin.name, plugin.attributes); | ||
}; | ||
@@ -495,0 +508,0 @@ } |
@@ -43,10 +43,18 @@ 'use strict'; | ||
case 0: | ||
_context.next = 2; | ||
if (item.hasOwnProperty('id')) { | ||
_context.next = 2; | ||
break; | ||
} | ||
throw Error('"API doesn\'t have an Id: ' + JSON.stringify(item, null, ' ')); | ||
case 2: | ||
_context.next = 4; | ||
return fetchPlugins(item.id); | ||
case 2: | ||
case 4: | ||
plugins = _context.sent; | ||
return _context.abrupt('return', _extends({}, item, { plugins: plugins })); | ||
case 4: | ||
case 6: | ||
case 'end': | ||
@@ -53,0 +61,0 @@ return _context.stop(); |
@@ -22,3 +22,3 @@ 'use strict'; | ||
case 'api-plugin': | ||
return adminApiRoot + '/apis/' + params.apiName + '/plugins/' + params.pluginId; | ||
return adminApiRoot + '/apis/' + params.apiId + '/plugins/' + params.pluginId; | ||
case 'consumers': | ||
@@ -25,0 +25,0 @@ return adminApiRoot + '/consumers'; |
{ | ||
"name": "kongfig", | ||
"version": "1.2.17", | ||
"version": "1.2.18", | ||
"description": "A tool for Kong to allow declarative configuration.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/mybuilder/kongfig", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
215888
33
3179