Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Feature/config groups #1198

Closed
wants to merge 4 commits into from

Conversation

Sunny-NEC
Copy link

Added code for iot/configGroups (#752)

@@ -13,3 +13,4 @@
- FIX: Remove preprocess stripping of explicitAttrs (#1151)
- FIX: NGSI-LD commands are invalid. (#1185)
- Upgrade logops dep from 2.1.0 to 2.1.2 due to colors dependency corruption
dd /iot/configGroups API endpoints (as equivalent to /iot/services) (#752)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dd seems to be a typo

@fgalan
Copy link
Member

fgalan commented Feb 7, 2022

Please solve the conflict in CHANGES_NEXT_RELEASE so unit tests can automatically run in your PR.

@fgalan
Copy link
Member

fgalan commented Feb 7, 2022

It seems this is the fifth incarnation of the cgroups PR:

Just in case it can be useful (mainly for taking into account all the potential feedback spreaded over them)

@@ -13,3 +13,4 @@
- FIX: Remove preprocess stripping of explicitAttrs (#1151)
- FIX: NGSI-LD commands are invalid. (#1185)
- Upgrade logops dep from 2.1.0 to 2.1.2 due to colors dependency corruption
dd /iot/configGroups API endpoints (as equivalent to /iot/services) (#752)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dd /iot/configGroups API endpoints (as equivalent to /iot/services) (#752)
Add /iot/configGroups API endpoints (as equivalent to /iot/services) (#752)

doc/api.md Outdated
Comment on lines 206 to 220
### Relationship between service groups and devices

Devices may be associated to exisiting service groups (or not) based in `apiKey` matching or `type` matching (in the
case `apiKey` matching fails). For instance, let's consider a situation in which a service group has been provisioned
with `type=X`/`apiKey=111` and no other service group has been provisioned.

- IoT Agent receives an anonymous measure with `apiKey=111`. The matching `apiKey` means the entity inherits from
service group. Device entity has `type=X` and `apiKey=111`
- IoT Agent receives a provisioning request for an explicit device of `type=Y`/`apiKey=111`. The matching `apiKey`
means the entity inherits from service group but type is overridden. Device entity has `type=Y` and `apiKey=111`
- IoT Agent receives a provisioning request for an explicit device of `type=X`/`apiKey=222`. The matching `type` means
the entity inherits from service group but `apiKey` is overridden. Device entity has `type=X` and `apiKey=222`.
- IoT Agent receives a provisioning request for an explicit device of `type=Y`/`apiKey=222`. No matching. Device
entity has `type=Y` and `apiKey=222` and no service group.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not included in PR #954

doc/api.md Outdated
Comment on lines 226 to 258
| Payload Field | DB Field | Definition | Example of value |
| --------------------- | -------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------- |
| `device_id` | `id` | Device ID that will be used to identify the device. | UO834IO |
| `service` | `service` | Name of the service the device belongs to (will be used in the fiware-service header). | smartGondor |
| `service_path` | `subservice` | Name of the subservice the device belongs to (used in the fiware-servicepath header). | /gardens |
| `entity_name` | `name` | Name of the entity representing the device in the Context Broker | ParkLamplight12 |
| `entity_type` | `type` | Type of the entity in the Context Broker | Lamplights |
| `timezone` | `timezone` | Time zone of the sensor if it has any | America/Santiago |
| `timestamp` | `timestamp` | Optional flag about whether or not to add the `TimeInstant` attribute to the device entity created, as well as a `TimeInstant` metadata to each attribute, with the current timestamp. With NGSI-LD, the Standard `observedAt` property-of-a-property is created instead. | true |
| `apikey` | `apikey` | Optional Apikey key string to use instead of group apikey | 9n4hb1vpwbjozzmw9f0flf9c2 |
| `endpoint` | `endpoint` | Endpoint where the device is going to receive commands, if any. | http://theDeviceUrl:1234/commands |
| `protocol` | `protocol` | Name of the device protocol, for its use with an IoT Manager. | IoTA-UL |
| `transport` | `transport` | Name of the device transport protocol, for the IoT Agents with multiple transport protocols. | MQTT |
| `attributes` | `active` | List of active attributes of the device | `[ { "name": "attr_name", "type": "Text" } ]` |
| `lazy` | `lazy` | List of lazy attributes of the device | `[ { "name": "attr_name", "type": "Text" } ]` |
| `commands` | `commands` | List of commands of the device | `[ { "name": "attr_name", "type": "Text" } ]` |
| `internal_attributes` | `internalAttributes` | List of internal attributes with free format for specific IoT Agent configuration | LWM2M mappings from object URIs to attributes |
| `static_attributes` | `staticAttributes` | List of static attributes to append to the entity. All the updateContext requests to the CB will have this set of attributes appended. | `[ { "name": "attr_name", "type": "Text" } ]` |
| `expressionLanguage` | `expresionLanguage` | optional boolean value, to set expression language used to compute expressions, possible values are: legacy or jexl. When not set or wrongly set, legacy is used as default value. |
| `explicitAttrs` | `explicitAttrs` | optional field to support selective ignore of measures so that IOTA doesn’t progress. See details in [specific section](advanced-topics.md#explicitly-defined-attributes-explicitattrs) | (see details in specific section) |
| `ngsiVersion` | `ngsiVersion` | optional string value used in mixed mode to switch between **NGSI-v2** and **NGSI-LD** payloads. The default is `v2`. When not running in mixed mode, this field is ignored. | `v2/ld` |
| Payload Field | DB Field | Definition | Example of value |
| --------------------- | -------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------- |
| `device_id` | `id` | Device ID that will be used to identify the device. | UO834IO |
| `service` | `service` | Name of the service the device belongs to (will be used in the fiware-service header). | smartGondor |
| `service_path` | `subservice` | Name of the subservice the device belongs to (used in the fiware-servicepath header). | /gardens |
| `entity_name` | `name` | Name of the entity representing the device in the Context Broker | ParkLamplight12 |
| `entity_type` | `type` | Type of the entity in the Context Broker | Lamplights |
| `timezone` | `timezone` | Time zone of the sensor if it has any | America/Santiago |
| `timestamp` | `timestamp` | Optional flag about whether or not to add the `TimeInstant` attribute to the device entity created, as well as a `TimeInstant` metadata to each attribute, with the current timestamp. With NGSI-LD, the Standard `observedAt` property-of-a-property is created instead. | true |
| `apikey` | `apikey` | Optional Apikey key string to use instead of group apikey | 9n4hb1vpwbjozzmw9f0flf9c2 |
| `endpoint` | `endpoint` | Endpoint where the device is going to receive commands, if any. | http://theDeviceUrl:1234/commands |
| `protocol` | `protocol` | Name of the device protocol, for its use with an IoT Manager. | IoTA-UL |
| `transport` | `transport` | Name of the device transport protocol, for the IoT Agents with multiple transport protocols. | MQTT |
| `attributes` | `active` | List of active attributes of the device | `[ { "name": "attr_name", "type": "Text" } ]` |
| `lazy` | `lazy` | List of lazy attributes of the device | `[ { "name": "attr_name", "type": "Text" } ]` |
| `commands` | `commands` | List of commands of the device | `[ { "name": "attr_name", "type": "Text" } ]` |
| `internal_attributes` | `internalAttributes` | List of internal attributes with free format for specific IoT Agent configuration | LWM2M mappings from object URIs to attributes |
| `static_attributes` | `staticAttributes` | List of static attributes to append to the entity. All the updateContext requests to the CB will have this set of attributes appended. | `[ { "name": "attr_name", "type": "Text" } ]` |
| `expressionLanguage` | `expresionLanguage` | optional boolean value, to set expression language used to compute expressions, possible values are: legacy or jexl. When not set or wrongly set, legacy is used as default value. |
| `explicitAttrs` | `explicitAttrs` | Boolean value to support selective ignore of measures for device so that IOTA doesn’t progress. If not specified default is `false`. | `true/false` |
| `ngsiVersion` | `ngsiVersion` | optional string value used in mixed mode to switch between **NGSI-v2** and **NGSI-LD** payloads. The default is `v2`. When not running in mixed mode, this field is ignored. | `v2/ld` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not included in PR #954

@@ -31,7 +31,6 @@ const domainUtils = require('../common/domain');
const middlewares = require('../common/genericMiddleware');
const intoTrans = domainUtils.intoTrans;
const deviceProvisioning = require('./deviceProvisioningServer');
const deviceUpdating = require('./deviceProvisioningServer');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not included in PR #954

Could you elaborate why is included here?

@@ -117,7 +117,6 @@ exports.setNotificationHandler = intoTrans(context, contextServer.setNotificatio
exports.setConfigurationHandler = intoTrans(context, groupProvisioning.setConfigurationHandler);
exports.setRemoveConfigurationHandler = intoTrans(context, groupProvisioning.setRemoveConfigurationHandler);
exports.setProvisioningHandler = intoTrans(context, deviceProvisioning.setProvisioningHandler);
exports.setUpdatingHandler = intoTrans(context, deviceUpdating.setUpdatingHandler);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not included in PR #954

Could you elaborate why is included here?

Comment on lines 151 to 150
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '')
.delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes were not included in PR #954. Could you elaborate why are included here?

const utils = require('../../../tools/utils');
const should = require('should');
const nock = require('nock');
const request = require('request');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request dependency should be used as included in this PR #1119

const should = require('should');
const nock = require('nock');
let contextBrokerMock;
const request = require('request');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request dependency should be used as included in this PR #1119

Comment on lines 232 to 241
it('should return the existing device', function (done) {
iotAgentLib.retrieveDevice('Light1', '801230BJKL23Y9090DSFL123HJK09H324HV8732', function (error, device) {
should.not.exist(error);
should.exist(device);

device.id.should.equal('Light1');
done();
});
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes were not included in PR #954. Could you elaborate why are included here?

const _ = require('underscore');
const utils = require('../../tools/utils');
const async = require('async');
const request = require('request');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request dependency should be used as included in this PR #1119

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be9e2b8
@mapedraza please review this commit . I did all the required changes.

@mapedraza
Copy link
Collaborator

Additionally to the comments on the code, this PR changes 20 files, in opposite to previous PR #954 which modifies 31 files. Some of them are related with NGSIv1 tests but not all of them. Could you elaborate why?

The files not covered in this PR but with changes in 954 and are not NGSv1 related are:

  • lib/fiware-iotagent-lib.js
  • test/unit/ngsiv2/provisioning/device-provisioning-api_test.js (please add the comment, could be useful)
  • test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js (please add the comment, could be useful)

@mapedraza
Copy link
Collaborator

overpassed by #1375 (comment)

@mapedraza mapedraza closed this Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants