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

feat/add-mAttachTenant #31

Merged
merged 36 commits into from
Mar 16, 2021
Merged

feat/add-mAttachTenant #31

merged 36 commits into from
Mar 16, 2021

Conversation

rolljee
Copy link
Contributor

@rolljee rolljee commented Mar 2, 2021

Add mAttachTenant methods

@rolljee
Copy link
Contributor Author

rolljee commented Mar 3, 2021

My bad, I forgot to write the documentation

@rolljee rolljee marked this pull request as draft March 3, 2021 08:15
@rolljee rolljee marked this pull request as ready for review March 3, 2021 09:39
doc/1/controllers/sensor/mattach-tenant/index.md Outdated Show resolved Hide resolved
features/SensorController.feature Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Aschen Aschen left a comment

Choose a reason for hiding this comment

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

The import action should returns the list of success and errors to allows the users to act accordingly and modify the input.

For example if every sensors cannot be attached to tenants for some reason, the one who could should still be attached and proper response should be sent to user.

This will allows to import a CSV, having some sensor attached but errors with others, correct the errors lines and re-import the same CSV to import the corrected lines.
Trying to re-attach a sensor to the same tenant should then not be considered as an error.

Finally, a strict option could be interesting to throw an error if any of the line contains an error (the errors must be checked before import)

You can look at omniscient code for an example:

features/SensorController.feature Outdated Show resolved Hide resolved
features/SensorController.feature Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
doc/1/controllers/sensor/mattach-tenant/index.md Outdated Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
lib/services/SensorService.ts Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
lib/controllers/SensorController.ts Outdated Show resolved Hide resolved
@Leodau Leodau linked an issue Mar 4, 2021 that may be closed by this pull request
@rolljee rolljee mentioned this pull request Mar 4, 2021
3 tasks
lib/controllers/SensorController.ts Show resolved Hide resolved
lib/controllers/SensorController.ts Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
lib/types/SensorContent.ts Outdated Show resolved Hide resolved
lib/services/SensorService.ts Outdated Show resolved Hide resolved
@rolljee rolljee requested a review from Aschen March 9, 2021 08:21
Copy link
Contributor

@Aschen Aschen left a comment

Choose a reason for hiding this comment

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

Can you add a Laius about the format ? Users will be interested to know that they can use CSV for example (it's a very bankable feature in avv)

@@ -110,6 +110,12 @@ Sensors can be attached to tenant by using the [device-manager/sensor:attach](/k

When attached, the sensor document is copied inside the `sensors` collection of the tenant index.

## Attach to multiple tenant

Multiple differents Sensors can also be attached to multiple defferents tenant by using the [device-manager/sensor:attach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/mattach-tenant) API action.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Multiple differents Sensors can also be attached to multiple defferents tenant by using the [device-manager/sensor:attach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/mattach-tenant) API action.
Multiple different Sensors can also be attached to multiple different tenant by using the [device-manager/sensor:mAttach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/m-attach-tenant) API action.

The file name must be changed accordingly

'sensors',
sensor._id,
{ assetId });
const writeMany = async (start: number, end: number) => {
Copy link
Contributor

@Aschen Aschen Mar 9, 2021

Choose a reason for hiding this comment

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

Very clever design 👍

@rolljee rolljee requested review from Aschen and Leodau March 10, 2021 08:57
Copy link
Contributor

@Aschen Aschen left a comment

Choose a reason for hiding this comment

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

Last change and LGTM 👍

@@ -112,9 +112,11 @@ When attached, the sensor document is copied inside the `sensors` collection of

## Attach to multiple tenant

Multiple differents Sensors can also be attached to multiple defferents tenant by using the [device-manager/sensor:attach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/mattach-tenant) API action.
Multiple different Sensors can also be attached to multiple defferents tenant by using the [device-manager/sensor:mAttach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/mAttach) API action.
Copy link
Contributor

Choose a reason for hiding this comment

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

File name should be in kebab-case (while API action is in camelCase)

Suggested change
Multiple different Sensors can also be attached to multiple defferents tenant by using the [device-manager/sensor:mAttach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/mAttach) API action.
Multiple different Sensors can also be attached to multiple defferents tenant by using the [device-manager/sensor:mAttach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/m-attach) API action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update files accordingly 👍

doc/1/controllers/sensor/m-attach/index.md Outdated Show resolved Hide resolved
doc/1/controllers/sensor/m-attach/index.md Outdated Show resolved Hide resolved
doc/1/controllers/sensor/m-attach/index.md Outdated Show resolved Hide resolved
@@ -41,6 +45,10 @@ export class SensorController extends CRUDController {
handler: this.attachTenant.bind(this),
http: [{ verb: 'put', path: 'device-manager/:index/sensors/:_id/_attach' }]
},
mAttachTenant: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, the action name is mAttach or mAttachTenant at the end ? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stick to mAttach, sorry about that

doc/1/controllers/sensor/m-attach/index.md Outdated Show resolved Hide resolved
@Aschen
Copy link
Contributor

Aschen commented Mar 10, 2021

LGTM 👍

@Aschen Aschen merged commit 144a8fd into 1-dev Mar 16, 2021
@Aschen Aschen deleted the feat/add-m-attach-tenant branch March 16, 2021 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bulk API actions
3 participants