Skip to content

Latest commit

 

History

History
170 lines (161 loc) · 3.48 KB

SubscriptionsFunctions.md

File metadata and controls

170 lines (161 loc) · 3.48 KB

Subscriptions Functions


Indéx navigation

Read Functions.

Headers

For the examples we will use the next JSON as headers

var headers = {
    'Fiware-Correlator': '3451e5c2-226d-11e6-aaf0-d48564c29d20'
}

But you can use another options,one empty JSON or you can ignore the headers if you don't need them

Get Subscriptions.

Example

cb.listSubscriptions(headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))

Get Subscription.

Example

cb.getSubscription("5a83c5463fc4dec59e4ef8e2", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))

Create Functions.

Create Subscription.

Example

cb.createSubscription({
	"description": "Alert subscription TEST",
	"subject": {
	"entities": [
  		{
			"idPattern": ".*",
			"type": "Alert"
		}
	],
	"condition": {
		"attrs": [
  			"id",	
  			"type",
  			"category",
  			"subCategory",
  			"location",
  			"address",
  			"dateObserved",
  			"validFrom",
  			"validTo",
  			"description",
  			"alertSource",
  			"data",
  			"severity"
		]
		}
	},
	"notification": {
  		"attrs": [
  			"id",  
          	"type",
            "category",
            "subCategory",
            "location",
            "address",
            "dateObserved",
            "validFrom",
            "validTo",
            "description",
            "alertSource",
            "data",
            "severity"
        ],
		"attrsFormat": "normalized",
		"http": {
			"url": "http://service.mx"
		}
	},
	"throttling": 5
}, headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))

Update Functions.

Update Subscription

Example

cb.updateSubscription("5a93a9063fc4dec59e4ef8eb", {
	"description": "Alert subscription TEST",
	"subject": {
	"entities": [
  		{
			"idPattern": ".*",
			"type": "Alert"
		}
	],
	"condition": {
		"attrs": [
  			"id",	
  			"type",
  			"location",
  			"address",
  			"dateObserved",
  			"validFrom",
  			"validTo",
  			"description",
		]
		}
	},
	"notification": {
  		"attrs": [
  			"id",  
          	"type",
            "category",
            "subCategory",
            "location",
            "address",
            "dateObserved",
            "validFrom",
            "validTo",
            "description",
            "alertSource",
            "data",
            "severity"
        ],
		"attrsFormat": "normalized",
		"http": {
			"url": "http://crateservice.com"
		}
	},
	"throttling": 5
}, headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))

Update Subscription Status.

Example

cb.updateSubscriptionStatus("5a81e50a3fc4dec59e4ef8dc", "active", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))

Delete Functions.

##Delete Subscription.

Example

cb.deleteSubscription("5a93a9103fc4dec59e4ef8ec", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))