Skip to content

Commit 84d4b2d

Browse files
author
Pavel Petroshenko
authored
Merge pull request #21 from electricimp/develop
v1.4.0
2 parents 92a8bd8 + b7187d6 commit 84d4b2d

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

lib/DeviceGroups.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class DeviceGroups extends Entities {
4343
};
4444
this._validCreateAttributes = {
4545
name : true,
46-
description : false
46+
description : false,
47+
region : false
4748
};
4849
this._validUpdateAttributes = {
4950
name : true,
@@ -141,6 +142,9 @@ class DeviceGroups extends Entities {
141142
// this must be unique for all DeviceGroups in this Product
142143
// 'description' (String, optional) - an optional free-form
143144
// description of the Device Group
145+
// 'region' (String, optional) - a Device Group's region,
146+
// May be specified if the new Device Group is of the production
147+
// or pre_production type only
144148
// productionTarget : Optional production_target relationship of the Device Group to be
145149
// Object created. Must be specified for pre_factoryfixture and factoryfixture device groups.
146150
// The valid keys are:
@@ -152,9 +156,17 @@ class DeviceGroups extends Entities {
152156
// Returns: Promise that resolves when the Device Group is successfully created,
153157
// or rejects with an error
154158
create(productId, type, attributes, productionTarget = null) {
155-
const error = ParamsChecker.validateNonEmpty(productId) ||
159+
let error = ParamsChecker.validateNonEmpty(productId) ||
156160
DeviceGroups.validateType(type, 'type') ||
157161
this._validateProductionTarget(type, productionTarget, true);
162+
if (!error && 'region' in attributes &&
163+
!(type == DeviceGroups.TYPE_PRE_PRODUCTION || type == DeviceGroups.TYPE_PRODUCTION)) {
164+
error = new Errors.InvalidDataError(
165+
Util.format(
166+
'region may be specified for "%s" or "%s" device groups only',
167+
DeviceGroups.TYPE_PRE_PRODUCTION,
168+
DeviceGroups.TYPE_PRODUCTION));
169+
}
158170
if (error) {
159171
return Promise.reject(error);
160172
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imp-central-api",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "Electric Imp impCentral API v5 Client",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)