Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

feat: add V2 support-notifications #420

Merged

Conversation

siggiskulason
Copy link

@siggiskulason siggiskulason commented Nov 2, 2021

This commit adds support for support-notification enpoints:

  • notification [add/cleanup/list/rm]
  • subscription [add/get/list/rm]
  • transmission [get/list/rm]

Fix #392
Fix #389

Signed-off-by: Siggi Skulason siggi.skulason@canonical.com

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-cli/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?) Will be added in separate PR
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?) Will be added in separate PR

Testing Instructions

  1. Install EdgeXFoundry and start up support-notifications service
  2. Build the CLI from this PR with make build and test the commands as follows:

notifications [add/cleanup/list/rm]

# print help
./bin/edgex-cli notification

# add notifications
./bin/edgex-cli notification add -h
./bin/edgex-cli notification add -s "sender01" -c "content" --category "category01"
./bin/edgex-cli notification add -s "sender01" -c "content" --category "category02"
./bin/edgex-cli notification add -s "sender01" -c "content" --category "category03" --labels "l1,l2"
./bin/edgex-cli notification add -s "sender01" -c "content" --category "category04" --labels "l3"

# list notifications, short, verbose and json
./bin/edgex-cli notification list -h
./bin/edgex-cli notification list -c "category02" -v
./bin/edgex-cli notification list -c "category03" -v -j | jq '.'
./bin/edgex-cli notification list --start "01 jan 20 00:00 GMT" --end "01 dec 24 00:00 GMT"

# remove a notification by ID
./bin/edgex-cli notification list -c "category04"
ID=`./bin/edgex-cli notification list -c "category04" -v -j | jq -r '.notifications[0].id'`
./bin/edgex-cli notification rm -i $ID
./bin/edgex-cli notification list -c "category04"


# clean up all notifications
./bin/edgex-cli notification list --start "01 jan 20 00:00 GMT" --end "01 dec 24 00:00 GMT"
./bin/edgex-cli notification cleanup
./bin/edgex-cli notification list --start "01 jan 20 00:00 GMT" --end "01 dec 24 00:00 GMT"

subscriptions [add/get/list/rm]

# print help
./bin/edgex-cli subscription

# add subscriptions
./bin/edgex-cli subscription add -h
./bin/edgex-cli subscription add -n "name01" --receiver "receiver01" -c "[{\"type\": \"EMAIL\", \"recipients\": [\"123@gmail.com\"]}]" --labels "l1,l2,l3"

# get the subscription by name
./bin/edgex-cli subscription name -n "name01"
./bin/edgex-cli subscription name -n "name01" -v
./bin/edgex-cli subscription name -n "name01" -j || jq '.'

# list subscriptions
./bin/edgex-cli subscription list
./bin/edgex-cli subscription list --label "l1"
./bin/edgex-cli subscription list --label "l4"

# remove subscription
./bin/edgex-cli subscription rm -n "name01"
./bin/edgex-cli subscription list --label "l1"

transmissions [get/list/rm]

# print help
./bin/edgex-cli transmission

# create a notification and subscription
./bin/edgex-cli subscription add -n "Test-Subscription" --description "Test data for subscription" --categories "health-check" --labels "simple" --receiver "tafuser" --resend-limit 0 --admin-state "UNLOCKED" -c "[{\"type\": \"REST\", \"host\": \"localhost\", \"port\": 7770, \"httpMethod\": \"POST\"}]"
./bin/edgex-cli notification add -d "Test data for notification 1" --category "health-check" --labels "simple" --content-type "string" --content "This is a test notification" --sender "taf-admin"
./bin/edgex-cli notification add -d "Test data for notification 2" --category "health-check" --labels "simple" --content-type "string" --content "This is a test notification" --sender "taf-admin"
./bin/edgex-cli notification add -d "Test data for notification 3" --category "health-check" --labels "simple" --content-type "string" --content "This is a test notification" --sender "taf-admin"
 
 # list the transmissions
./bin/edgex-cli transmission list
./bin/edgex-cli transmission list -v 
ID=`./bin/edgex-cli transmission list -j | jq -r '.transmissions[0].id'`
./bin/edgex-cli transmission id -i $ID
./bin/edgex-cli transmission id -i $ID -v
./bin/edgex-cli transmission id -i $ID -j

New Dependency Instructions (If applicable)

This commit adds support for support-notification endpoints:

- notification [add/cleanup/list/rm]
- subscription [add/get/list/rm]
- transmission [get/list/rm]

Fix #392
Fix #389

Signed-off-by: Siggi Skulason <siggi.skulason@canonical.com>
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@siggiskulason siggiskulason merged commit aba3abf into edgexfoundry:main Nov 3, 2021
@siggiskulason siggiskulason deleted the add-v2-support-notifications branch December 3, 2021 13:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade CLI to V2 - update subscription commands Upgrade CLI to V2 - update notification commands
2 participants