Skip to content

Commit

Permalink
update to v0.2.19 of the library. Add new example: findApiProductForP…
Browse files Browse the repository at this point in the history
…roxy.js
  • Loading branch information
DinoChiesa committed Dec 8, 2017
1 parent 8bb1c71 commit 923a99c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 7 deletions.
74 changes: 74 additions & 0 deletions examples/findApiProductForProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// findApiProductForProxy.js
// ------------------------------------------------------------------
//
// created: Mon Mar 20 09:57:02 2017
// last saved: <2017-December-07 18:19:37>

var edgejs = require('apigee-edge-js'),
common = edgejs.utility,
apigeeEdge = edgejs.edge,
Getopt = require('node-getopt'),
version = '20171207-1807',
getopt = new Getopt(common.commonOptions.concat([
['P' , 'proxy=ARG', 'Required. the proxy to find.'],
['T' , 'notoken', 'Optional. do not try to obtain a login token.']
])).bindHelp();

console.log(
'Apigee Edge findApiProductForProxy.js tool, version: ' + version + '\n' +
'Node.js ' + process.version + '\n');

common.logWrite('start');

// process.argv array starts with 'node' and 'scriptname.js'
var opt = getopt.parse(process.argv.slice(2));

function handleError(e) {
if (e) {
console.log(e);
console.log(e.stack);
process.exit(1);
}
}
// ========================================================

common.verifyCommonRequiredParameters(opt.options, getopt);

if ( !opt.options.proxy ) {
console.log('You must specify a proxy to find');
getopt.showHelp();
process.exit(1);
}

var options = {
mgmtServer: opt.options.mgmtserver,
org : opt.options.org,
user: opt.options.username,
password: opt.options.password,
no_token: opt.options.notoken,
verbosity: opt.options.verbose || 0
};

apigeeEdge.connect(options, function(e, org) {
handleError(e);
org.products.get({expand:true}, function(e, result) {
handleError(e);
var apiproducts = result.apiProduct;
common.logWrite('total count of API products for that org: %d', apiproducts.length);
var filtered = apiproducts.filter(function(product) {
return (product.proxies.indexOf(opt.options.proxy) >= 0);
});

if (filtered) {
common.logWrite('count of API products containing %s: %d', opt.options.proxy, filtered.length);
if (filtered.length) {
common.logWrite(JSON.stringify(filtered.map( function(item) { return item.name;}), null, 2));

}
if ( opt.options.verbose ) {
common.logWrite(JSON.stringify(filtered, null, 2));
}
}

});
});
5 changes: 2 additions & 3 deletions examples/findJavaPolicies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
//
// This tool does not examine environment-wide or organization-wide resources.
//
// last saved: <2017-December-07 17:55:02>
// last saved: <2017-December-07 18:06:43>

var fs = require('fs'),
async = require('async'),
var async = require('async'),
edgejs = require('apigee-edge-js'),
common = edgejs.utility,
apigeeEdge = edgejs.edge,
Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "dchiesa@google.com",
"license": "Apache-2.0",
"dependencies": {
"apigee-edge-js": "^0.2.18",
"apigee-edge-js": "^0.2.19",
"async": "^2.2.0",
"mkdirp": "^0.5.1",
"netrc": "0.1.3",
Expand Down
4 changes: 2 additions & 2 deletions lib/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// library of functions for Apigee Edge.
//
// created: Mon Jun 6 17:32:20 2016
// last saved: <2017-November-08 18:20:22>
// last saved: <2017-December-07 18:22:37>

(function (){
var path = require('path'),
Expand Down Expand Up @@ -1233,7 +1233,7 @@
mergeRequestOptions(conn, function(requestOptions) {
requestOptions.url = (options.name) ?
urljoin(conn.urlBase, 'apiproducts', options.name) :
urljoin(conn.urlBase, 'apiproducts') ;
urljoin(conn.urlBase, 'apiproducts') + (options.expand ? '?expand=true' : '');
if (conn.verbosity>0) {
utility.logWrite(sprintf('GET %s', requestOptions.url));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apigee-edge-js",
"version": "0.2.18",
"version": "0.2.19",
"description": "Dino's nodejs library for the administration API for Apigee Edge.",
"main" : "index.js",
"scripts": {
Expand Down

0 comments on commit 923a99c

Please sign in to comment.