createGroup method
Creates a new user device group.
Creates a new group with the available
parameters and allows for metadata
storage in the type
parameter.
Implementation
Future<void> createGroup(String groupName,
[String? parentGroupId, String? type, List<String>? nodeIds]) async {
final uri = _urlBase.getPath(_devGroupBase);
final body = await JsonIsolate().encodeJson({
'group_name': groupName,
'parent_group_id': parentGroupId,
'type': type,
'nodes': nodeIds,
});
final resp = await post(uri, body: body, headers: {
URLBase.authHeader: accessToken,
});
final Map<String, dynamic> bodyResp =
await JsonIsolate().decodeJson(resp.body);
if (resp.statusCode != 200) {
throw bodyResp['description'];
}
}