From 47477f3380b37f8f2f67417c5078be3c26e66126 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Thu, 24 Mar 2022 10:12:45 +0000 Subject: [PATCH 01/34] Prepare for 0.10.0 release --- ChangeHistory.md | 33 +++++++++++++++++++++++++++++++++ README.md | 32 ++++---------------------------- package.json | 20 ++++++++++---------- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/ChangeHistory.md b/ChangeHistory.md index bd051b11..e011b136 100644 --- a/ChangeHistory.md +++ b/ChangeHistory.md @@ -1,3 +1,36 @@ + +## 0.9.x + +### New in version 0.9.5 +- Assistant V1 & V2 - Allow customerId to be passed inside msg.params +- Assistant V2 - Skip the persist_session_id check if there is no msg.params +- Update list of supported languages in Speech to Text and Text to Speech nodes. + +### New in version 0.9.4 +- Assistant V1 Workspace manager - Allow endpoint to be overridden through msg.params +- Language Translator, Speech to Text, Text to Speech - Sort Languages in drop down select list. + +### New in version 0.9.3 +- Assistant V1 - Fix alternateIntents setting. +- Assistant V2 - Allow return of request session id. +- Update list of supported languages in Speech to Text, Text to Speech and Translation nodes. + +### New in version 0.9.2 +- Assistant V2 - Fix bug session expiry bug. + + +### New in version 0.9.1 +- Assistant V2 - Allow flow to assign a string session id. The node maps this user specified session id to the real session id. Additional param option allow session id to be reset. + +### New in version 0.9.0 +- Node-RED & IBM-Watson & Use of promises on API invocation & IAM URL construct migration & Removal of default endpoint of + - Assistant V1 + - Assistant V2 +- All Nodes now require Node-RED 1.0.x or above +- Remove watson-developer-cloud dependancy +- Remove code for redundant nodes + + ## 0.8.x ### New in version 0.8.2 diff --git a/README.md b/README.md index 8f19ac92..469c975d 100644 --- a/README.md +++ b/README.md @@ -8,34 +8,10 @@ Node-RED Watson Nodes for IBM Cloud CLA assistant -### New in version 0.9.5 -- Assistant V1 & V2 - Allow customerId to be passed inside msg.params -- Assistant V2 - Skip the persist_session_id check if there is no msg.params -- Update list of supported languages in Speech to Text and Text to Speech nodes. +### New in version 0.10.0 +- Bump of dependencies +- Min version of Node is 12.20.0 -### New in version 0.9.4 -- Assistant V1 Workspace manager - Allow endpoint to be overridden through msg.params -- Language Translator, Speech to Text, Text to Speech - Sort Languages in drop down select list. - -### New in version 0.9.3 -- Assistant V1 - Fix alternateIntents setting. -- Assistant V2 - Allow return of request session id. -- Update list of supported languages in Speech to Text, Text to Speech and Translation nodes. - -### New in version 0.9.2 -- Assistant V2 - Fix bug session expiry bug. - - -### New in version 0.9.1 -- Assistant V2 - Allow flow to assign a string session id. The node maps this user specified session id to the real session id. Additional param option allow session id to be reset. - -### New in version 0.9.0 -- Node-RED & IBM-Watson & Use of promises on API invocation & IAM URL construct migration & Removal of default endpoint of - - Assistant V1 - - Assistant V2 -- All Nodes now require Node-RED 1.0.x or above -- Remove watson-developer-cloud dependancy -- Remove code for redundant nodes ### Watson Nodes for Node-RED @@ -79,4 +55,4 @@ before doing so. ### Copyright and license -Copyright 2018, 2019, 2020 IBM Corp. under [the Apache 2.0 license](LICENSE). +Copyright 2018, 2022 IBM Corp. under [the Apache 2.0 license](LICENSE). diff --git a/package.json b/package.json index a8e05272..adef736e 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,20 @@ { "name": "node-red-node-watson", - "version": "0.9.5", + "version": "0.10.0", "description": "A collection of Node-RED nodes for IBM Watson services", "dependencies": { - "async": "^1.5.2", - "cfenv": "~1.2.2", - "file-type": "^12.4.2", - "request": "~2.88.0", - "temp": "^0.9.0", - "qs": "6.x", - "image-type": "^2.0.2", + "async": "^3.2.3", + "cfenv": "~1.2.4", + "file-type": "^16.5.3", + "request": "~2.88.2", + "temp": "^0.9.4", + "qs": "^6.10.3", + "image-type": "^4.1.0", "ibm-watson": "^5.2.1", "word-count": "^0.2.2", "is-docx": "^0.0.3", "stream-to-array": "^2.3.0", - "ws": "^4.1.0" + "ws": "^8.5.0" }, "repository": { "type": "git", @@ -58,6 +58,6 @@ } }, "engines": { - "node": ">=10.0.0" + "node": ">=12.20.0" } } From 180be2a82efa37e4766b7f255ce4ce4f28a97041 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Thu, 24 Mar 2022 10:39:29 +0000 Subject: [PATCH 02/34] Drop Personality Insights node --- README.md | 1 + package.json | 2 - .../icons/personality_insights.png | Bin 4946 -> 0 bytes services/personality_insights/v3.html | 158 ------------ services/personality_insights/v3.js | 230 ------------------ utilities/payload-utils.js | 20 -- 6 files changed, 1 insertion(+), 410 deletions(-) delete mode 100644 services/personality_insights/icons/personality_insights.png delete mode 100644 services/personality_insights/v3.html delete mode 100644 services/personality_insights/v3.js diff --git a/README.md b/README.md index 469c975d..31545283 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Node-RED Watson Nodes for IBM Cloud ### New in version 0.10.0 - Bump of dependencies - Min version of Node is 12.20.0 +- Drop Personality Insights node diff --git a/package.json b/package.json index adef736e..223d0c39 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "qs": "^6.10.3", "image-type": "^4.1.0", "ibm-watson": "^5.2.1", - "word-count": "^0.2.2", "is-docx": "^0.0.3", "stream-to-array": "^2.3.0", "ws": "^8.5.0" @@ -47,7 +46,6 @@ "watson-natural-language-classifier-v1": "services/natural_language_classifier/v1.js", "watson-natural-language-understanding-v1": "services/natural_language_understanding/v1.js", "watson-natural-language-understanding-model-manager-v1": "services/natural_language_understanding/v1-model-manager.js", - "watson-personality-insights-v3": "services/personality_insights/v3.js", "watson-speech-to-text-v1": "services/speech_to_text/v1.js", "watson-speech-to-text-corpus-builder-v1": "services/speech_to_text/v1-corpus-builder.js", "watson-text-to-speech-v1": "services/text_to_speech/v1.js", diff --git a/services/personality_insights/icons/personality_insights.png b/services/personality_insights/icons/personality_insights.png deleted file mode 100644 index 087138847e5b26b6af4acef74ff6b49b654b3e27..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4946 zcmZuzcU)7;)(sG)7o{Ueh!klFRRu}tgaFb+BveB$2_PMjCQW)L6afM0QoNv21f-)N z0qF{a7K-$a6nS{>ed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}VR?-P7a$4oEX z&1m+aLw_7OVzgdWb7~(K*b+YNXVF$aq2pTMbrn0^u8xt^JiA=Qy*b6v-PNhN7Z=M& z;5U-j4-g<55%VUEDA`G2%NQS{MZ*&`fP$2Ub?G*saMHYtk9OPIIdY*`#aPhQ%vLik zDR?E}BTnPtQS4|GglWXf&em3FR~X}Xt@J^>Ba4~NAWo4JS+2|Q8kw1xAZ^RdGBCHk zWFux4pSYD(b+5>_nPa%2~Met_~p4Q;G1tL3|jlCLY0cpJBUPSTKs$7lG zUr3`)MZdprV-0gRW_uc?`Iwy2MKT4b%>I6HBifjFN7PwL%>H z+Ru2+9(?p_)05^MYYu+rN7A}RI*hDB#1_6Q?pqOhV3`@VF`CpR)4aLye5)r!+OU#L zW2V=6+Uz0qtW#_QrOu8`;XLkqZ)0=aJwzUoW&=e~zpXLle34A_+%Af5`La`@9xuTq zXJ<0$NVWED^3mi3*0*Y4&JyLjPh377Ebb1(1utY__E6gzlC}5O4DfF6_3Pc(1lzX_ zyt!b9h`nc^@)UiCM5H%%nZHMfz4eJUIH!0nVxw=x`^l)`V$bkEo_@4!D+z))5uX3^ zMSbnC^kkINhIQCvBpUx(e+_V&q}0UGvXk7rO<16N{n&M1==~EehT`r>((dN0&)OuZ z^^Qc_KGO7+z9OBpw<19|(^BG;yy`4BYtCFa(wO<>+Yd1n#^6CI;eE!^BJ9 rq}$!$fO4$|t{Ou!t9DLdE$6HgjXd^XE8dsCFDgh?ZIw!;N6-ENs@*s3 diff --git a/services/personality_insights/v3.html b/services/personality_insights/v3.html deleted file mode 100644 index c7258aa2..00000000 --- a/services/personality_insights/v3.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - diff --git a/services/personality_insights/v3.js b/services/personality_insights/v3.js deleted file mode 100644 index fafed441..00000000 --- a/services/personality_insights/v3.js +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright 2015 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * 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 - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function (RED) { - const SERVICE_IDENTIFIER = 'personality-insights', - PersonalityInsightsV3 = require('ibm-watson/personality-insights/v3'), - { IamAuthenticator } = require('ibm-watson/auth'); - - var pkg = require('../../package.json'), - payloadutils = require('../../utilities/payload-utils'), - serviceutils = require('../../utilities/service-utils'), - service = serviceutils.getServiceCreds(SERVICE_IDENTIFIER), - username = null, - password = null, - sUsername = null, - sPassword = null, - apikey = null, - sApikey = null, - endpoint = '', - sEndpoint = 'https://gateway.watsonplatform.net/personality-insights/api', - - VALID_INPUT_LANGUAGES = ['ar','en','es','ja', 'ko'], - VALID_RESPONSE_LANGUAGES = ['ar','de','en','es','fr','it','ja','ko','pt-br','zh-cn','zh-tw']; - - if (service) { - sUsername = service.username ? service.username : ''; - sPassword = service.password ? service.password : ''; - sApikey = service.apikey ? service.apikey : ''; - sEndpoint = service.url; - } - - // This HTTP GET REST request is used by the browser side of the node to - // determine if credentials are found. - RED.httpAdmin.get('/watson-personality-insights-v3/vcap', function (req, res) { - res.json(service ? {bound_service: true} : null); - }); - - - function payloadCheck(msg) { - if (!msg.payload) { - return Promise.reject('Missing property: msg.payload'); - } - if ('string' !== typeof msg.payload && - 'object' !== typeof msg.payload) { - return Promise.reject('submitted msg.payload is not text or json object'); - } - return Promise.resolve(); - } - - function wordcountCheck(msg, config) { - var p = new Promise(function resolver(resolve, reject) { - if ('string' === typeof msg.payload) { - var wc = payloadutils.word_count(config.inputlang); - wc(msg.payload, function (length) { - if (length < 100) { - reject('Personality insights requires a minimum of one hundred words.' + - ' Only ' + length + ' submitted'); - } else { - resolve(); - } - }); - } else { - resolve(); - } - }); - return p; - } - - function credentialsCheck(node) { - username = sUsername || node.credentials.username; - password = sPassword || node.credentials.password; - apikey = sApikey || node.credentials.apikey; - - if (!apikey && (!username || !password)) { - return Promise.reject('Missing Personality Insights service credentials'); - } - return Promise.resolve(); - } - - // This function prepares the params object for the - // call to Personality Insights - function prepareParams(msg, config) { - var params = {}, - inputlang = config.inputlang ? config.inputlang : 'en', - outputlang = config.outputlang ? config.outputlang : 'en'; - - if (msg.piparams) { - if (msg.piparams.inputlanguage && - -1 < VALID_INPUT_LANGUAGES.indexOf(msg.piparams.inputlanguage)) { - inputlang = msg.piparams.inputlanguage; - } - if (msg.piparams.responselanguage && - -1 < VALID_RESPONSE_LANGUAGES.indexOf(msg.piparams.responselanguage)) { - outputlang = msg.piparams.responselanguage; - } - } - - params = { - content: msg.payload, - consumptionPreferences: config.consumption ? config.consumption : false, - rawScores: config.rawscores ? config.rawscores : false, - headers: { - 'content-language': inputlang, - 'accept-language': outputlang, - 'accept': 'application/json' - } - }; - - if ('string' === typeof msg.payload) { - params.contentType = 'text/plain'; - } else { - params.contentType = 'application/json'; - } - - return Promise.resolve(params); - } - - function setEndPoint(config) { - endpoint = sEndpoint; - if (config['service-endpoint']) { - endpoint = config['service-endpoint']; - } - return Promise.resolve(); - } - - function executeService(msg, params) { - var p = new Promise(function resolver(resolve, reject) { - let personality_insights = null; - let authSettings = {}; - let serviceSettings = { - version: '2017-10-13', - headers: { - 'User-Agent': pkg.name + '-' + pkg.version - } - }; - - if (apikey) { - authSettings.apikey = apikey; - } else { - authSettings.username = username; - authSettings.password = password; - } - - serviceSettings.authenticator = new IamAuthenticator(authSettings); - - if (endpoint) { - serviceSettings.url = endpoint; - } - - personality_insights = new PersonalityInsightsV3(serviceSettings); - - personality_insights.profile(params) - .then((profile) => { - if (profile && profile.result) { - msg.insights = profile.result; - } else { - msg.insights = profile; - } - resolve(); - }) - .catch((err) => { - reject(err); - }) - - }); - return p; - } - - // This is the start of the Node Code. In this case only on input - // is being processed. - function Node(config) { - RED.nodes.createNode(this,config); - var node = this, - message = ''; - - this.on('input', function(msg, send, done) { - node.status({}); - - payloadCheck(msg) - .then(function(){ - return wordcountCheck(msg, config); - }) - .then(function(){ - return credentialsCheck(node); - }) - .then(function(){ - return setEndPoint(config); - }) - .then(function(){ - return prepareParams(msg, config); - }) - .then(function(params){ - - node.status({fill:'blue', shape:'dot', text:'requesting'}); - return executeService(msg, params); - }) - .then(function(){ - node.status({}); - send(msg); - done(); - }) - .catch(function(err){ - payloadutils.reportError(node, msg, err); - send(msg); - done(err); - }); - }); - } - - RED.nodes.registerType('watson-personality-insights-v3',Node,{ - credentials: { - username: {type:'text'}, - password: {type:'password'}, - apikey: {type:'password'} - } - }); -}; diff --git a/utilities/payload-utils.js b/utilities/payload-utils.js index a49c20f0..322861ff 100644 --- a/utilities/payload-utils.js +++ b/utilities/payload-utils.js @@ -194,26 +194,6 @@ PayloadUtils.prototype = { return code; }, - // Function that is returns a function to count - // the characters in each language. - word_count: function(ct) { - var count = require('word-count'), - fn = function(txt, cb) { - // default - return cb(txt.split(' ').length); - }; - - if (ct === 'ja') { - fn = function(txt, cb) { - cb(200); - }; - } else if (ct === 'ko') { - fn = function(txt, cb) { - cb(count(txt)); - }; - } - return fn; - } }; var payloadutils = new PayloadUtils(); From b93f522c6636478c7bf33991df7842ab123a9064 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Thu, 24 Mar 2022 10:56:33 +0000 Subject: [PATCH 03/34] Drop Visual Recognition Nodes --- README.md | 2 +- package.json | 6 +- .../icons/VR-v3-25x25-old.png | Bin 1164 -> 0 bytes .../visual_recognition/icons/VR-v3-pink.png | Bin 8809 -> 0 bytes services/visual_recognition/icons/visual2.png | Bin 876 -> 0 bytes .../icons/visual_recognition.png | Bin 3720 -> 0 bytes services/visual_recognition/v3.html | 307 ---------- services/visual_recognition/v3.js | 559 ------------------ .../v4-collection-utils.html | 294 --------- .../visual_recognition/v4-collection-utils.js | 507 ---------------- 10 files changed, 2 insertions(+), 1673 deletions(-) delete mode 100644 services/visual_recognition/icons/VR-v3-25x25-old.png delete mode 100644 services/visual_recognition/icons/VR-v3-pink.png delete mode 100644 services/visual_recognition/icons/visual2.png delete mode 100644 services/visual_recognition/icons/visual_recognition.png delete mode 100644 services/visual_recognition/v3.html delete mode 100644 services/visual_recognition/v3.js delete mode 100644 services/visual_recognition/v4-collection-utils.html delete mode 100644 services/visual_recognition/v4-collection-utils.js diff --git a/README.md b/README.md index 31545283..2acaad43 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Node-RED Watson Nodes for IBM Cloud - Bump of dependencies - Min version of Node is 12.20.0 - Drop Personality Insights node - +- Drop Visual Recognition nodes ### Watson Nodes for Node-RED diff --git a/package.json b/package.json index 223d0c39..16679488 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,11 @@ "version": "0.10.0", "description": "A collection of Node-RED nodes for IBM Watson services", "dependencies": { - "async": "^3.2.3", "cfenv": "~1.2.4", "file-type": "^16.5.3", "request": "~2.88.2", "temp": "^0.9.4", "qs": "^6.10.3", - "image-type": "^4.1.0", "ibm-watson": "^5.2.1", "is-docx": "^0.0.3", "stream-to-array": "^2.3.0", @@ -50,9 +48,7 @@ "watson-speech-to-text-corpus-builder-v1": "services/speech_to_text/v1-corpus-builder.js", "watson-text-to-speech-v1": "services/text_to_speech/v1.js", "watson-text-to-speech-corpus-builder-v1": "services/text_to_speech/v1-corpus-builder.js", - "watson-tone-analyzer-v3": "services/tone_analyzer/v3.js", - "watson-visual-recognition-v3": "services/visual_recognition/v3.js", - "watson-visual-recognition-collection-utils-v4": "services/visual_recognition/v4-collection-utils.js" + "watson-tone-analyzer-v3": "services/tone_analyzer/v3.js" } }, "engines": { diff --git a/services/visual_recognition/icons/VR-v3-25x25-old.png b/services/visual_recognition/icons/VR-v3-25x25-old.png deleted file mode 100644 index 82e099e1d8db1246675f03bc350b0719bbbf0abd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1164 zcmV;71atd|P)P000>X1^@s6#OZ}&000D2NklI%M?|7?!-|nGVViS$02C!!hZu1J*rRbDA|uvOQMQ+;7+l1A)#$AVyo7J zE6(xDT^rxVW8c;xxyMLDG&`6>{8MEUs7FzEa&W36j)jQaB;K$S_iib|eVg)$6d-29 z8q8mxhp6IQaPQ^fp&eVXwD%ZZkWVPevT2VrlDW&DBg!I{WD?V7%x#!QZd`b9FKnYD zkS>nllONkre7F&Dl_fr}2+)fC-=O)*sG=CJUh?NC#bGYx1R5Moy)n{*s4G`c}=7Pamz2J$BH;<(d}PL~5^hnukN$N`iY_8_gM99-6`;ELYB z;_nU2Q2se9#wTvWdE*+=h)01S%&sgpaI})AQ4v$FXCQZzM8}roBbGehllclN4mM)Z zhC<9+tpk^y29E3{pKNDFmQ4d?xPA%=7Zr^|v~#RgOmD>R|B8XUw5twZ3O``iaU=3} z)}iXqJ|wIw@Bt8cT)zgHL#LR|i-b|>u0Frf5D>|Hozn)i4fQ}L9;n@n)GumKVQj^R zEe5>4qZ-<(_wjIE1_O97Hyur86C9p#6c5|5ebj}%YgbY9%V|XrYM*1xE@1QN?lvqW zK#Z;#I{)pd+@HM)HLcC?cyHqGsVQ8%brbH}w=hMXPyaQJm4iJBo`}p7DY#;(M>KQ` z3NkT2Yb6%syoTkqjHU-jv4xX{ zOT&2Cc`}q;PQora4=A6NKt3QKpN{>E+_U`=OUsq9&^n<5hcLjZ1X6u|5T3~iRtJ&F zu-6mFEGw&cI?-l&S1`y&ggJ9vV}uMLy(_p22ZFqNZUC)+T$q#W`Te)hE<7_&RFXg^ zqC41|a4mh-R!`;$F9pq$nYF|&CXr;hgFT9P1k=e#^p`lrqzGobx$A$;c%rAWcBe%6 zwPK0mNzzF8tdV@JuyYPe>C%2v{G2|E2j(MQD9Suhai@pT4K( e_!$-{tbYKrfzYZhW68Jx0000b diff --git a/services/visual_recognition/icons/VR-v3-pink.png b/services/visual_recognition/icons/VR-v3-pink.png deleted file mode 100644 index a9f654d41794bd7154a2bf170d46f640eee32f7b..0000000000000000000000000000000000000000 GIT binary patch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P%W%of46Hm9})IGo87<@7#OGosy=dC;8p`yXWzJ=bYbT#@Tpp)Zf;SKw}c{ z5r`AM|K$~7BpCdo0`&c?!ri|pi9_8Uz88H|eIJScVFg8pTN;x&9&!zF-+i$J!=e zB^)60MPj7&P04U{kl;PD8)9&tp0YD(3tFIxD?WB-9jwk-uJBw3n-|L?6lF{aNP@Xl zp{(c8xRhg%ed}#^ak?dm58QoAV%|Skg+Lz^d_4W6D4;~rz9G&-@aRkgDVR&p7PX;; zPR|(JyVS+Wo-BTntng?YSHD%Uf(!AMtsNmrs}kY7w|@eIBUOyB>dPM{ks^7SYZXZy zi8e-#V}JygSi$iPSH^LXPHTUrYQB`duy1>?z9u{zut-HG}gFUMW`B~K=s4A(UhjI1oqB5MSMtUp74YgB|vQoEk%j@O2>sOVY3Gm`IGBYobh*v>v+R4ZK$JOzL3F6d7YDbafjp zZSFV~oeL9qvOR0eR=|{?*?uZlZHUfh7XxgcTVh!{eCy*^>}*k|@z>hAwpGa*we8;; zRL`PHbQYuY=(^kqwU4=AsORH8;2()GUU0(&_Kft}5Ocw!N`#~2h41w6&)r)7dvIup mj8l@C^=E{`UwQQNx8@fT;$lVphS3TD0000 - - - - - - - - - - - - - - diff --git a/services/visual_recognition/v3.js b/services/visual_recognition/v3.js deleted file mode 100644 index 3f702e28..00000000 --- a/services/visual_recognition/v3.js +++ /dev/null @@ -1,559 +0,0 @@ -/** - * Copyright 2013,2015, 2016 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * 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 - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - const SERVICE_IDENTIFIER = 'visual-recognition', - VisualRecognitionV3 = require('ibm-watson/visual-recognition/v3'), - { IamAuthenticator } = require('ibm-watson/auth'), - METHODS = { - CREATECLASSIFER : 'createClassifier', - LISTCLASSIFIERS : 'listClassifiers', - UPDATECLASSIFIER : 'updateClassifier', - GETCLASSIFIER : 'getClassifier', - DELETECLASSIFIER : 'deleteClassifier', - retrieveClassifiersList : 'listClassifiers', - retrieveClassifierDetails : 'getClassifier', - deleteClassifier : 'deleteClassifier' - }; - - var pkg = require('../../package.json'), - serviceutils = require('../../utilities/service-utils'), - payloadutils = require('../../utilities/payload-utils'), - //watson = require('watson-developer-cloud'), - imageType = require('image-type'), - url = require('url'), - temp = require('temp'), - fileType = require('file-type'), - fs = require('fs'), - async = require('async'), - sAPIKey = null, - apikey = '', - service = null, - endpoint = '', - sEndpoint = ''; - - // temp is being used for file streaming to allow the file to arrive so it can be processed. - temp.track(); - - service = serviceutils.getServiceCreds(SERVICE_IDENTIFIER); - - if (service) { - sAPIKey = service.api_key || service.apikey; - sEndpoint = service.url; - } - - RED.httpAdmin.get('/watson-visual-recognition/vcap', function(req, res) { - res.json(service ? { - bound_service: true - } : null); - }); - - function imageCheck(data) { - return data instanceof Buffer && imageType(data) !== null; - } - - function urlCheck(str) { - var parsed = url.parse(str); - return (!!parsed.hostname && !!parsed.protocol && str.indexOf(' ') < 0); - } - - function stream_buffer(file, contents, cb) { - fs.writeFile(file, contents, function(err) { - if (err) { - throw err; - } - cb(); - }); - } - - function verifyPayload(msg) { - if (!msg.payload) { - return Promise.reject('Missing property: msg.payload'); - } else { - return Promise.resolve(); - } - } - - - function verifyFeatureMode(node, msg, config) { - const theOptions = { - 'classify' : 'classifyImage' - }; - - var f = config['image-feature']; - - if (msg.params && msg.params.detect_mode) { - if (msg.params.detect_mode in theOptions) { - f = theOptions[msg.params.detect_mode]; - } else { - node.error('Invalid parameter setting for detect_mode, using configuration value'); - } - } - if (!f) { - node.error('No configuration value for detect mode found, defaulting to classify'); - f = theOptions['classify']; - } - return Promise.resolve(f); - } - - function verifyInputs(feature, msg) { - switch (feature) { - case 'classifyImage': - if (typeof msg.payload === 'boolean' || - typeof msg.payload === 'number') { - return Promise.reject('Bad format : msg.payload must be a URL string or a Node.js Buffer'); - } - break; - } - return Promise.resolve(); - } - - - function verifyServiceCredentials(node, msg) { - // If it is present the newly provided user entered key - // takes precedence over the existing one. - apikey = sAPIKey || node.credentials.apikey; - if (!apikey) { - return Promise.reject('Missing Watson Visual Recognition API service credentials'); - } - - let authSettings = {}; - - var serviceSettings = { - version: '2018-03-19', - headers: { - 'User-Agent': pkg.name + '-' + pkg.version - } - }; - - if (endpoint) { - serviceSettings.url = endpoint; - } - - // VR instances created post 22 May 2018, are expecting an iam API Key - //if (iamAPIKey) { - // serviceSettings.iam_apikey = apikey; - //} else { - authSettings.apikey = apikey; - //} - serviceSettings.authenticator = new IamAuthenticator(authSettings); - - // The change to watson-developer-cloud 3.0.x has resulted in a - // change in how the Accept-Language is specified. It now needs - // to go in as a header. - - if (node.config != null && node.config.lang != null) { - serviceSettings.headers['Accept-Language'] = node.config.lang; - } - if (msg.params != null && msg.params.accept_language != null) { - serviceSettings.headers['Accept-Language'] = msg.params['accept_language']; - } - - node.service = new VisualRecognitionV3(serviceSettings); - - return Promise.resolve(); - } - - - function processTheResponse(body, feature, node, msg) { - if (body == null) { - return Promise.reject('call to watson visual recognition v3 service failed'); - } else if (body.images != null && body.images[0].error) { - return Promise.reject(body.images[0].error); - } else { - if (feature === 'deleteClassifier') { - msg.result = 'Successfully deleted classifier_id: ' + msg.params.classifier_id; - } else { - msg.result = body; - } - return Promise.resolve(); - } - } - - function setCommonParams(node, msg, params) { - if (msg.params != null && msg.params.classifier_ids != null) { - params['classifierIds'] = msg.params['classifier_ids']; - } - if (msg.params != null && msg.params.owners != null) { - params['owners'] = msg.params['owners']; - } - if (msg.params != null && msg.params.threshold != null) { - params['threshold'] = msg.params['threshold']; - } - if (node.config != null && node.config.lang != null) { - params['acceptLanguage'] = node.config.lang; - } - if (msg.params != null && msg.params.accept_language != null) { - params['acceptLanguage'] = msg.params['accept_language']; - } - } - - function prepareCommonParams(params, node, msg) { - var p = new Promise(function resolver(resolve, reject) { - if (imageCheck(msg.payload)) { - var ft = fileType(msg.payload); - var ext = ft ? ft.ext : 'tmp'; - temp.open({ - suffix: '.' + ext - }, function(err, info) { - if (err) { - reject('Node has been unable to open the image stream'); - } - stream_buffer(info.path, msg.payload, function() { - params['imagesFile'] = fs.createReadStream(info.path); - setCommonParams(node, msg, params); - resolve(); - }); - }); - } else if (urlCheck(msg.payload)) { - params['url'] = msg.payload; - setCommonParams(node, msg, params); - resolve(); - } else { - reject('Payload must be either an image buffer or a string representing a url'); - } - }); - return p; - } - - - // This is where the two read stream tasks are built, individually - // asynTasks will be the two functions that will be invoked added - // one at a time, each time this function is invoked - // msg holds the parameters - // k is the key value for the files in msg. - // listParams is where the files will go so that they - // can be sent to the service. - // callback is the callback that async forces so that it can - // control the async functions that it is invoking. - function addTask(asyncTasks, msg, k, listParams, node) { - asyncTasks.push(function(callback) { - var buffer = msg.params[k]; - temp.open({ - suffix: '.' + fileType(buffer).ext - }, function(err, info) { - if (err) { - node.status({ - fill: 'red', - shape: 'ring', - text: 'unable to open image stream' - }); - node.error('Node has been unable to open the image stream', msg); - return callback('open error on ' + k); - } - stream_buffer(info.path, msg.params[k], function() { - let example_name = k.replace('_examples',''); - - if (k.includes('negative')) { - listParams['negativeExamples'] = fs.createReadStream(info.path); - } else { - if (! listParams['positiveExamples']) { - listParams['positiveExamples'] = {}; - } - listParams['positiveExamples'][example_name] = fs.createReadStream(info.path); - } - - callback(null, example_name); - }); - }); - }); - } - - // This function is expecting - // msg.params["name"] : a string name that will be used as prefix - // for the returned classifier_id (Required) - // msg.params["{classname}_examples"] : a Node.js binary - // Buffer of the ZIP that contains a minimum of 10 images. (Required) - // msg.params["negative_examples"] : a Node.js binary Buffer of the ZIP - // that contains a minimum of 10 images.(Optional) - - function prepareParamsClassifierFiles(params, node, msg) { - var p = new Promise(function resolver(resolve, reject) { - var listParams = {}, - asyncTasks = [], - k = null; - for (k in msg.params) { - if (k.indexOf('_examples') >= 0) { - addTask(asyncTasks, msg, k, listParams, node); - } else if (k === 'name') { - listParams[k] = msg.params[k]; - } - } - - // function is invoked when both asyncTasks have completed. - async.parallel(asyncTasks, function(error) { - if (error) { - reject(error); - //throw error; - } - for (var p in listParams) { - if (p != null) { - params[p] = listParams[p]; - } - } - resolve(); - }); - }); - return p; - } - - function performDeleteAllClassifiers(params, node, msg) { - var p = new Promise(function resolver(resolve, reject) { - node.service.listClassifiers(params, function(err, body) { - node.status({}); - if (err) { - reject(err); - } else { - // Array to hold async tasks - var asyncTasks = [], - nbTodelete = 0, - nbdeleted = 0; - nbTodelete = body.classifiers.length; - body.classifiers.forEach(function(aClassifier) { - asyncTasks.push(function(cb) { - var parms = {}; - - parms.classifierId = aClassifier.classifierId; - node.service.deleteClassifier(parms, function(err) { - if (err) { - node.error(err, msg); - return cb('error'); - } - nbdeleted++; - cb(null, parms.classifierId); - }); - }); - }); - async.parallel(asyncTasks, function(error, deletedList) { - if (deletedList.length === nbTodelete) { - msg.result = 'All custom classifiers have been deleted.'; - } else { - msg.result = 'Some Classifiers could have not been deleted;' + - 'See log for errors.'; - } - resolve(); - }); - } - }); - }); - return p; - } - - function invokeService(feature, params, node, msg) { - var p = new Promise(function resolver(resolve, reject) { - switch (feature) { - case 'classifyImage': - node.service.classify(params) - .then((data) => { - let result = data - if (data && data.result) { - result = data.result; - } - resolve(result); - }) - .catch((err) => { - reject(err); - }); - break; - } - }); - return p; - } - - function executeService(feature, params, node, msg) { - var p = prepareCommonParams(params, node, msg) - .then(function() { - return invokeService(feature, params, node, msg); - }) - .then(function(body) { - return processTheResponse(body, feature, node, msg); - }); - return p; - } - - function invokeClassifierMethod(node, params, method) { - var p = new Promise(function resolver(resolve, reject) { - node.service[method](params) - .then((data) => { - let result = data - if (data && data.result) { - result = data.result; - } - resolve(result); - }) - .catch((err) => { - reject(err); - }) - }); - return p; - } - - function executeCreateClassifier(params, node, msg) { - var p = prepareParamsClassifierFiles(params, node, msg) - .then(function() { - return invokeClassifierMethod(node, params, METHODS.CREATECLASSIFER); - }); - - return p; - } - - function executeUpdateClassifier(params, node, msg) { - // This is not an error, the params for create & update - // are essentially the same. - var p = prepareParamsClassifierFiles(params, node, msg) - .then(function() { - return invokeClassifierMethod(node, params, METHODS.UPDATECLASSIFIER); - }); - - return p; - } - - function executeUtilService(feature, params, node, msg) { - var p = null; - switch (feature) { - case 'createClassifier': - p = executeCreateClassifier(params, node, msg) - .then(function(body) { - return processTheResponse(body, feature, node, msg); - }); - break; - - case 'updateClassifier': - p = executeUpdateClassifier(params, node, msg) - .then(function(body) { - return processTheResponse(body, feature, node, msg); - }); - break; - - case 'retrieveClassifiersList': - case 'retrieveClassifierDetails': - case 'deleteClassifier': - p = invokeClassifierMethod(node, params, METHODS[feature]) - .then(function(body) { - return processTheResponse(body, feature, node, msg); - }); - break; - - case 'deleteAllClassifiers': - p = performDeleteAllClassifiers(params, node, msg); - break; - - default: - p = Promise.reject('Mode ' + feature + ' not understood'); - } - return p; - } - - function execute(feature, params, node, msg) { - node.status({ - fill: 'blue', - shape: 'dot', - text: 'Calling ' + feature + ' ...' - }); - - if (feature === 'classifyImage') { - return executeService(feature, params, node, msg); - //return Promise.resolve(); - } else { - if (msg.params && msg.params['classifier_id']) { - params['classifierId'] = msg.params['classifier_id']; - } - return executeUtilService(feature, params, node, msg); - // return Promise.resolve(); - } - } - - function determineEndpoint(config) { - endpoint = sEndpoint; - if (!endpoint && config['vr-service-endpoint']) { - endpoint = config['vr-service-endpoint']; - } - return Promise.resolve(); - } - - // This is the Watson Visual Recognition V3 Node - function WatsonVisualRecognitionV3Node(config) { - var node = this, - b = false, - feature = ''; - - RED.nodes.createNode(this, config); - node.config = config; - - node.on('input', function(msg, send, done) { - var params = {}; - - node.status({}); - - verifyPayload(msg) - .then(function() { - return verifyFeatureMode(node, msg, config); - }) - .then(function(f) { - feature = f; - return payloadutils.checkForStream(msg); - }) - .then(function() { - return verifyInputs(feature, msg); - }) - .then(function() { - return determineEndpoint(config); - }) - .then(function() { - return verifyServiceCredentials(node, msg); - }) - .then(function() { - return execute(feature, params, node, msg); - }) - .then(function() { - temp.cleanup(); - node.status({}); - send(msg); - done(); - }) - .catch(function(err) { - payloadutils.reportError(node, msg, err); - - msg.result = {}; - msg.result['error'] = err; - // Note: This node.send forwards the error to the next node, - // if this isn't desired then this line needs to be removed. - // Should be ok as the node.error would already have recorded - // the error in the debug console. - temp.cleanup(); - send(msg); - done(err); - }); - }); - } - - RED.nodes.registerType('visual-recognition-v3', WatsonVisualRecognitionV3Node, { - credentials: { - apikey: { - type: 'password' - } - } - }); - - RED.nodes.registerType('visual-recognition-util-v3', WatsonVisualRecognitionV3Node, { - credentials: { - apikey: { - type: 'password' - } - } - }); - -}; diff --git a/services/visual_recognition/v4-collection-utils.html b/services/visual_recognition/v4-collection-utils.html deleted file mode 100644 index b366c1d1..00000000 --- a/services/visual_recognition/v4-collection-utils.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - - diff --git a/services/visual_recognition/v4-collection-utils.js b/services/visual_recognition/v4-collection-utils.js deleted file mode 100644 index 13237f70..00000000 --- a/services/visual_recognition/v4-collection-utils.js +++ /dev/null @@ -1,507 +0,0 @@ -/** - * Copyright 2020 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * 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 - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - const SERVICE_IDENTIFIER = 'visual-recognition', - VisualRecognitionV4 = require('ibm-watson/visual-recognition/v4'), - { IamAuthenticator } = require('ibm-watson/auth'), - FEATURE = 'image-feature', - REQUIRED_PARAMS = { - 'analyze': ['collectionIds'], - 'createCollection': ['name', 'description'], - 'getCollection': ['collectionId'], - 'updateCollection': ['collectionId'], - 'deleteCollection': ['collectionId'], - 'addImages': ['collectionId'], - 'listImages': ['collectionId'], - 'getImageDetails': ['collectionId', 'imageId'], - 'deleteImage': ['collectionId', 'imageId'], - 'getJpegImage': ['collectionId', 'imageId'], - 'train': ['collectionId'], - 'addImageTrainingData' : ['collectionId', 'imageId', 'objects'] - }; - - var pkg = require('../../package.json'), - serviceutils = require('../../utilities/service-utils'), - payloadutils = require('../../utilities/payload-utils'), - temp = require('temp'), - fileType = require('file-type'), - fs = require('fs'), - fsp = require('fs').promises, - sAPIKey = null, - apikey = '', - service = null, - endpoint = '', - sEndpoint = ''; - - // temp is being used for file streaming to allow the file to arrive so it can be processed. - temp.track(); - - service = serviceutils.getServiceCreds(SERVICE_IDENTIFIER); - - if (service) { - sAPIKey = service.api_key || service.apikey; - sEndpoint = service.url; - } - - RED.httpAdmin.get('/watson-visual-recognition-v4/vcap', function(req, res) { - res.json(service ? { - bound_service: true - } : null); - }); - - function invokeCollectionMethod(node, msg) { - return new Promise(function resolver(resolve, reject) { - let service = node.service; - let method = node.config[FEATURE]; - let params = msg.params; - - service[method](params) - .then((data) => { - let result = data - if (data && data.result) { - result = data.result; - } - resolve(result); - }) - .catch((err) => { - reject(err); - }) - }); - } - - function responseForDeleteMode(node, msg) { - let feature = node.config[FEATURE]; - let field = null; - - switch (feature) { - case 'deleteCollection': - msg.payload = 'Successfully deleted collection id: ' + msg.params.collectionId; - break; - case 'deleteImage': - msg.payload = 'Successfully deleted image id: ' - + msg.params.imageId - + ' from collection ' - + msg.params.collectionId; - break - default: - return false; - } - return true; - } - - function processTheResponse (body, node, msg) { - return new Promise(function resolver(resolve, reject) { - if (body == null) { - return reject('call to watson visual recognition v4 service failed'); - } else if (! responseForDeleteMode(node, msg)) { - msg.payload = body; - payloadutils.checkForStream(msg) - .then(() => { - resolve(); - }) - .catch((err) => { - reject(err); - }) - } - }); - } - - function extractIDs(body) { - let ids = []; - - if (body && body instanceof Object) { - if (body.collections && body.collections instanceof Array) { - body.collections.forEach((c) => { - if (c instanceof Object && c['collection_id']) { - ids.push(c['collection_id']); - } - }); - } - if (ids.length > 0) { - return Promise.resolve(ids); - } - } - - return Promise.reject('No Collection IDs found'); - } - - function performDeleteCollection(node, msg, IDs) { - return new Promise(function resolver(resolve, reject) { - let promises = []; - - IDs.forEach((id) => { - let msgClone = JSON.parse(JSON.stringify(msg)); - node.config[FEATURE] = 'deleteCollection'; - msgClone.params = { - 'collectionId' : id - } - promises.push(invokeCollectionMethod(node, msgClone)); - }); - - Promise.all(promises).then(() => { - resolve(); - }) - }); - } - - function performDeleteAllCollections(node, msg) { - return new Promise(function resolver(resolve, reject) { - let ids = null; - node.config[FEATURE] = 'listCollections'; - invokeCollectionMethod(node, msg) - .then((body) => { - return extractIDs(body); - }) - .then((IDs) => { - ids = IDs - return performDeleteCollection(node, msg, IDs); - }) - .then(() => { - node.config[FEATURE] = 'deleteAllCollections'; - resolve('Successfully deleted collections : '+ ids.join(' and ')); - }) - .catch((err) => { - reject(err); - }); - }); - } - - function execute(node, msg) { - return new Promise(function resolver(resolve, reject) { - node.status({ - fill: 'blue', - shape: 'dot', - text: 'Invoking ' + node.config[FEATURE] + ' ...' - }); - - let executeOperation = invokeCollectionMethod; - if ('deleteAllCollections' === node.config[FEATURE]) { - executeOperation = performDeleteAllCollections; - } - - executeOperation(node, msg) - .then((data)=> { - return processTheResponse(data, node, msg); - }) - .then(() => { - resolve(); - }) - .catch((err) => { - reject(err); - }); - }); - } - - - function verifyServiceCredentials(node, msg) { - // If it is present the newly provided user entered key - // takes precedence over the existing one. - apikey = sAPIKey || node.credentials.apikey; - if (!apikey) { - return Promise.reject('Missing Watson Visual Recognition API service credentials'); - } - - let authSettings = {}; - - var serviceSettings = { - version: '2019-02-11', - headers: { - 'User-Agent': pkg.name + '-' + pkg.version - } - }; - - if (endpoint) { - serviceSettings.url = endpoint; - } - - authSettings.apikey = apikey; - serviceSettings.authenticator = new IamAuthenticator(authSettings); - - node.service = new VisualRecognitionV4(serviceSettings); - - return Promise.resolve(); - } - - - function determineEndpoint(config) { - endpoint = sEndpoint; - if (!endpoint && config['vr-service-endpoint']) { - endpoint = config['vr-service-endpoint']; - } - if (!endpoint) { - return Promise.reject('No endpoint URL has been provided'); - } - return Promise.resolve(); - } - - function paramCheckFor(requiredFields, msg){ - let theMissing = []; - - if (!msg || !msg.params) { - theMissing = requiredFields; - } else { - requiredFields.forEach((r) => { - if (! msg.params[r]) { - theMissing.push(r); - } - }) - } - - return theMissing; - } - - function verifyParams(node, msg) { - let params = {}; - let theMissing = []; - let feature = node.config[FEATURE]; - - switch (feature) { - - case 'analyze': - case 'createCollection': - case 'getCollection': - case 'updateCollection': - case 'deleteCollection': - case 'addImages': - case 'listImages': - case 'getImageDetails': - case 'deleteImage': - case 'getJpegImage': - case 'train': - case 'addImageTrainingData': - theMissing = paramCheckFor(REQUIRED_PARAMS[feature], msg); - if (theMissing.length === 0) { - return Promise.resolve(); - } else { - return Promise.reject('Missing parameter(s) : ' + theMissing.join(' and ')); - } - - case 'listCollections': - case 'deleteAllCollections': - case 'getTrainingUsage': - if (! msg.params) { - msg.params = {}; - } - return Promise.resolve(); - - default: - return Promise.reject('Unknown Mode'); - } - } - - function augmentParams(node, msg) { - if ('analyze' === node.config[FEATURE]) { - msg.params.features = ['objects']; - } - return Promise.resolve(); - } - - function bufferCheck(data) { - return data instanceof Buffer; - } - - function zipCheck(msg) { - return new Promise(function resolver(resolve, reject) { - if (!bufferCheck(msg.payload)) { - reject('msg.payload is neither an array or urls or a zip'); - } else { - let ft = fileType(msg.payload); - if (!ft || !ft.ext || 'zip' != ft.ext) { - reject('msg.payload is not a zip'); - } else { - resolve(); - } - } - }); - } - - function setImagesFileParam(msg) { - return new Promise(function resolver(resolve, reject) { - temp.open({ - suffix: '.' + 'zip' - }, function(err, info) { - if (err) { - reject('Node has been unable to open the zip stream'); - } - fsp.writeFile(info.path, msg.payload) - .then(() => { - msg.params['imagesFile'] = fs.createReadStream(info.path); - resolve(); - }) - .catch((err) => { - reject(err); - }) - }); - }); - } - - function imagesExpected(feature) { - switch(feature) { - case 'addImages': - case 'analyze': - return true; - default: - return false; - } - } - - function processPayload(node, msg) { - return new Promise(function resolver(resolve, reject) { - if (!imagesExpected(node.config[FEATURE])) { - resolve(); - } else if (Array.isArray(msg.payload)) { - // Payload can be either an array of urls for images - msg.params['imageUrl'] = msg.payload; - resolve(); - } else { - // or a zip of images - payloadutils.checkForStream(msg) - .then(() => { - return zipCheck(msg); - }) - .then(() => { - return setImagesFileParam(msg); - }) - .then(() => { - resolve(); - }) - .catch((err) => { - reject(err); - }); - } - }); - } - - function verifyPayload(node, msg) { - switch (node.config[FEATURE]) { - case 'createCollection': - case 'listCollections': - case 'getCollection': - case 'updateCollection': - case 'deleteCollection': - case 'deleteAllCollections': - case 'listImages': - case 'getImageDetails': - case 'deleteImage': - case 'getJpegImage': - case 'train': - case 'addImageTrainingData': - case 'getTrainingUsage': - return Promise.resolve(); - case 'addImages': - case 'analyze': - if (!msg.payload) { - return Promise.reject('Missing property: msg.payload'); - } - return Promise.resolve(); - default: - return Promise.reject('Unknown mode has been specified'); - } - } - - function verifyFeatureMode(node, msg) { - let f = node.config[FEATURE]; - if (!f) { - let errMsg = 'No configuration value for mode found'; - node.error(errMsg); - return Promise.reject(errMsg); - } - return Promise.resolve(); - } - - - // This is the processing of the On input event - function processOnInput(node, msg) { - return new Promise(function resolver(resolve, reject) { - // Verify that a mode has been set - verifyFeatureMode(node, msg) - .then(() => { - // Using the mode verify that the payload conforms - return verifyPayload(node, msg); - }) - .then(() => { - return verifyParams(node, msg); - }) - .then(() => { - return augmentParams(node, msg); - }) - .then(() => { - return processPayload(node, msg); - }) - .then(() => { - return determineEndpoint(node.config); - }) - .then(() => { - return verifyServiceCredentials(node, msg); - }) - .then(() => { - return execute(node, msg); - }) - .then(() => { - resolve(); - }) - .catch((err) => { - reject(err); - }); - }); - } - - // This is the Watson Visual Recognition V4 Node - function WatsonVisualRecognitionV4Node(config) { - let node = this; - - RED.nodes.createNode(this, config); - node.config = config; - - node.on('input', function(msg, send, done) { - var params = {}; - - node.status({}); - - processOnInput(node, msg) - .then(() => { - temp.cleanup(); - node.status({}); - send(msg); - done(); - }) - .catch((err) => { - payloadutils.reportError(node, msg, err); - - msg.payload = {}; - msg.payload['error'] = err; - // Note: This node.send forwards the error to the next node, - // if this isn't desired then this line needs to be removed. - // Should be ok as the node.error would already have recorded - // the error in the debug console. - temp.cleanup(); - send(msg); - done(err); - }); - }); - } - - - RED.nodes.registerType('visual-recognition-util-v4', WatsonVisualRecognitionV4Node, { - credentials: { - apikey: { - type: 'password' - } - } - }); - -}; From 4da9e9db041a7c44d208c0bddb7ff6d792f069e4 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Thu, 24 Mar 2022 11:31:21 +0000 Subject: [PATCH 04/34] Remove username/password fields --- README.md | 2 ++ services/assistant/v1-workspace-manager.html | 18 +--------- services/assistant/v1-workspace-manager.js | 35 ++++++-------------- services/assistant/v1.html | 14 +------- services/assistant/v1.js | 33 +++++------------- 5 files changed, 22 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 2acaad43..abb00a1f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Node-RED Watson Nodes for IBM Cloud - Min version of Node is 12.20.0 - Drop Personality Insights node - Drop Visual Recognition nodes +- Remove Username / Password fields from + - Watson Assistant V1 node ### Watson Nodes for Node-RED diff --git a/services/assistant/v1-workspace-manager.html b/services/assistant/v1-workspace-manager.html index 55b0a2a4..f9a4c399 100644 --- a/services/assistant/v1-workspace-manager.html +++ b/services/assistant/v1-workspace-manager.html @@ -1,5 +1,5 @@ + + + + + + diff --git a/services/discovery/v2-project-manager.js b/services/discovery/v2-project-manager.js new file mode 100644 index 00000000..89bd6e59 --- /dev/null +++ b/services/discovery/v2-project-manager.js @@ -0,0 +1,92 @@ +/** + * Copyright 2022 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * 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 + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function (RED) { + + const SERVICE_IDENTIFIER = 'discovery'; + var discoveryutils = require('./discovery-utils'), + serviceutils = require('../../utilities/service-utils'), + payloadutils = require('../../utilities/payload-utils'), + dservice = serviceutils.getServiceCreds(SERVICE_IDENTIFIER), + apikey = null, + sApikey = null, + endpoint = '', + sEndpoint = ''; + + + function initialCheck(k, m) { + var message = ''; + if (!k) { + message = 'Missing Watson Discovery service credentials'; + } else if (!m || '' === m) { + message = 'Required Discovery method has not been specified'; + } + if (message){ + return Promise.reject(message); + } + return Promise.resolve(); + } + + if (dservice) { + sApikey = dservice.apikey ? dservice.apikey : ''; + sEndpoint = dservice.url ? dservice.url : ''; + } + + RED.httpAdmin.get('/watson-discovery-v2-pm/vcap', function (req, res) { + res.json(serviceutils.checkServiceBound(SERVICE_IDENTIFIER)); + }); + + + function Node (config) { + var node = this; + RED.nodes.createNode(this, config); + + this.on('input', function(msg, send, done) { + + var method = config['discovery-method'], + message = '', + params = {}; + + apikey = sApikey || node.credentials.apikey; + + endpoint = sEndpoint; + if (config['service-endpoint']) { + endpoint = config['service-endpoint']; + } + + node.status({}); + initialCheck(apikey, method) + .then(() => { + return Promise.reject("not yet implemented"); + }) + .then(function(){ + node.status({}); + send(msg); + done(); + }) + .catch(function(err){ + let errMsg = payloadutils.reportError(node, msg, err); + done(errMsg); + }); + }); + } + + RED.nodes.registerType('watson-discovery-v2-project-manager', Node, { + credentials: { + apikey: {type:'password'} + } + }); +}; From a861d50f38a74d9393b4085c26465776ab904b39 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Fri, 25 Mar 2022 10:29:45 +0000 Subject: [PATCH 13/34] Implement List Envrionments method --- services/discovery/discovery-utils2.js | 59 +++++++++++++++++++ services/discovery/v2-project-manager.html | 10 +++- services/discovery/v2-project-manager.js | 67 +++++++++++++++++++++- 3 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 services/discovery/discovery-utils2.js diff --git a/services/discovery/discovery-utils2.js b/services/discovery/discovery-utils2.js new file mode 100644 index 00000000..c1a715c2 --- /dev/null +++ b/services/discovery/discovery-utils2.js @@ -0,0 +1,59 @@ +/** + * Copyright 2022 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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 + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ +const pkg = require('../../package.json'), + DiscoveryV2 = require('ibm-watson/discovery/v2'), + { IamAuthenticator } = require('ibm-watson/auth'); + + +function DiscoveryUtils2() {} +DiscoveryUtils2.prototype = { + + buildService: function(apikey, endpoint) { + let authSettings = {}; + let serviceSettings = { + version: '2020-08-30', + headers: { + 'User-Agent': pkg.name + '-' + pkg.version + } + }; + + if (apikey) { + authSettings.apikey = apikey; + } + serviceSettings.authenticator = new IamAuthenticator(authSettings); + + if (endpoint) { + serviceSettings.url = endpoint; + serviceSettings.serviceUrl = endpoint; + } + + return new DiscoveryV2(serviceSettings); + }, + + + buildParams: function(msg, config) { + var params = {}, + me = this; + + return params; + } + + +}; + +var discoveryutils2 = new DiscoveryUtils2(); + +module.exports = discoveryutils2; diff --git a/services/discovery/v2-project-manager.html b/services/discovery/v2-project-manager.html index 1f9b75e0..175a7d8e 100644 --- a/services/discovery/v2-project-manager.html +++ b/services/discovery/v2-project-manager.html @@ -37,6 +37,11 @@
@@ -49,6 +54,9 @@
  • +

    List Existing Projects

    +

    For this method the node does not need any input. +

@@ -115,7 +123,7 @@ category: 'IBM Watson', defaults: { name: {value: ''}, - 'discovery-method': {value:''}, + 'discovery-method': {value:'listProjects'}, 'service-endpoint' :{value: ''} }, credentials: { diff --git a/services/discovery/v2-project-manager.js b/services/discovery/v2-project-manager.js index 89bd6e59..7b43d9d9 100644 --- a/services/discovery/v2-project-manager.js +++ b/services/discovery/v2-project-manager.js @@ -17,15 +17,46 @@ module.exports = function (RED) { const SERVICE_IDENTIFIER = 'discovery'; - var discoveryutils = require('./discovery-utils'), + var discoveryutils = require('./discovery-utils2'), serviceutils = require('../../utilities/service-utils'), payloadutils = require('../../utilities/payload-utils'), + responseutils = require('../../utilities/response-utils'), dservice = serviceutils.getServiceCreds(SERVICE_IDENTIFIER), apikey = null, sApikey = null, endpoint = '', sEndpoint = ''; + const ExecutionList = { + 'listProjects' : executeProjectList + }; + + function executeProjectList(node, discovery, params, msg) { + let fields = { + node : node, + discovery : discovery, + params : params, + msg : msg, + method : "listProjects", + response : "projects" + } + return executeListMethod(fields) + } + + function executeListMethod(fields) { + var p = new Promise(function resolver(resolve, reject){ + fields.discovery[fields.method](fields.params) + .then((response) => { + responseutils.parseResponseFor(fields.msg, response, fields.response); + resolve(); + }) + .catch((err) => { + reject(err); + }); + }); + return p; + } + function initialCheck(k, m) { var message = ''; @@ -40,6 +71,33 @@ module.exports = function (RED) { return Promise.resolve(); } + function checkParams(method, params) { + var response = ''; + + if (response) { + return Promise.reject(response); + } else { + return Promise.resolve(); + } + } + + // function unknownMethod(node, discovery, params, msg) { + // return Promise.reject('Unable to process as unknown mode has been specified'); + // } + + function executeMethod(node, method, params, msg) { + let discovery = discoveryutils.buildService(apikey, endpoint); + + let exe = ExecutionList[method]; + if (!exe) { + exe = unknownMethod + } + + return exe(node, discovery, params, msg); + } + + + if (dservice) { sApikey = dservice.apikey ? dservice.apikey : ''; sEndpoint = dservice.url ? dservice.url : ''; @@ -70,7 +128,12 @@ module.exports = function (RED) { node.status({}); initialCheck(apikey, method) .then(() => { - return Promise.reject("not yet implemented"); + params = discoveryutils.buildParams(msg,config); + return checkParams(method, params); + }) + .then(function(){ + node.status({fill:'blue', shape:'dot', text:'requesting'}); + return executeMethod(node, method, params, msg); }) .then(function(){ node.status({}); From 2603f2b47c3d89262b9fea9620c16d1324f9960f Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Fri, 25 Mar 2022 11:29:41 +0000 Subject: [PATCH 14/34] Add GetProject method --- services/discovery/discovery-utils2.js | 22 ++++++++++ services/discovery/v2-project-manager.html | 36 +++++++++++++++- services/discovery/v2-project-manager.js | 48 +++++++++++++++++----- 3 files changed, 93 insertions(+), 13 deletions(-) diff --git a/services/discovery/discovery-utils2.js b/services/discovery/discovery-utils2.js index c1a715c2..895d5120 100644 --- a/services/discovery/discovery-utils2.js +++ b/services/discovery/discovery-utils2.js @@ -44,10 +44,32 @@ DiscoveryUtils2.prototype = { }, + paramProjectCheck: function(params) { + var response = ''; + if (!params.projectId) { + response = 'Missing Project ID '; + } + return response; + }, + + buildParamsFor: function(msg, config, params, field) { + if (msg.discoveryparams && msg.discoveryparams[field]) { + params[field] = msg.discoveryparams[field]; + } else if (config[field]) { + params[field] = config[field]; + } + return params; + }, + + buildParams: function(msg, config) { var params = {}, me = this; + ['projectId'].forEach(function(f) { + params = me.buildParamsFor(msg, config, params, f); + }); + return params; } diff --git a/services/discovery/v2-project-manager.html b/services/discovery/v2-project-manager.html index 175a7d8e..885dd5d7 100644 --- a/services/discovery/v2-project-manager.html +++ b/services/discovery/v2-project-manager.html @@ -46,6 +46,12 @@ +
+ + +
+ + @@ -74,7 +91,7 @@
  • Retrieve project details

    -

    For this method the node needs an Project ID as input. +

    For this method the node needs project ID as input.

    The project being requested can be overridden by specifying the search id in msg.discoveryparams.projectId @@ -85,6 +102,25 @@

  • +
    + +
  • +

    Create new project

    +

    For this method the node needs project name and type as input. +

    +

    The name and type can be overridden by specifying + the msg.discoveryparams.projectName + and msg.discoveryparams.projectType +

    +

    The default query parameters for the query can be set by + specifying msg.discoveryparams.defaultQueryParameters +

    +

    Node output :

    +
      +
    • msg.discovery_response : Details of the requested project.
    • +
    +
  • +

    For more information about the Discovery service, @@ -103,6 +139,8 @@ disV2pm.hideAll = function() { $('#node-input-projectId').parent().hide(); + $('#node-input-projectName').parent().hide(); + $('#node-input-projectType').parent().hide(); }; disV2pm.showSelectedFields = function(fields) { @@ -117,7 +155,12 @@ switch (method) { case 'getProject': - fields.push('#node-input-projectId'); + fields.push('#node-input-projectId'); + break; + case 'createProject': + fields.push('#node-input-projectName'); + fields.push('#node-input-projectType'); + break; } disV2pm.showSelectedFields(fields); @@ -155,6 +198,8 @@ defaults: { name: {value: ''}, projectId: {value: ''}, + projectName: {value: ''}, + projectType: {value: 'document_retrieval'}, 'discovery-method': {value:'listProjects'}, 'service-endpoint' :{value: ''} }, diff --git a/services/discovery/v2-project-manager.js b/services/discovery/v2-project-manager.js index 747b147d..05a01c2d 100644 --- a/services/discovery/v2-project-manager.js +++ b/services/discovery/v2-project-manager.js @@ -29,7 +29,8 @@ module.exports = function (RED) { const ExecutionList = { 'listProjects' : executeListProjects, - 'getProject' : executeDiscoveryMethod + 'getProject' : executeDiscoveryMethod, + 'createProject' : executeDiscoveryMethod }; function executeListProjects(fields) { @@ -90,6 +91,11 @@ module.exports = function (RED) { case 'getProject': response = discoveryutils.paramProjectCheck(params); break; + + case 'createProject': + response = discoveryutils.paramNameCheck(params) + + discoveryutils.paramTypeCheck(params); + break; } if (response) { From fc3d5e79bd056c11aa97702b4f23b5fd493d480b Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Fri, 25 Mar 2022 13:38:07 +0000 Subject: [PATCH 16/34] Add updated project method --- services/discovery/v2-project-manager.html | 25 +++++++++++++++++++--- services/discovery/v2-project-manager.js | 9 +++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/services/discovery/v2-project-manager.html b/services/discovery/v2-project-manager.html index 0c53558f..317abd40 100644 --- a/services/discovery/v2-project-manager.html +++ b/services/discovery/v2-project-manager.html @@ -56,7 +56,6 @@ -

    @@ -136,6 +136,22 @@ + +
    + +
  • +

    Delete Project

    +

    For this method the node needs project Id as input. +

    +

    The Id can be overridden by specifying + the msg.discoveryparams.projectId +

    +

    Node output :

    +
      +
    • msg.discovery_response : result of the delete request.
    • +
    +
  • +

    For more information about the Discovery service, @@ -170,6 +186,7 @@ switch (method) { case 'getProject': + case 'deleteProject': fields.push('#node-input-projectId'); break; case 'createProject': diff --git a/services/discovery/v2-project-manager.js b/services/discovery/v2-project-manager.js index 386ad793..d47f61da 100644 --- a/services/discovery/v2-project-manager.js +++ b/services/discovery/v2-project-manager.js @@ -31,7 +31,8 @@ module.exports = function (RED) { 'listProjects' : executeListProjects, 'getProject' : executeDiscoveryMethod, 'createProject' : executeDiscoveryMethod, - 'updateProject' : executeDiscoveryMethod + 'updateProject' : executeDiscoveryMethod, + 'deleteProject' : executeDiscoveryMethod }; function executeListProjects(fields) { @@ -90,6 +91,7 @@ module.exports = function (RED) { switch (method) { case 'getProject': + case 'deleteProject': response = discoveryutils.paramProjectCheck(params); break; @@ -136,7 +138,6 @@ module.exports = function (RED) { } - if (dservice) { sApikey = dservice.apikey ? dservice.apikey : ''; sEndpoint = dservice.url ? dservice.url : ''; From a74f82072c549017b7aa56b9cbc3be0774df9602 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Fri, 25 Mar 2022 14:10:52 +0000 Subject: [PATCH 18/34] List Collections --- services/discovery/v2-project-manager.html | 25 +++++++++++++++++++++- services/discovery/v2-project-manager.js | 10 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/services/discovery/v2-project-manager.html b/services/discovery/v2-project-manager.html index 411b8004..4f6315eb 100644 --- a/services/discovery/v2-project-manager.html +++ b/services/discovery/v2-project-manager.html @@ -42,7 +42,13 @@ - + + + + + + +

    @@ -152,6 +158,22 @@ + +
    + +
  • +

    List Collections

    +

    For this method the node needs project Id as input. +

    +

    The project Id can be overridden by specifying + the search id in msg.discoveryparams.projectId +

    +

    Node output :

    +
      +
    • msg.collections : List of collections in the project.
    • +
    +
  • +

    For more information about the Discovery service, @@ -187,6 +209,7 @@ switch (method) { case 'getProject': case 'deleteProject': + case 'listCollections': fields.push('#node-input-projectId'); break; case 'createProject': diff --git a/services/discovery/v2-project-manager.js b/services/discovery/v2-project-manager.js index d47f61da..2d5a47cf 100644 --- a/services/discovery/v2-project-manager.js +++ b/services/discovery/v2-project-manager.js @@ -32,7 +32,9 @@ module.exports = function (RED) { 'getProject' : executeDiscoveryMethod, 'createProject' : executeDiscoveryMethod, 'updateProject' : executeDiscoveryMethod, - 'deleteProject' : executeDiscoveryMethod + 'deleteProject' : executeDiscoveryMethod, + + 'listCollections' : executeListCollections }; function executeListProjects(fields) { @@ -40,6 +42,11 @@ module.exports = function (RED) { return executeListMethod(fields) } + function executeListCollections(fields) { + fields.response = "collections"; + return executeListMethod(fields) + } + function executeListMethod(fields) { var p = new Promise(function resolver(resolve, reject){ fields.discovery[fields.method](fields.params) @@ -92,6 +99,7 @@ module.exports = function (RED) { switch (method) { case 'getProject': case 'deleteProject': + case 'listCollections': response = discoveryutils.paramProjectCheck(params); break; From 654285e54be1de1a9528d10a4b87e55e4c5bb649 Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Fri, 25 Mar 2022 14:25:12 +0000 Subject: [PATCH 19/34] Get Collection Method --- services/discovery/discovery-utils2.js | 8 +++++++- services/discovery/v2-project-manager.html | 10 ++++++++++ services/discovery/v2-project-manager.js | 7 ++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/services/discovery/discovery-utils2.js b/services/discovery/discovery-utils2.js index f0d97b82..0bc0b42c 100644 --- a/services/discovery/discovery-utils2.js +++ b/services/discovery/discovery-utils2.js @@ -48,6 +48,12 @@ DiscoveryUtils2.prototype = { return this.paramFieldCheck(params, 'projectId'); }, + paramCollectionCheck: function(params) { + return this.paramFieldCheck(params, 'projectId') + + this.paramFieldCheck(params, 'collectionId') ; + }, + + paramNameCheck: function(params) { return this.paramFieldCheck(params, 'name'); }, @@ -128,7 +134,7 @@ DiscoveryUtils2.prototype = { params = me.buildParamsForType(msg, config, params); params = me.adddefaultQueryParameters(msg, params); - ['projectId'].forEach(function(f) { + ['projectId', 'collectionId'].forEach(function(f) { params = me.buildParamsFor(msg, config, params, f); }); diff --git a/services/discovery/v2-project-manager.html b/services/discovery/v2-project-manager.html index 4f6315eb..0e5bdce8 100644 --- a/services/discovery/v2-project-manager.html +++ b/services/discovery/v2-project-manager.html @@ -73,6 +73,10 @@ +

    + + +
    @@ -194,6 +198,7 @@ $('#node-input-projectId').parent().hide(); $('#node-input-projectName').parent().hide(); $('#node-input-projectType').parent().hide(); + $('#node-input-collectionId').parent().hide(); }; disV2pm.showSelectedFields = function(fields) { @@ -220,6 +225,10 @@ fields.push('#node-input-projectId'); fields.push('#node-input-projectName'); break; + case 'getCollection': + fields.push('#node-input-projectId'); + fields.push('#node-input-collectionId'); + break; } disV2pm.showSelectedFields(fields); @@ -259,6 +268,7 @@ projectId: {value: ''}, projectName: {value: ''}, projectType: {value: 'document_retrieval'}, + collectionId: {value: ''}, 'discovery-method': {value:'listProjects'}, 'service-endpoint' :{value: ''} }, diff --git a/services/discovery/v2-project-manager.js b/services/discovery/v2-project-manager.js index 2d5a47cf..e1f273bb 100644 --- a/services/discovery/v2-project-manager.js +++ b/services/discovery/v2-project-manager.js @@ -34,7 +34,8 @@ module.exports = function (RED) { 'updateProject' : executeDiscoveryMethod, 'deleteProject' : executeDiscoveryMethod, - 'listCollections' : executeListCollections + 'listCollections' : executeListCollections, + 'getCollection' : executeDiscoveryMethod, }; function executeListProjects(fields) { @@ -103,6 +104,10 @@ module.exports = function (RED) { response = discoveryutils.paramProjectCheck(params); break; + case 'getCollection': + response = discoveryutils.paramCollectionCheck(params); + break; + case 'createProject': response = discoveryutils.paramNameCheck(params) + discoveryutils.paramTypeCheck(params); From 9895ed8b95476469a5ed8f27a2260b9b22bf785f Mon Sep 17 00:00:00 2001 From: Soheel Chughtai Date: Fri, 25 Mar 2022 15:07:46 +0000 Subject: [PATCH 20/34] Create Collection method --- services/discovery/discovery-utils2.js | 32 ++++++++----- services/discovery/v2-project-manager.html | 56 ++++++++++++++++++++++ services/discovery/v2-project-manager.js | 6 +++ 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/services/discovery/discovery-utils2.js b/services/discovery/discovery-utils2.js index 0bc0b42c..6d553fa1 100644 --- a/services/discovery/discovery-utils2.js +++ b/services/discovery/discovery-utils2.js @@ -82,15 +82,20 @@ DiscoveryUtils2.prototype = { buildParamsForName: function(msg, config, params) { let name = ''; if (msg.discoveryparams) { - if (msg.discoveryparams.projectName) { - name = msg.discoveryparams.projectName; - } else if (msg.discoveryparams.projectname) { - name = msg.discoveryparams.projectname; + for (f of ['projectName', 'projectname', + 'collectionName', 'collectionname']) { + if (msg.discoveryparams[f]) { + name = msg.discoveryparams[f]; + break; + } } } if (!name) { - if (config.projectName) { - name = config.projectName + for (f of ['projectName', 'collectionName']) { + if (config[f]) { + name = config[f]; + break; + } } } if (name) { @@ -119,9 +124,14 @@ DiscoveryUtils2.prototype = { return params; }, - adddefaultQueryParameters: function(msg, params) { - if (msg.discoveryparams && msg.discoveryparams.defaultQueryParameters) { - params.defaultQueryParameters = msg.discoveryparams.defaultQueryParameters; + addOtherParams: function(msg, params) { + if (msg.discoveryparams) { + if (msg.discoveryparams.defaultQueryParameters) { + params.defaultQueryParameters = msg.discoveryparams.defaultQueryParameters; + } + if (msg.discoveryparams.enrichments) { + params.defaultQueryParameters = msg.discoveryparams.enrichments; + } } return params }, @@ -132,9 +142,9 @@ DiscoveryUtils2.prototype = { params = me.buildParamsForName(msg, config, params); params = me.buildParamsForType(msg, config, params); - params = me.adddefaultQueryParameters(msg, params); + params = me.addOtherParams(msg, params); - ['projectId', 'collectionId'].forEach(function(f) { + ['projectId', 'collectionId', 'description', 'language'].forEach(function(f) { params = me.buildParamsFor(msg, config, params, f); }); diff --git a/services/discovery/v2-project-manager.html b/services/discovery/v2-project-manager.html index 0e5bdce8..49234fe5 100644 --- a/services/discovery/v2-project-manager.html +++ b/services/discovery/v2-project-manager.html @@ -78,6 +78,22 @@ +
    + + +
    + +
    + + +
    + + +
    + + +
    +