{"action":"created","comment":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/93267945","pull_request_review_id":13791651,"id":93267945,"diff_hunk":"@@ -0,0 +1,216 @@\n+/**\n+ * Copyright 20016 IBM Corp.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the 'License');\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an 'AS IS' BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ **/\n+\n+module.exports = function (RED) {\n+\n+  const SERVICE_IDENTIFIER = 'discovery';\n+  var discoveryutils = require('./discovery-utils'),\n+    DiscoveryV1 = require('watson-developer-cloud/discovery/v1'),\n+    serviceutils = require('../../utilities/service-utils'),\n+    dservice = serviceutils.getServiceCreds(SERVICE_IDENTIFIER),\n+    username = null,\n+    password = null,\n+    sUsername = null,\n+    sPassword = null;\n+\n+  function checkParams(method, params){\n+    var response = '';\n+    switch (method) {\n+    case 'getEnvironmentDetails':\n+    case 'listCollections':\n+      response = discoveryutils.paramEnvCheck(params);\n+      break;\n+    case 'getCollectionDetails':\n+    case 'query':\n+      response = discoveryutils.paramEnvCheck(params)\n+            + discoveryutils.paramCollectionCheck(params);\n+      break;\n+    case 'listConfigurations':\n+      response = discoveryutils.paramEnvCheck(params);\n+      break;\n+    case 'getConfigurationDetails':\n+      response = discoveryutils.paramEnvCheck(params)\n+            + discoveryutils.paramConfigurationCheck(params);\n+      break;\n+    }\n+    return response;\n+  }\n+\n+  function executeListEnvrionments(node, discovery, params, msg) {\n+    discovery.getEnvironments(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.environments = response.environments ? response.environments : [];\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeEnvrionmentDetails(node, discovery, params, msg) {\n+    discovery.getEnvironment(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.environment_details = response;\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeListCollections(node, discovery, params, msg) {\n+    discovery.getCollections(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.collections = response.collections ? response.collections : [];\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeGetCollectionDetails(node, discovery, params, msg) {\n+    discovery.getCollection(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.collection_details = response;\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeListConfigurations(node, discovery, params, msg) {\n+    discovery.getConfigurations(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.configurations = response.configurations ? response.configurations : [];\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeGetConfigurationDetails(node, discovery, params, msg) {\n+    discovery.getConfiguration(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.configuration_details = response;\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeQuery(node, discovery, params, msg) {\n+    discovery.query(params, function (err, response) {\n+      node.status({});\n+      if (err) {\n+        discoveryutils.reportError(node, msg, err.error);\n+      } else {\n+        msg.search_results = response;\n+      }\n+      node.send(msg);\n+    });\n+  }\n+\n+  function executeMethod(node, method, params, msg) {","path":"services/discovery/v1.js","position":136,"original_position":136,"commit_id":"147cade9dfd2a2bfc5ffaeaa892bdd73aeb947cd","original_commit_id":"147cade9dfd2a2bfc5ffaeaa892bdd73aeb947cd","user":{"login":"codacy-bot","id":19940114,"avatar_url":"https://avatars.githubusercontent.com/u/19940114?v=3","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Function 'executeMethod' has a complexity of 8. (complexity)](https://www.codacy.com/app/BetaWorks-NodeRED-Watson/node-red-node-watson/file/4782504577/issues/source?bid=3330694&fileBranchId=4016200#l136)","created_at":"2016-12-20T16:05:35Z","updated_at":"2016-12-20T16:05:35Z","html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/230#discussion_r93267945","pull_request_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230","_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/93267945"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/230#discussion_r93267945"},"pull_request":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230"}}},"pull_request":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230","id":98767055,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/230","diff_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/230.diff","patch_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/230.patch","issue_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/230","number":230,"state":"open","locked":false,"title":"Discovery Node","user":{"login":"chughts","id":10371360,"avatar_url":"https://avatars.githubusercontent.com/u/10371360?v=3","gravatar_id":"","url":"https://api.github.com/users/chughts","html_url":"https://github.com/chughts","followers_url":"https://api.github.com/users/chughts/followers","following_url":"https://api.github.com/users/chughts/following{/other_user}","gists_url":"https://api.github.com/users/chughts/gists{/gist_id}","starred_url":"https://api.github.com/users/chughts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chughts/subscriptions","organizations_url":"https://api.github.com/users/chughts/orgs","repos_url":"https://api.github.com/users/chughts/repos","events_url":"https://api.github.com/users/chughts/events{/privacy}","received_events_url":"https://api.github.com/users/chughts/received_events","type":"User","site_admin":false},"body":"New Discovery V1 Node, implementing query and list and get details methods for environments, configurations and collections.","created_at":"2016-12-20T15:17:23Z","updated_at":"2016-12-20T16:05:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45c05554840b668b2caf524b06ff1c09f4c61060","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230/commits","review_comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230/comments","review_comment_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/230/comments","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/147cade9dfd2a2bfc5ffaeaa892bdd73aeb947cd","head":{"label":"chughts:cffixes","ref":"cffixes","sha":"147cade9dfd2a2bfc5ffaeaa892bdd73aeb947cd","user":{"login":"chughts","id":10371360,"avatar_url":"https://avatars.githubusercontent.com/u/10371360?v=3","gravatar_id":"","url":"https://api.github.com/users/chughts","html_url":"https://github.com/chughts","followers_url":"https://api.github.com/users/chughts/followers","following_url":"https://api.github.com/users/chughts/following{/other_user}","gists_url":"https://api.github.com/users/chughts/gists{/gist_id}","starred_url":"https://api.github.com/users/chughts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chughts/subscriptions","organizations_url":"https://api.github.com/users/chughts/orgs","repos_url":"https://api.github.com/users/chughts/repos","events_url":"https://api.github.com/users/chughts/events{/privacy}","received_events_url":"https://api.github.com/users/chughts/received_events","type":"User","site_admin":false},"repo":{"id":58115630,"name":"node-red-node-watson","full_name":"chughts/node-red-node-watson","owner":{"login":"chughts","id":10371360,"avatar_url":"https://avatars.githubusercontent.com/u/10371360?v=3","gravatar_id":"","url":"https://api.github.com/users/chughts","html_url":"https://github.com/chughts","followers_url":"https://api.github.com/users/chughts/followers","following_url":"https://api.github.com/users/chughts/following{/other_user}","gists_url":"https://api.github.com/users/chughts/gists{/gist_id}","starred_url":"https://api.github.com/users/chughts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chughts/subscriptions","organizations_url":"https://api.github.com/users/chughts/orgs","repos_url":"https://api.github.com/users/chughts/repos","events_url":"https://api.github.com/users/chughts/events{/privacy}","received_events_url":"https://api.github.com/users/chughts/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chughts/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":true,"url":"https://api.github.com/repos/chughts/node-red-node-watson","forks_url":"https://api.github.com/repos/chughts/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/chughts/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chughts/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chughts/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/chughts/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/chughts/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/chughts/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/chughts/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/chughts/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/chughts/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chughts/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/chughts/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/chughts/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/chughts/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/chughts/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/chughts/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/chughts/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/chughts/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/chughts/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/chughts/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/chughts/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chughts/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/chughts/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chughts/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/chughts/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/chughts/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/chughts/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/chughts/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chughts/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/chughts/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/chughts/node-red-node-watson/deployments","created_at":"2016-05-05T08:19:28Z","updated_at":"2016-10-29T19:52:33Z","pushed_at":"2016-12-20T16:03:46Z","git_url":"git://github.com/chughts/node-red-node-watson.git","ssh_url":"git@github.com:chughts/node-red-node-watson.git","clone_url":"https://github.com/chughts/node-red-node-watson.git","svn_url":"https://github.com/chughts/node-red-node-watson","homepage":null,"size":8033,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"watson-developer-cloud:master","ref":"master","sha":"5ad9742ef319c600f98e352bb0778ba58e32a517","user":{"login":"watson-developer-cloud","id":10017763,"avatar_url":"https://avatars.githubusercontent.com/u/10017763?v=3","gravatar_id":"","url":"https://api.github.com/users/watson-developer-cloud","html_url":"https://github.com/watson-developer-cloud","followers_url":"https://api.github.com/users/watson-developer-cloud/followers","following_url":"https://api.github.com/users/watson-developer-cloud/following{/other_user}","gists_url":"https://api.github.com/users/watson-developer-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/watson-developer-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watson-developer-cloud/subscriptions","organizations_url":"https://api.github.com/users/watson-developer-cloud/orgs","repos_url":"https://api.github.com/users/watson-developer-cloud/repos","events_url":"https://api.github.com/users/watson-developer-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/watson-developer-cloud/received_events","type":"Organization","site_admin":false},"repo":{"id":55415107,"name":"node-red-node-watson","full_name":"watson-developer-cloud/node-red-node-watson","owner":{"login":"watson-developer-cloud","id":10017763,"avatar_url":"https://avatars.githubusercontent.com/u/10017763?v=3","gravatar_id":"","url":"https://api.github.com/users/watson-developer-cloud","html_url":"https://github.com/watson-developer-cloud","followers_url":"https://api.github.com/users/watson-developer-cloud/followers","following_url":"https://api.github.com/users/watson-developer-cloud/following{/other_user}","gists_url":"https://api.github.com/users/watson-developer-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/watson-developer-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watson-developer-cloud/subscriptions","organizations_url":"https://api.github.com/users/watson-developer-cloud/orgs","repos_url":"https://api.github.com/users/watson-developer-cloud/repos","events_url":"https://api.github.com/users/watson-developer-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/watson-developer-cloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":false,"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson","forks_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/deployments","created_at":"2016-04-04T13:51:28Z","updated_at":"2016-12-15T18:42:15Z","pushed_at":"2016-12-20T16:03:48Z","git_url":"git://github.com/watson-developer-cloud/node-red-node-watson.git","ssh_url":"git@github.com:watson-developer-cloud/node-red-node-watson.git","clone_url":"https://github.com/watson-developer-cloud/node-red-node-watson.git","svn_url":"https://github.com/watson-developer-cloud/node-red-node-watson","homepage":null,"size":8006,"stargazers_count":19,"watchers_count":19,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":15,"forks":31,"open_issues":15,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/230"},"issue":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/230"},"comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/230/comments"},"review_comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230/comments"},"review_comment":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/230/commits"},"statuses":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/147cade9dfd2a2bfc5ffaeaa892bdd73aeb947cd"}}}}
{"actor":{"display_login":"codacy-bot"}}