forked from openconnectivityfoundation/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.raml
executable file
·256 lines (231 loc) · 9.89 KB
/
rules.raml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#%RAML 0.8
title: Rules
version: v1-20160622
documentation:
- title: OCF Copyright
content: Copyright (c) 2016 Open Connectivity Foundation, Inc. All rights reserved.
- title: OCF License
content: !include LICENSE.md
- title: OCF Disclaimer
content: !include DISCLAIMER.md
schemas:
- Collection: !include schemas/oic.collection-schema.json
- Rule: !include schemas/oic.rule-schema.json
- RuleUpdate: !include schemas/oic.rule-Update-schema.json
- RuleMember: !include schemas/oic.ruleMember-schema.json
traits:
- interface:
queryParameters:
if:
enum: ["oic.if.a", "oic.if.ll", "oic.if.baseline"]
/RuleListResURI:
description: |
Toplevel Rule resource.
This resource is a generic collection resource
The rts value shall contain oic.wk.rule resource types
displayName: Rules (Top level)
get:
description: |
Provides the current list of web links pointing to rules
responses:
200:
body:
application/json:
schema: Collection
example: |
{
"rt": "oic.wk.ruleList",
"n": "list of rules",
"rts": "oic.wk.rule",
"links": [
]
}
post:
description: |
Provides the action to create a new rule in the ruleList resource
The only resource type that is allowed to be created "oic.wk.rule".
The example contains a condition, currentStatus and test.
body:
application/json:
schema: Rule
example: |
{
"condition": "(FFFAB960-736F-46F7-BEC0-9E6CBD671ADC1:binaryswitchid:value = true) and (FFFFB960-736F-46F7-BEC0-9E6CBD671FFFF:tempid:temperature > 30)",
"currentStatus": "off",
"test": false,
"rt": "oic.wk.rule",
"n": "my first rule",
"id": "my_rule1",
"rts": "oic.r.ruleMember",
"links": [
]
}
responses:
200:
description: |
Indicates that the target resource was created.
The created resource attributes are provided in the response,
including the server generated identifier.
body:
application/json:
schema: Rule
example: |
{
"condition": "(FFFAB960-736F-46F7-BEC0-9E6CBD671ADC1:binaryswitchid:value == true) and (FFFFB960-736F-46F7-BEC0-9E6CBD671FFFF:tempid:temperature > 30)",
"currentStatus": "off",
"test": false,
"rt": "oic.wk.rule",
"n": "my first rule",
"id": "FFFFB960-736F-46F7-BEC0-9E6CBD671ADC1" ,
"rts": "oic.r.ruleMember",
"links": [
]
}
delete:
description: |
No change from collection.
When delete is used with the URI of the collection without and query parameters then the entire collection is deleted
When the delete uses the "ins" parameter with the value of a specific link then only that link is deleted
queryParameters:
ins:
type: string
description: |
Delete the Web link identified by the string - could be a UUID.
required: false
example: |
DELETE /mycollection?ins="FFFFB960-736F-46F7-BEC0-9E6CBD671ADC1"
responses:
200:
description: The web link instance or the the entire collection has been successfully deleted
400:
description: The request is invalid
/RuleResURI:
description: |
Collection that models a rule.
This resource is an generic collection resource with additional parameters.
The rts value shall contain oic.wk.ruleMember resource types.
The additional parameters are
condition, this is the rule that will be evaluated
currentStatus, the current state of the rule, can be "enabled, disabled, error"
test an trigger once activation of the rule
displayName: Rule
get:
description: |
Provides the current rule and list of web links to the rule members
responses:
200:
body:
application/json:
schema: Rule
example: |
{
"condition": "(FFFAB960-736F-46F7-BEC0-9E6CBD671ADC1:binaryswitchid:value == true) and (FFFFB960-736F-46F7-BEC0-9E6CBD671FFFF:tempid:temperature > 30)",
"currentStatus": "disabled",
"test": false,
"rt": "oic.wk.rule",
"n": "my first rule",
"id": "FFFFB960-736F-46F7-BEC0-9E6CBD671ADC1",
"rts": "oic.r.ruleMember",
"links": [
]
}
put:
description: |
Provides the action to enable/disable the rule and an test mode for the rule.
Calling this method with test = true will update of all ruleMembers to the prescribed membervalue.
body:
application/json:
schema: RuleUpdate
example: |
{
"currentStatus": "enabled"
}
responses:
200:
description: |
Indicates that the value is changed.
The changed properties are provided in the response.
body:
application/json:
schema: RuleUpdate
example: |
{
"currentStatus": "enabled"
}
post:
description: |
Provides the action to create a new ruleMember in the rule resource
The only resource type that is allowed to be created is "oic.wk.ruleMember".
The id of the resource will be generated by the implementation.
body:
application/json:
schema: RuleMember
example: |
{
"link": { "href":"coap://mydevice/mybinaryswitch",
"if": "oic.if.a",
"rt": "oic.r.switch.binary" },
"id": "",
"n": "my binary switch (for light bulb) mappings",
"memberProperty": "value",
"memberValue": true
}
responses:
200:
description: |
Indicates that the target resource was created.
The new resource attributes are provided in the response.
body:
application/json:
schema: RuleMember
example: |
{
"id": "FFFFB960-FFFF-46F7-BEC0-9E6234671ADC1",
"n": "my binary switch (for light bulb) mappings",
"link": { "href":"coap://mydevice/mybinaryswitch",
"if": "oic.if.a",
"rt": "oic.r.switch.binary" },
"memberProperty": "value",
"memberValue": true
}
delete:
description: |
No change from collection.
When delete is used with the URI of the collection without and query parameters then the entire collection is deleted
When the delete uses the "ins" parameter with the value of a specific link then only that link is deleted
queryParameters:
ins:
type: string
description: |
Delete the Web link identified by the string - could be a UUID.
required: false
example: |
DELETE /mycollection?ins="FFFFB960-FFFF-46F7-BEC0-9E6234671ADC1"
responses:
200:
description: The web link instance or the the entire collection has been successfully deleted
400:
description: The request is invalid
/RuleMemberResURI:
description: |
Rule member resource.
This resource is assignment statement of an property in a resource indicated by an URI
displayName: Rule Member
get:
description: |
Provides the rule mappings
responses:
200:
body:
application/json:
schema: RuleMember
example: |
{
"id": "FFFFB960-FFFF-46F7-BEC0-9E6234671ADC1",
"n": "my binary switch (for light bulb) mappings",
"link": { "href":"coap://mydevice/mybinaryswitch",
"if": "oic.if.a",
"rt": "oic.r.switch.binary" },
"memberProperty": "value",
"memberValue": true
}