-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
143 lines (124 loc) · 4.25 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
var cb = require("./lib/OCB");
var headers = {
'Fiware-Correlator': '3451e5c2-226d-11e6-aaf0-d48564c29d20'
}
var urlContextBroker = "http://35.185.120.11:1026/v2"; // Está mal no necesita ultima /
cb.config(urlContextBroker, headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))
/*
cb.retrieveAPIResources(headers)
.then((result) => console.log(result))
.catch((err) => console.log(err)) // Esta mal domcumentación no pone =>
cb.getEntityType("Device")
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.getEntityTypes(headers)
.then((result) => console.dir(result))
.catch((err) => console.log(err))
*/
/*
cb.getEntityAttributeValue("UserContext:User_33", "location", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.getEntityAttribute("UserContext:User_33", "location", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.getEntityAttrs("UserContext:User_33", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.getEntity("UserContext:User_33", headers)
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.getEntityListType("UserContext", headers)
.then((entities) => {console.log(entities)})
.catch((err) => console.log(err))
cb.listEntities(headers)
.then((entities) => {console.log(entities)})
.catch((err) => console.log(err))
*/
/*cb.createEntity({
"id": "Room6",
"temperature": {
"metadata": {
"accuracy": {
"type": "Number",
"value": 0.8
}
},
"type": "Number",
"value": 26.5
},
"type": "Room"
}).then((result) => console.log(result))
.catch((err) => console.log(err))
*/
/*
cb.updateEntityAttributeValue('Room1', 'temperature', 16)
.then((result) => {console.log(result)})
.catch((err) => console.log(err))
cb.updateJSONAttrEntity('Room1', 'temperature', {
"type": "Number",
"value": 34.982398
})
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.addJSONAttributeToEntity("Room1",{
"pressure":{
"value": 90,
"type": "Integer"
}
})
.then((result) => console.log(result))
.catch((err) => console.log(err))
*/
/*
cb.deleteEntity("Room1")
.then((result) => console.log(result))
.catch((err) => console.log(err))
cb.deleteEntityAttribute("Room1", "pressure")
.then((result) => console.log(result))
.catch((err) => console.log(err))
*/
//let query = "?id=.*&type=Device&georel=coveredBy&q=owner==Idowner&geometry=polygon&coords=18.879751306118546,-99.22197723761204;18.87991373199594,-99.22199869528413;18.87996449005033,-99.22190750017762;18.879984793267777,-99.2218270339072;18.879939111025056,-99.22174656763676;18.879893428769883,-99.22165537253022;18.87973100287282,-99.22145152464509;18.8795888800837,-99.22130132094026;18.879390923140832,-99.221076015383;18.87928940666914,-99.22097945585847;18.87893917436966,-99.22117793932557;18.87856356210443,-99.22121012583375;18.878675230703656,-99.22134960070255;18.878776747547473,-99.22145152464509;18.87888841600463,-99.22154808416965;18.87903053938793,-99.22144079580903;18.879203117619838,-99.22140860930085;18.87936554402868,-99.22153199091554;18.87948228791276,-99.22165537253022;18.879614259162025,-99.22181630507114;18.879751306118546,-99.22197723761204&options=keyValues";
//let query = "?id=Device_Smartphone_.*&type=Device&options=count";
/*let query = "?id=^Room[2-5]*&options=keyValues";
cb.getWithQuery(query, headers)
.then((result) => {
if (result.body.length < 1){
console.log("No entities found")
}
else{
console.log(result.body)
console.log(result.headers._headers);
}
})
.catch((err) => console.log(err))
*/
cb.createSubscription({
"description": "Alert subscription to QuantumLeap",
"expires": "2040-01-01T14:00:00.00Z",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "Alert"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"attrs": [],
"attrsFormat": "normalized",
"http": {
"url": "http://192.168.191.134:8668/v2/notify"
},
"metadata": [
"dateCreated",
"dateModified"
]
}
})
.then(console.log)