You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/01/12 18:51:06 UTC

[GitHub] csantanapr closed pull request #95: Sugar namespsace get.

csantanapr closed pull request #95: Sugar namespsace get.
URL: https://github.com/apache/incubator-openwhisk-client-js/pull/95
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/README.md b/README.md
index 3f36dec..81cdbb2 100644
--- a/README.md
+++ b/README.md
@@ -245,7 +245,6 @@ ow.actions.get({name: '...'})
 ow.activations.get({name: '...'})
 ow.triggers.get({name: '...'})
 ow.rules.get({name: '...'})
-ow.namespaces.get({name: '...'})
 ow.packages.get({name: '...'})
 ow.feeds.get({name: '...', trigger: '...'})
 ```
diff --git a/lib/namespaces.js b/lib/namespaces.js
index b07fa96..e9d8a81 100644
--- a/lib/namespaces.js
+++ b/lib/namespaces.js
@@ -7,22 +7,17 @@ const BaseOperation = require('./base_operation')
 
 class Namespaces extends BaseOperation {
   list () {
-    return this.client.request('GET', `namespaces`)
+    return this.client.request('GET', 'namespaces')
   }
 
-  get (options) {
-    if (typeof options === 'string') {
-      return this.client.request('GET', `namespaces/${options}`)
-    }
-
-    options = options || {}
-    const id = options.name || options.namespace
-
-    if (!id) {
-      throw new Error('Missing mandatory parameter: id or namespace.')
-    }
-
-    return this.client.request('GET', `namespaces/${id}`)
+  get () {
+    let actions = this.client.request('GET', 'namespaces/_/actions')
+    let packages = this.client.request('GET', 'namespaces/_/packages')
+    let triggers = this.client.request('GET', 'namespaces/_/triggers')
+    let rules = this.client.request('GET', 'namespaces/_/rules')
+    return Promise
+      .all([actions, packages, triggers, rules])
+      .then(([actions, packages, triggers, rules]) => ({actions, packages, triggers, rules}))
   }
 }
 
diff --git a/test/unit/namespaces.test.js b/test/unit/namespaces.test.js
index 1c7b03e..5a31673 100644
--- a/test/unit/namespaces.test.js
+++ b/test/unit/namespaces.test.js
@@ -18,46 +18,17 @@ test('should list all namespaces', t => {
   return namespaces.list()
 })
 
-test('should retrieve namespace using id', t => {
-  t.plan(2)
+test('should retrieve namespace entities', t => {
+  t.plan(16)
   const client = {}
-  const id = 'custom_ns'
   client.request = (method, path, options) => {
     t.is(method, 'GET')
-    t.is(path, `namespaces/${id}`)
+    let parts = path.split('/')
+    t.is(parts[0], 'namespaces')
+    t.is(parts[1], '_')
+    t.is(["actions", "triggers", "rules", "packages"].indexOf(parts[2]) > -1, true)
   }
 
   const namespaces = new Namespaces(client)
-  return namespaces.get({name: id})
-})
-
-test('should retrieve namespace using string id', t => {
-  t.plan(2)
-  const client = {}
-  const id = 'custom_ns'
-  client.request = (method, path, options) => {
-    t.is(method, 'GET')
-    t.is(path, `namespaces/${id}`)
-  }
-
-  const namespaces = new Namespaces(client)
-  return namespaces.get(id)
-})
-
-test('should retrieve namespace using namespace', t => {
-  t.plan(2)
-  const client = {}
-  const id = 'custom_ns'
-  client.request = (method, path, options) => {
-    t.is(method, 'GET')
-    t.is(path, `namespaces/${id}`)
-  }
-
-  const namespaces = new Namespaces(client)
-  return namespaces.get({namespace: id})
-})
-
-test('should throw error for missing namespace id', t => {
-  const namespaces = new Namespaces()
-  return t.throws(() => { namespaces.get() }, /Missing mandatory parameter/)
+  return namespaces.get()
 })


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services