abaruni closed pull request #88: WIP support feed trigger update
URL: https://github.com/apache/incubator-openwhisk-client-js/pull/88
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 afd150e..3f36dec 100644
--- a/README.md
+++ b/README.md
@@ -247,7 +247,7 @@ ow.triggers.get({name: '...'})
ow.rules.get({name: '...'})
ow.namespaces.get({name: '...'})
ow.packages.get({name: '...'})
-ow.feeds.get({name: '...'})
+ow.feeds.get({name: '...', trigger: '...'})
```
The following optional parameters are supported:
@@ -415,10 +415,11 @@ ow.rules.disable({name: '...'})
The following optional parameters are supported:
- `namespace` - set custom namespace for endpoint
-### create feeds
+### create & update feeds
```javascript
ow.feeds.create({feedName: '...', trigger: '...'})
+ow.feeds.update({feedName: '...', trigger: '...'})
```
The following optional parameters are supported:
diff --git a/lib/feeds.js b/lib/feeds.js
index f8cdc28..1ecc151 100644
--- a/lib/feeds.js
+++ b/lib/feeds.js
@@ -25,6 +25,10 @@ class Feeds {
return this.feed('READ', options)
}
+ update (options) {
+ return this.feed('UPDATE', options)
+ }
+
feed (event, options) {
if (!this.feed_name(options)) {
throw new Error(messages.MISSING_FEED_NAME_ERROR)
diff --git a/test/integration/feeds.test.js b/test/integration/feeds.test.js
index 1ebd7b8..d2ea95c 100644
--- a/test/integration/feeds.test.js
+++ b/test/integration/feeds.test.js
@@ -23,7 +23,7 @@ envParams.forEach(key => {
const NAMESPACE = process.env.__OW_NAMESPACE
var tempTest = Utils.getInsecureFlag() ? test.skip : test;
-tempTest('create and delete a feed', t => {
+tempTest('create, get, update, and delete a feed', t => {
const errors = err => {
console.log(err)
t.fail()
@@ -42,9 +42,12 @@ tempTest('create and delete a feed', t => {
t.is(get_result.response.success, true)
return feeds.delete(feed_params).then(feed_result => {
t.is(feed_result.response.success, true)
- return triggers.delete({triggerName: 'sample_feed_trigger'}).then(()
=> {
- t.pass()
- })
+ return feeds.update(feed_params).then(update_result => {
+ t.is(feed_result.response.success, false) // alarms does not
currently support update, hence should fail
+ return triggers.delete({triggerName: 'sample_feed_trigger'}).then(()
=> {
+ t.pass()
+ })
+ }).catch(errors)
}).catch(errors)
}).catch(errors)
}).catch(errors)
diff --git a/test/unit/feeds.test.js b/test/unit/feeds.test.js
index d68ef6f..005f3ec 100644
--- a/test/unit/feeds.test.js
+++ b/test/unit/feeds.test.js
@@ -228,6 +228,28 @@ test('should be able to get feed', t => {
return feeds.get({name: feed_name, trigger: trigger_name})
})
+test('should be able to update feed', t => {
+ const feed_name = 'feed_name'
+ const api_key = 'username:password'
+ const trigger_name = '/trigger_ns/trigger_name'
+ const client = {}
+ client.options = { api_key }
+
+ const ns = '_'
+ const feeds = new Feeds(client)
+
+ client.request = (method, path, options) => {
+ t.is(method, 'POST')
+ t.is(path, `namespaces/${ns}/actions/${feed_name}`)
+ t.deepEqual(options.qs, {blocking: true})
+ t.deepEqual(options.body, {authKey: client.options.api_key,
lifecycleEvent: 'UPDATE', triggerName: `${trigger_name}`})
+ }
+
+ t.plan(4)
+
+ return feeds.update({name: feed_name, trigger: trigger_name})
+})
+
test('should throw errors without trigger parameter ', t => {
const ns = '_'
const client = { options: {} }
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services