Skip to content

Commit 1b92a04

Browse files
committed
update device groups
1 parent 2bc6d78 commit 1b92a04

File tree

1 file changed

+155
-1
lines changed

1 file changed

+155
-1
lines changed

articles/iot-central/core/howto-manage-devices-with-rest-api.md

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ The response to this request looks like the following example:
194194
}
195195
```
196196

197-
### List device groups
197+
### List device groups [1.1-preview]
198198

199199
Use the following request to retrieve a list of device groups from your application:
200200

@@ -231,6 +231,160 @@ The response to this request looks like the following example:
231231

232232
The organizations field is only used when an application has an organization hierarchy defined. To learn more about organizations, see [Manage IoT Central organizations](howto-edit-device-template.md)
233233

234+
## Device Groups
235+
236+
### Add a device group
237+
238+
Use the following request to create a new device group.
239+
240+
```http
241+
PUT https://{subdomain}.{baseDomain}/api/deviceGroups/{deviceGroupId}?api-version=1.2-preview
242+
```
243+
244+
The following example shows a request body that adds a device group.
245+
246+
```json
247+
{
248+
"displayName": "Device group 1",
249+
"description": "Custom device group.",
250+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
251+
"organizations": [
252+
"seattle"
253+
]
254+
}
255+
```
256+
257+
The request body has some required fields:
258+
259+
* `@displayName`: Display name of the device group.
260+
* `@filter`: Query defining which devices should be in this group.
261+
* `@etag`: ETag used to prevent conflict in device updates.
262+
* `description`: Short summary of device group.
263+
* `organizations` : List of organization IDs of the device group.
264+
265+
The response to this request looks like the following example:
266+
267+
```json
268+
{
269+
"id": "group1",
270+
"displayName": "Device group 1",
271+
"description": "Custom device group.",
272+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
273+
"organizations": [
274+
"seattle"
275+
]
276+
}
277+
```
278+
279+
### Get a device group
280+
281+
Use the following request to retrieve details of a device group from your application:
282+
283+
```http
284+
GET https://{subdomain}.{baseDomain}/api/deviceGroups/{deviceGroupId}?api-version=1.2-preview
285+
```
286+
287+
* deviceGroupId - Unique ID for the device group.
288+
289+
The response to this request looks like the following example:
290+
291+
```json
292+
{
293+
"id": "475cad48-b7ff-4a09-b51e-1a9021385453",
294+
"displayName": "DeviceGroupEntry1",
295+
"description": "This is a default device group containing all the devices for this particular Device Template.",
296+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
297+
"organizations": [
298+
"seattle"
299+
]
300+
}
301+
```
302+
303+
### Update a device group
304+
305+
```http
306+
PATCH https://{subdomain}.{baseDomain}/api/deviceGroups/{deviceGroupId}?api-version=1.2-preview
307+
```
308+
309+
The sample request body looks like the following example which updates the `displayName` of the device group:
310+
311+
```json
312+
{
313+
"displayName": "New group name"
314+
}
315+
316+
```
317+
318+
The response to this request looks like the following example:
319+
320+
```json
321+
{
322+
"id": "group1",
323+
"displayName": "New group name",
324+
"description": "Custom device group.",
325+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
326+
"organizations": [
327+
"seattle"
328+
]
329+
}
330+
```
331+
332+
### Delete a device group
333+
334+
Use the following request to delete a device group:
335+
336+
```http
337+
DELETE https://{subdomain}.{baseDomain}/api/deviceGroups/{deviceGroupId}?api-version=1.2-preview
338+
```
339+
340+
### List device groups
341+
342+
Use the following request to retrieve a list of device groups from your application:
343+
344+
```http
345+
GET https://{subdomain}.{baseDomain}/api/deviceGroups?api-version=1.2-preview
346+
```
347+
348+
The response to this request looks like the following example:
349+
350+
```json
351+
{
352+
"value": [
353+
{
354+
"id": "475cad48-b7ff-4a09-b51e-1a9021385453",
355+
"displayName": "DeviceGroupEntry1",
356+
"description": "This is a default device group containing all the devices for this particular Device Template.",
357+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:dtdlv2\" AND $provisioned = true",
358+
"organizations": [
359+
"seattle"
360+
]
361+
},
362+
{
363+
"id": "c2d5ae1d-2cb7-4f58-bf44-5e816aba0a0e",
364+
"displayName": "DeviceGroupEntry2",
365+
"description": "This is a default device group containing all the devices for this particular Device Template.",
366+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:model1\"",
367+
"organizations": [
368+
"redmond"
369+
]
370+
},
371+
{
372+
"id": "241ad72b-32aa-4216-aabe-91b240582c8d",
373+
"displayName": "DeviceGroupEntry3",
374+
"description": "This is a default device group containing all the devices for this particular Device Template.",
375+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:model2\" AND $simulated = true"
376+
},
377+
{
378+
"id": "group4",
379+
"displayName": "DeviceGroupEntry4",
380+
"description": "This is a default device group containing all the devices for this particular Device Template.",
381+
"filter": "SELECT * FROM devices WHERE $template = \"dtmi:modelDefinition:model3\""
382+
}
383+
]
384+
}
385+
```
386+
387+
234388
### Use ODATA filters
235389

236390
You can use ODATA filters to filter the results returned by the list devices API.

0 commit comments

Comments
 (0)