Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apiman-admin-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apiman-admin-client - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

README.md

8

index.js

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -21,2 +21,2 @@

module.exports = require('./lib/apiman');
module.exports = require('./lib/apiman');

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -31,3 +31,3 @@

* Initializes the apiman client.
*
*
* @instance

@@ -39,4 +39,3 @@ * @param {object} options - Request options.

*/
function apiman(options) {
function apiman (options) {
const handleOptions = (uri) => {

@@ -63,4 +62,4 @@ options = util.handleOptions(options);

/**
* Returns the status of the apiman system.
* This is useful to use when testing a client's connection
* Returns the status of the apiman system.
* This is useful to use when testing a client's connection
* to the apiman API Manager REST services.

@@ -72,3 +71,3 @@ *

*/
function status() {
function status () {
handleOptions(uris.STATUS);

@@ -79,3 +78,3 @@ return get();

/**
* Exports the data from the API Manager as JSON. All data in the API Manager,
* Exports the data from the API Manager as JSON. All data in the API Manager,
* including global/admin information, will be exported.

@@ -87,3 +86,3 @@ *

*/
function exportData() {
function exportData () {
handleOptions(uris.EXPORT);

@@ -101,3 +100,3 @@ return get();

*/
function importData(filePath) {
function importData (filePath) {
handleOptions(uris.IMPORT);

@@ -111,3 +110,3 @@ options.body = fs.readFileSync(filePath, 'utf-8');

/**
* Returns all the Gateways that have been configured.
* Returns all the Gateways that have been configured.
*

@@ -118,3 +117,3 @@ * @instance

*/
function gateways() {
function gateways () {
handleOptions(uris.GATEWAYS);

@@ -125,3 +124,3 @@ return get();

/**
* Returns information about the Gateway.
* Returns information about the Gateway.
*

@@ -133,3 +132,3 @@ * @instance

*/
function gateway(id) {
function gateway (id) {
handleOptions(uris.GATEWAYS);

@@ -140,4 +139,4 @@ return getById(id);

/**
* This function is used to create a new Gateway.
*
* This function is used to create a new Gateway.
*
* @instance

@@ -148,3 +147,3 @@ * @param {object} gatewayRepresentation - An object representing the gateway.

*/
function gatewayAdd(gatewayRepresentation) {
function gatewayAdd (gatewayRepresentation) {
handleOptions(uris.GATEWAYS);

@@ -156,4 +155,4 @@ options.body = gatewayRepresentation;

/**
* This function is used to remove a Gateway.
*
* This function is used to remove a Gateway.
*
* @instance

@@ -164,3 +163,3 @@ * @param {string} id - The ID of the Gateway.

*/
function gatewayDelete(id) {
function gatewayDelete (id) {
handleOptions(uris.GATEWAYS);

@@ -172,3 +171,3 @@ return remove(id);

* Returns all of the permissions assigned to the current authenticated user.
*
*
* @instance

@@ -178,3 +177,3 @@ * @function permissions

*/
function permissions() {
function permissions () {
handleOptions(uris.PERMISSIONS);

@@ -185,3 +184,3 @@ return get();

/**
* Returns all permissions of specific user.
* Returns all permissions of specific user.
*

@@ -193,3 +192,3 @@ * @instance

*/
function permissionsUser(id) {
function permissionsUser (id) {
handleOptions(uris.PERMISSIONS);

@@ -200,3 +199,3 @@ return getById(id);

/**
* Returns information about the Plugin.
* Returns information about the Plugin.
*

@@ -208,3 +207,3 @@ * @instance

*/
function plugin(id) {
function plugin (id) {
handleOptions(uris.PLUGINS);

@@ -216,3 +215,3 @@ return getById(id);

* Returns all plugins that have been added to the system.
*
*
* @instance

@@ -222,3 +221,3 @@ * @function plugins

*/
function plugins() {
function plugins () {
handleOptions(uris.PLUGINS);

@@ -229,4 +228,4 @@ return get();

/**
* This function is used to create a new Plugin.
*
* This function is used to create a new Plugin.
*
* @instance

@@ -237,3 +236,3 @@ * @param {object} pluginRepresentation - An object representing the plugin.

*/
function pluginAdd(pluginRepresentation) {
function pluginAdd (pluginRepresentation) {
handleOptions(uris.PLUGINS);

@@ -246,3 +245,3 @@ options.body = pluginRepresentation;

* Returns all available plugins.
*
*
* @instance

@@ -252,3 +251,3 @@ * @function availablePlugins

*/
function availablePlugins() {
function availablePlugins () {
handleOptions(uris.AVAILABLE_PLUGINS);

@@ -259,4 +258,4 @@ return get();

/**
* This function is used to remove a Plugin.
*
* This function is used to remove a Plugin.
*
* @instance

@@ -267,3 +266,3 @@ * @param {string} id - The ID of the Plugin.

*/
function pluginDelete(id) {
function pluginDelete (id) {
handleOptions(uris.PLUGINS);

@@ -275,3 +274,3 @@ return remove(id);

* Returns all the roles currently defined in apiman.
*
*
* @instance

@@ -281,3 +280,3 @@ * @function roles

*/
function roles() {
function roles () {
handleOptions(uris.ROLES);

@@ -288,3 +287,3 @@ return get();

/**
* Returns information about the role.
* Returns information about the role.
*

@@ -296,3 +295,3 @@ * @instance

*/
function role(id) {
function role (id) {
handleOptions(uris.ROLES);

@@ -303,4 +302,4 @@ return getById(id);

/**
* This function is used to remove a Role.
*
* This function is used to remove a Role.
*
* @instance

@@ -311,3 +310,3 @@ * @param {string} id - The ID of the Role.

*/
function roleDelete(id) {
function roleDelete (id) {
handleOptions(uris.ROLES);

@@ -318,3 +317,3 @@ return remove(id);

/**
* Returns information about the policy definition.
* Returns information about the policy definition.
*

@@ -326,3 +325,3 @@ * @instance

*/
function policyDefinition(id) {
function policyDefinition (id) {
handleOptions(uris.POLICY_DEFINITIONS);

@@ -334,3 +333,3 @@ return getById(id);

* Returns all the policy definitions currently defined in apiman.
*
*
* @instance

@@ -340,3 +339,3 @@ * @function policyDefinitions

*/
function policyDefinitions() {
function policyDefinitions () {
handleOptions(uris.POLICY_DEFINITIONS);

@@ -347,4 +346,4 @@ return get();

/**
* This function is used to remove a policy definition.
*
* This function is used to remove a policy definition.
*
* @instance

@@ -355,3 +354,3 @@ * @param {string} id - The ID of the policy definition.

*/
function policyDefinitionDelete(id) {
function policyDefinitionDelete (id) {
handleOptions(uris.POLICY_DEFINITIONS);

@@ -363,3 +362,3 @@ return remove(id);

* Returns all the organizations with APIs for the current user.
*
*
* @instance

@@ -369,3 +368,3 @@ * @function currentUserAPIOrganizations

*/
function currentUserAPIOrganizations() {
function currentUserAPIOrganizations () {
handleOptions(uris.CURRENT_USER_APIORGS);

@@ -377,3 +376,3 @@ return get();

* Returns all of the APIs the current user has permission to edit.
*
*
* @instance

@@ -383,3 +382,3 @@ * @function currentUserAPIs

*/
function currentUserAPIs() {
function currentUserAPIs () {
handleOptions(uris.CURRENT_USER_APIS);

@@ -390,5 +389,5 @@ return get();

/**
* Returns all the organizations with clients for the current user
* Returns all the organizations with clients for the current user
* has permission to edit clients.
*
*
* @instance

@@ -398,3 +397,3 @@ * @function currentUserClientOrganizations

*/
function currentUserClientOrganizations() {
function currentUserClientOrganizations () {
handleOptions(uris.CURRENT_USER_CLIENTORGS);

@@ -405,5 +404,5 @@ return get();

/**
* Returnsall the clients for the current user
* Returnsall the clients for the current user
* has permission to edit clients.
*
*
* @instance

@@ -413,3 +412,3 @@ * @function currentUserClients

*/
function currentUserClients() {
function currentUserClients () {
handleOptions(uris.CURRENT_USER_CLIENTS);

@@ -420,4 +419,4 @@ return get();

/**
* Returns information about the current authenticated user.
*
* Returns information about the current authenticated user.
*
* @instance

@@ -427,3 +426,3 @@ * @function currentUserInfo

*/
function currentUserInfo() {
function currentUserInfo () {
handleOptions(uris.CURRENT_USER_INFO);

@@ -434,4 +433,4 @@ return get();

/**
* Updates information about the current authenticated user.
*
* Updates information about the current authenticated user.
*
* @instance

@@ -443,3 +442,3 @@ * @param {string} email - User's email.

*/
function currentUserUpdate(email, fullName) {
function currentUserUpdate (email, fullName) {
handleOptions(uris.CURRENT_USER_INFO);

@@ -451,5 +450,5 @@ options.body = { email: email, fullName: fullName };

/**
* Returns all the organizations for which the current user
* Returns all the organizations for which the current user
* has permission to edit plans.
*
*
* @instance

@@ -459,3 +458,3 @@ * @function currentUserPlanOrganizations

*/
function currentUserPlanOrganizations() {
function currentUserPlanOrganizations () {
handleOptions(uris.CURRENT_USER_PLANORGS);

@@ -466,3 +465,3 @@ return get();

/**
* Returns information about the organization.
* Returns information about the organization.
*

@@ -474,3 +473,3 @@ * @instance

*/
function organization(id) {
function organization (id) {
handleOptions(uris.ORGANIZATIONS);

@@ -481,4 +480,4 @@ return getById(id);

/**
* This function is used to create a new Organization.
*
* This function is used to create a new Organization.
*
* @instance

@@ -490,3 +489,3 @@ * @param {string} name - Organization's name.

*/
function organizationAdd(name, description) {
function organizationAdd (name, description) {
handleOptions(uris.ORGANIZATIONS);

@@ -498,4 +497,4 @@ options.body = { name: name, description: description };

/**
* This function is used to remove a Organization.
*
* This function is used to remove a Organization.
*
* @instance

@@ -506,3 +505,3 @@ * @param {string} id - The ID of the Organization.

*/
function organizationDelete(id) {
function organizationDelete (id) {
handleOptions(uris.ORGANIZATIONS);

@@ -513,3 +512,3 @@ return remove(id);

/**
* Returns information about the user.
* Returns information about the user.
*

@@ -521,3 +520,3 @@ * @instance

*/
function user(id) {
function user (id) {
handleOptions(uris.USERS);

@@ -528,4 +527,4 @@ return getById(id);

/**
* Updates information about the user.
*
* Updates information about the user.
*
* @instance

@@ -538,3 +537,3 @@ * @param {string} userId - User's id.

*/
function userUpdate(userId, email, fullName) {
function userUpdate (userId, email, fullName) {
handleOptions(uris.USERS + userId);

@@ -547,3 +546,3 @@ options.body = { email: email, fullName: fullName };

* Returns all of the User's APIs.
*
*
* @instance

@@ -554,3 +553,3 @@ * @function userAPIs

*/
function userAPIs(userId) {
function userAPIs (userId) {
handleOptions(uris.USERS + userId + '/apis');

@@ -562,3 +561,3 @@ return get();

* Returns all of the User's clients.
*
*
* @instance

@@ -569,3 +568,3 @@ * @function userClients

*/
function userClients(userId) {
function userClients (userId) {
handleOptions(uris.USERS + userId + '/clients');

@@ -577,3 +576,3 @@ return get();

* Returns all of the User's organizations.
*
*
* @instance

@@ -584,3 +583,3 @@ * @function userOrganizations

*/
function userOrganizations(userId) {
function userOrganizations (userId) {
handleOptions(uris.USERS + userId + '/organizations');

@@ -627,3 +626,2 @@ return get();

});
}
}

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -75,2 +75,2 @@

remove: remove
};
};

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -38,3 +38,3 @@

STATUS: '/apiman/system/status/',
USERS: '/apiman/users/',
};
USERS: '/apiman/users/'
};

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -21,5 +21,6 @@

function util() {
module.exports = util();
function handleOptions(options) {
function util () {
function handleOptions (options) {
let baseUrl = options.baseUrl || 'http://localhost:8080';

@@ -29,3 +30,3 @@ let username = options.username || 'admin';

let body = options.body;
const result = {

@@ -42,8 +43,3 @@ baseUrl: baseUrl,

return Object.freeze({
handleOptions
});
return Object.freeze({handleOptions});
}
module.exports = util();
{
"name": "apiman-admin-client",
"version": "0.3.0",
"version": "0.4.0",
"description": "Node.js client for the Apiman admin API.",

@@ -9,2 +9,3 @@ "main": "index.js",

"lint": "jshint index.js lib/*.js test/*.js",
"format": "semistandard",
"coverage": "./node_modules/.bin/istanbul cover tape -- test/**.js",

@@ -26,3 +27,3 @@ "docs": "./node_modules/.bin/jsdoc -d docs -t ./node_modules/ink-docstrap/template -R README.md lib/apiman.js"

"engines": {
"node": ">= 5.0.0"
"node": ">= 4.0.0"
},

@@ -41,2 +42,3 @@ "homepage": "https://github.com/bucharest-gold/apiman-admin-client#readme",

"jshint": "^2.9.2",
"semistandard": "^8.0.0",
"tape": "^4.5.1"

@@ -43,0 +45,0 @@ },

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -25,14 +25,12 @@

test('setup', (t) => {
apiman = apiman({});
apiman = apiman({});
apiman
.importData(__dirname + '/fixtures/api-manager-export.json')
.importData(require('path').join(__dirname, '/fixtures/api-manager-export.json'))
.then(x => {
t.equals(x.indexOf('Data import completed successfully!') > 0, true);
t.equals(x.includes('Data import completed successfully!'), true);
t.end();
}).catch(e => console.log(e));
});
test('The client should verify the status.', (t) => {
apiman.status()

@@ -43,7 +41,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return configured gateways.', (t) => {
apiman.gateways()

@@ -55,7 +51,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return one gateway.', (t) => {
apiman.gateway('TheGateway')

@@ -66,7 +60,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should add a gateway.', (t) => {
let configuration = JSON.stringify({

@@ -90,10 +82,8 @@ endpoint: 'http://localhost:8080/apiman-gateway-api-new',

}).catch(e => console.log(e));
});
test('The client should export the data.', (t) => {
apiman.exportData()
.then(x => {
t.equal(x.Metadata.apimanVersion.indexOf('Final') > 0, true);
t.equal(x.Metadata.apimanVersion.includes('Final'), true);
t.end();

@@ -104,3 +94,2 @@ }).catch(e => console.log(e));

test('The client should return permissions.', (t) => {
apiman.permissions()

@@ -111,7 +100,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return permissions of the user.', (t) => {
apiman.permissionsUser('admin')

@@ -123,7 +110,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return one plugin.', (t) => {
apiman.plugin(999)

@@ -134,7 +119,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should add one plugin.', (t) => {
let plug = {

@@ -152,7 +135,5 @@ type: 'war',

}).catch(e => console.log(e));
});
test('The client should return plugins.', (t) => {
apiman.plugins()

@@ -164,7 +145,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return available plugins.', (t) => {
apiman.availablePlugins()

@@ -176,7 +155,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return roles.', (t) => {
apiman.roles()

@@ -188,7 +165,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return one role.', (t) => {
apiman.role('ClientAppDeveloper')

@@ -199,7 +174,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return one policy definition.', (t) => {
apiman.policyDefinition('AuthorizationPolicy')

@@ -210,7 +183,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return policy definitions.', (t) => {
apiman.policyDefinitions()

@@ -222,7 +193,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return current user API organizations.', (t) => {
apiman.currentUserAPIOrganizations()

@@ -234,7 +203,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return current user APIs.', (t) => {
apiman.currentUserAPIs()

@@ -246,7 +213,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return current user client organizations.', (t) => {
apiman.currentUserClientOrganizations()

@@ -258,7 +223,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return current user clients.', (t) => {
apiman.currentUserClients()

@@ -270,7 +233,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should get informations about current user.', (t) => {
apiman.currentUserInfo()

@@ -281,7 +242,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should update informations about current user.', (t) => {
apiman.currentUserUpdate('admin2@example.org', 'The super admin.')

@@ -292,7 +251,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return current user organizations able to edit plans.', (t) => {
apiman.currentUserPlanOrganizations()

@@ -304,7 +261,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return one organization.', (t) => {
apiman.organization('bucharest-gold')

@@ -315,7 +270,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should create one organization.', (t) => {
apiman.organizationAdd('bucharest-gold2', 'the super org.')

@@ -326,7 +279,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return one user.', (t) => {
apiman.user('admin')

@@ -337,7 +288,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should update informations about user.', (t) => {
apiman.userUpdate('admin', 'admin3@example.org', 'The super admin again.')

@@ -348,8 +297,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return user APIs.', (t) => {
apiman.userAPIs('admin')

@@ -361,7 +307,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return user organizations.', (t) => {
apiman.userOrganizations('admin')

@@ -373,7 +317,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should return user clients.', (t) => {
apiman.userClients('admin')

@@ -385,7 +327,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should remove one gateway.', (t) => {
apiman.gatewayDelete('TheNewGateway3')

@@ -397,7 +337,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should remove one plugin.', (t) => {
apiman.pluginDelete(999)

@@ -409,7 +347,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should remove one organization.', (t) => {
apiman.organizationDelete('bucharest-gold')

@@ -421,7 +357,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should remove one role.', (t) => {
apiman.roleDelete('APIDeveloper')

@@ -433,7 +367,5 @@ .then(x => {

}).catch(e => console.log(e));
});
test('The client should remove one policy definition.', (t) => {
apiman.policyDefinitionDelete('AuthorizationPolicy')

@@ -445,10 +377,7 @@ .then(x => {

}).catch(e => console.log(e));
});
test('teardown', t => {
console.log('done.');
t.end();
});
});

@@ -7,5 +7,5 @@ /**

* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software

@@ -15,3 +15,3 @@ * distributed under the License is distributed on an "AS IS" BASIS,

* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/

@@ -25,3 +25,2 @@

test('Util should handle the default options.', (t) => {
t.equal(util.handleOptions({}).baseUrl, 'http://localhost:8080');

@@ -34,3 +33,2 @@ let headers = { 'Authorization': 'Basic YWRtaW46YWRtaW4xMjMh' };

test('Util should handle the options.', (t) => {
const opts = {

@@ -44,2 +42,2 @@ username: 'foo',

t.end();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc