Skip to content

Commit 923a99c

Browse files
committed
update to v0.2.19 of the library. Add new example: findApiProductForProxy.js
1 parent 8bb1c71 commit 923a99c

File tree

5 files changed

+80
-7
lines changed

5 files changed

+80
-7
lines changed

examples/findApiProductForProxy.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// findApiProductForProxy.js
2+
// ------------------------------------------------------------------
3+
//
4+
// created: Mon Mar 20 09:57:02 2017
5+
// last saved: <2017-December-07 18:19:37>
6+
7+
var edgejs = require('apigee-edge-js'),
8+
common = edgejs.utility,
9+
apigeeEdge = edgejs.edge,
10+
Getopt = require('node-getopt'),
11+
version = '20171207-1807',
12+
getopt = new Getopt(common.commonOptions.concat([
13+
['P' , 'proxy=ARG', 'Required. the proxy to find.'],
14+
['T' , 'notoken', 'Optional. do not try to obtain a login token.']
15+
])).bindHelp();
16+
17+
console.log(
18+
'Apigee Edge findApiProductForProxy.js tool, version: ' + version + '\n' +
19+
'Node.js ' + process.version + '\n');
20+
21+
common.logWrite('start');
22+
23+
// process.argv array starts with 'node' and 'scriptname.js'
24+
var opt = getopt.parse(process.argv.slice(2));
25+
26+
function handleError(e) {
27+
if (e) {
28+
console.log(e);
29+
console.log(e.stack);
30+
process.exit(1);
31+
}
32+
}
33+
// ========================================================
34+
35+
common.verifyCommonRequiredParameters(opt.options, getopt);
36+
37+
if ( !opt.options.proxy ) {
38+
console.log('You must specify a proxy to find');
39+
getopt.showHelp();
40+
process.exit(1);
41+
}
42+
43+
var options = {
44+
mgmtServer: opt.options.mgmtserver,
45+
org : opt.options.org,
46+
user: opt.options.username,
47+
password: opt.options.password,
48+
no_token: opt.options.notoken,
49+
verbosity: opt.options.verbose || 0
50+
};
51+
52+
apigeeEdge.connect(options, function(e, org) {
53+
handleError(e);
54+
org.products.get({expand:true}, function(e, result) {
55+
handleError(e);
56+
var apiproducts = result.apiProduct;
57+
common.logWrite('total count of API products for that org: %d', apiproducts.length);
58+
var filtered = apiproducts.filter(function(product) {
59+
return (product.proxies.indexOf(opt.options.proxy) >= 0);
60+
});
61+
62+
if (filtered) {
63+
common.logWrite('count of API products containing %s: %d', opt.options.proxy, filtered.length);
64+
if (filtered.length) {
65+
common.logWrite(JSON.stringify(filtered.map( function(item) { return item.name;}), null, 2));
66+
67+
}
68+
if ( opt.options.verbose ) {
69+
common.logWrite(JSON.stringify(filtered, null, 2));
70+
}
71+
}
72+
73+
});
74+
});

examples/findJavaPolicies.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
//
88
// This tool does not examine environment-wide or organization-wide resources.
99
//
10-
// last saved: <2017-December-07 17:55:02>
10+
// last saved: <2017-December-07 18:06:43>
1111

12-
var fs = require('fs'),
13-
async = require('async'),
12+
var async = require('async'),
1413
edgejs = require('apigee-edge-js'),
1514
common = edgejs.utility,
1615
apigeeEdge = edgejs.edge,

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "dchiesa@google.com",
1010
"license": "Apache-2.0",
1111
"dependencies": {
12-
"apigee-edge-js": "^0.2.18",
12+
"apigee-edge-js": "^0.2.19",
1313
"async": "^2.2.0",
1414
"mkdirp": "^0.5.1",
1515
"netrc": "0.1.3",

lib/edge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// library of functions for Apigee Edge.
55
//
66
// created: Mon Jun 6 17:32:20 2016
7-
// last saved: <2017-November-08 18:20:22>
7+
// last saved: <2017-December-07 18:22:37>
88

99
(function (){
1010
var path = require('path'),
@@ -1233,7 +1233,7 @@
12331233
mergeRequestOptions(conn, function(requestOptions) {
12341234
requestOptions.url = (options.name) ?
12351235
urljoin(conn.urlBase, 'apiproducts', options.name) :
1236-
urljoin(conn.urlBase, 'apiproducts') ;
1236+
urljoin(conn.urlBase, 'apiproducts') + (options.expand ? '?expand=true' : '');
12371237
if (conn.verbosity>0) {
12381238
utility.logWrite(sprintf('GET %s', requestOptions.url));
12391239
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apigee-edge-js",
3-
"version": "0.2.18",
3+
"version": "0.2.19",
44
"description": "Dino's nodejs library for the administration API for Apigee Edge.",
55
"main" : "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)