Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --raw flag for Subscription command (#201)
- Loading branch information
Showing
11 changed files
with
395 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2020-2021 Kazuhito Suda | ||
# | ||
# This file is part of NGSI Go | ||
# | ||
# https://github.com/lets-fiware/ngsi-go | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
|
||
# | ||
# Related issues: | ||
# https://github.com/lets-fiware/ngsi-go/issues/201 | ||
|
||
# | ||
# 0001 Create entity (400 Bad Request) | ||
# | ||
ngsi create --host orion subscription \ | ||
--data '{ | ||
"description": "Test Notification", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": "Alert.*", | ||
"type": "Alert" | ||
} | ||
], | ||
"condition": { | ||
"attrs": [] | ||
} | ||
}, | ||
"notification": { | ||
"httpCustom": { | ||
"url": "http://dev/null", | ||
"headers": { | ||
"fiware-shared-key": "test" | ||
} | ||
}, | ||
"attrsFormat": "keyValues" | ||
} | ||
}' | ||
|
||
|
||
```1 | ||
subscriptionsCreateV2005 400 Bad Request {"error":"BadRequest","description":"condition is empty"} | ||
``` | ||
|
||
# | ||
# 0002 Create entity --raw | ||
# | ||
ngsi create --host orion subscription --raw \ | ||
--data '{ | ||
"description": "Test Notification", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": "Alert.*", | ||
"type": "Alert" | ||
} | ||
], | ||
"condition": { | ||
"attrs": [] | ||
} | ||
}, | ||
"notification": { | ||
"httpCustom": { | ||
"url": "http://dev/null", | ||
"headers": { | ||
"fiware-shared-key": "test" | ||
} | ||
}, | ||
"attrsFormat": "keyValues" | ||
} | ||
}' | ||
|
||
``` | ||
REGEX(.*) | ||
``` | ||
|
||
# | ||
# 0003 Save subscription id | ||
# | ||
$id=$$ | ||
|
||
# | ||
# 0004 Get subscription | ||
# | ||
ngsi get subscription --id $id --pretty | ||
|
||
``` | ||
{ | ||
"id": "$id", | ||
"description": "Test Notification", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": "Alert.*", | ||
"type": "Alert" | ||
} | ||
], | ||
"condition": {} | ||
}, | ||
"notification": { | ||
"onlyChangedAttrs": false, | ||
"httpCustom": { | ||
"url": "http://dev/null", | ||
"headers": { | ||
"fiware-shared-key": "test" | ||
} | ||
}, | ||
"attrsFormat": "keyValues" | ||
}, | ||
"status": "active" | ||
} | ||
``` | ||
|
||
# | ||
# 0005 Get subscription --raw | ||
# | ||
ngsi get subscription --id $id --pretty --raw | ||
|
||
``` | ||
{ | ||
"id": "$id", | ||
"description": "Test Notification", | ||
"status": "active", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": "Alert.*", | ||
"type": "Alert" | ||
} | ||
], | ||
"condition": { | ||
"attrs": [] | ||
} | ||
}, | ||
"notification": { | ||
"attrs": [], | ||
"onlyChangedAttrs": false, | ||
"attrsFormat": "keyValues", | ||
"httpCustom": { | ||
"url": "http://dev/null", | ||
"headers": { | ||
"fiware-shared-key": "test" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
# | ||
# 0006 Update subscription (400 Bad Request) | ||
# | ||
ngsi update --host orion subscription --id $id \ | ||
--data '{ | ||
"description": "Test Notification", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": "Alert.*", | ||
"type": "Alert" | ||
} | ||
], | ||
"condition": { | ||
"attrs": [] | ||
} | ||
}, | ||
"notification": { | ||
"httpCustom": { | ||
"url": "http://dev/null", | ||
"headers": { | ||
"fiware-shared-key": "test" | ||
} | ||
}, | ||
"attrsFormat": "keyValues" | ||
} | ||
}' | ||
|
||
```1 | ||
subscriptionsUpdateV2005 400 Bad Request {"error":"BadRequest","description":"condition is empty"} $id | ||
``` | ||
|
||
# | ||
# 0007 Update subscription --raw | ||
# | ||
ngsi update --host orion subscription --id $id --raw \ | ||
--data '{ | ||
"description": "Test Notification", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": "Alert.*", | ||
"type": "Alert" | ||
} | ||
], | ||
"condition": { | ||
"attrs": [] | ||
} | ||
}, | ||
"notification": { | ||
"httpCustom": { | ||
"url": "http://dev/null", | ||
"headers": { | ||
"fiware-shared-key": "test" | ||
} | ||
}, | ||
"attrsFormat": "keyValues" | ||
} | ||
}' | ||
|
||
``` | ||
REGEX(.*) | ||
``` | ||
|
||
# | ||
# 9999 Delete subscription | ||
# | ||
ngsi delete --host orion subscription --id $id | ||
|
||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.