You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ja...@apache.org on 2018/03/23 11:40:34 UTC

[incubator-openwhisk-client-js] branch master updated: add count to list of valid qs params (#109)

This is an automated email from the ASF dual-hosted git repository.

jamesthomas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 0375c28  add count to list of valid qs params (#109)
0375c28 is described below

commit 0375c2899a88c69aa2b66b527daf01b9bd65a570
Author: Carlos Santana <cs...@gmail.com>
AuthorDate: Fri Mar 23 04:40:32 2018 -0700

    add count to list of valid qs params (#109)
    
    * add count to list of valid qs params
    
    * update readme with count
    
    * add tests for count query param
    
    * Update README.md
---
 README.md                     |  7 ++++++-
 lib/actions.js                |  2 +-
 lib/activations.js            |  2 +-
 lib/packages.js               |  2 +-
 lib/rules.js                  |  2 +-
 lib/triggers.js               |  2 +-
 test/unit/actions.test.js     | 14 ++++++++++++++
 test/unit/activations.test.js | 14 ++++++++++++++
 test/unit/packages.test.js    | 14 ++++++++++++++
 test/unit/rules.test.js       | 14 ++++++++++++++
 test/unit/triggers.test.js    | 15 +++++++++++++++
 11 files changed, 82 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index d11110d..3ce22fe 100644
--- a/README.md
+++ b/README.md
@@ -229,12 +229,17 @@ ow.namespaces.list()
 ow.packages.list()
 ```
 
-Query parameters for the API calls are supported (e.g. limit, skip, etc.) by passing an object with the named parameters as the first argument.
+Query parameters for the API calls are supported (e.g. limit, skip, count etc.) by passing an object with the named parameters as the first argument.
 
 ```javascript
 ow.actions.list({skip: 100, limit: 50})
 ```
 
+To count the number of resources without retrieving the resources you can use `count` query parameter.
+```javascript
+ow.actions.list({count:true})
+```
+
 The following optional parameters are supported:
 - `namespace` - set custom namespace for endpoint
 
diff --git a/lib/actions.js b/lib/actions.js
index c76ff15..77a1a57 100644
--- a/lib/actions.js
+++ b/lib/actions.js
@@ -16,7 +16,7 @@ class Actions extends Resources {
 
   list (options) {
     options = options || {}
-    options.qs = this.qs(options, ['skip', 'limit'])
+    options.qs = this.qs(options, ['skip', 'limit', 'count'])
 
     return super.list(options)
   }
diff --git a/lib/activations.js b/lib/activations.js
index 2358262..9cd3fe1 100644
--- a/lib/activations.js
+++ b/lib/activations.js
@@ -10,7 +10,7 @@ class Activations extends BaseOperation {
   list (options) {
     options = options || {}
     const namespace = this.namespace(options)
-    options.qs = this.qs(options || {}, ['name', 'skip', 'limit', 'upto', 'docs', 'since'])
+    options.qs = this.qs(options || {}, ['name', 'skip', 'limit', 'upto', 'docs', 'since', 'count'])
     return this.client.request('GET', `namespaces/${namespace}/activations`, options)
   }
 
diff --git a/lib/packages.js b/lib/packages.js
index aaeaec2..27391b6 100644
--- a/lib/packages.js
+++ b/lib/packages.js
@@ -14,7 +14,7 @@ class Packages extends Resources {
 
   list (options) {
     options = options || {}
-    options.qs = this.qs(options, ['skip', 'limit', 'public'])
+    options.qs = this.qs(options, ['skip', 'limit', 'public', 'count'])
 
     return super.list(options)
   }
diff --git a/lib/rules.js b/lib/rules.js
index 1606cba..4d09291 100644
--- a/lib/rules.js
+++ b/lib/rules.js
@@ -16,7 +16,7 @@ class Rules extends Resources {
 
   list (options) {
     options = options || {}
-    options.qs = this.qs(options, ['skip', 'limit'])
+    options.qs = this.qs(options, ['skip', 'limit', 'count'])
 
     return super.list(options)
   }
diff --git a/lib/triggers.js b/lib/triggers.js
index a0a88c0..f12d58b 100644
--- a/lib/triggers.js
+++ b/lib/triggers.js
@@ -14,7 +14,7 @@ class Triggers extends Resources {
 
   list (options) {
     options = options || {}
-    options.qs = this.qs(options, ['skip', 'limit'])
+    options.qs = this.qs(options, ['skip', 'limit', 'count'])
 
     return super.list(options)
   }
diff --git a/test/unit/actions.test.js b/test/unit/actions.test.js
index 715639a..b1b552a 100644
--- a/test/unit/actions.test.js
+++ b/test/unit/actions.test.js
@@ -35,6 +35,20 @@ test('should list all actions with parameters', t => {
   return actions.list({namespace: 'custom', skip: 100, limit: 100})
 })
 
+test('should list all actions with parameter count', t => {
+  t.plan(3)
+  const client = {}
+  const actions = new Actions(client)
+
+  client.request = (method, path, options) => {
+    t.is(method, 'GET')
+    t.is(path, `namespaces/custom/actions`)
+    t.deepEqual(options.qs, {count: true})
+  }
+
+  return actions.list({namespace: 'custom', count: true})
+})
+
 test('should retrieve action from identifier', t => {
   t.plan(2)
   const ns = '_'
diff --git a/test/unit/activations.test.js b/test/unit/activations.test.js
index d9607b5..0d6e31d 100644
--- a/test/unit/activations.test.js
+++ b/test/unit/activations.test.js
@@ -35,6 +35,20 @@ test('list all activations', t => {
   return activations.list({namespace: 'options_namespace', name: 'Hello', limit: 100, skip: 100, since: 100, upto: 100, docs: true})
 })
 
+test('list all activations with count parameter', t => {
+  t.plan(3)
+  const client = {}
+  const activations = new Activations(client)
+
+  client.request = (method, path, options) => {
+    t.is(method, 'GET')
+    t.is(path, `namespaces/options_namespace/activations`)
+    t.deepEqual(options.qs, {name: 'Hello', count: true})
+  }
+
+  return activations.list({namespace: 'options_namespace', name: 'Hello', count: true})
+})
+
 test('should retrieve an activation', t => {
   t.plan(2)
   const ns = '_'
diff --git a/test/unit/packages.test.js b/test/unit/packages.test.js
index 8fcb2fc..e02558e 100644
--- a/test/unit/packages.test.js
+++ b/test/unit/packages.test.js
@@ -35,6 +35,20 @@ test('should list all packages with parameters', t => {
   return packages.list({namespace: 'custom', skip: 100, limit: 100})
 })
 
+test('should list all packages with parameter count', t => {
+  t.plan(3)
+  const client = {}
+  const packages = new Packages(client)
+
+  client.request = (method, path, options) => {
+    t.is(method, 'GET')
+    t.is(path, `namespaces/custom/packages`)
+    t.deepEqual(options.qs, {count: true})
+  }
+
+  return packages.list({namespace: 'custom', count: true})
+})
+
 test('should retrieve package from string identifier', t => {
   t.plan(2)
   const ns = '_'
diff --git a/test/unit/rules.test.js b/test/unit/rules.test.js
index d1365c1..b2b8265 100644
--- a/test/unit/rules.test.js
+++ b/test/unit/rules.test.js
@@ -35,6 +35,20 @@ test('should list all rules with parameters', t => {
   return rules.list({namespace: 'custom', skip: 100, limit: 100})
 })
 
+test('should list all rules with parameter count', t => {
+  t.plan(3)
+  const client = { options: {} }
+  const rules = new Rules(client)
+
+  client.request = (method, path, options) => {
+    t.is(method, 'GET')
+    t.is(path, `namespaces/custom/rules`)
+    t.deepEqual(options.qs, {count: true})
+  }
+
+  return rules.list({namespace: 'custom', count: true})
+})
+
 test('should retrieve rule from identifier', t => {
   t.plan(2)
   const ns = '_'
diff --git a/test/unit/triggers.test.js b/test/unit/triggers.test.js
index 81e3933..d855727 100644
--- a/test/unit/triggers.test.js
+++ b/test/unit/triggers.test.js
@@ -36,6 +36,21 @@ test('should list all triggers with parameters', t => {
   return triggers.list({namespace: 'custom', skip: 100, limit: 100})
 })
 
+test('should list all triggers with parameter count', t => {
+  t.plan(3)
+  const ns = '_'
+  const client = {}
+  const triggers = new Triggers(client)
+
+  client.request = (method, path, options) => {
+    t.is(method, 'GET')
+    t.is(path, `namespaces/custom/triggers`)
+    t.deepEqual(options.qs, {count: true})
+  }
+
+  return triggers.list({namespace: 'custom', count: true})
+})
+
 test('should retrieve trigger from identifier', t => {
   t.plan(2)
   const ns = '_'

-- 
To stop receiving notification emails like this one, please contact
jamesthomas@apache.org.