@@ -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 }
0 commit comments