Skip to content

[DESIGN] Tags introduction [IOT-1359] #48

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

Merged
merged 9 commits into from
Oct 21, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions designs/0002-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Introduction of tags for device and thing

## Review Period

Best before October, 18 2021.

## What is the problem?
We need to design the commands to **handle tags** for things and devices. Tags could be attached and detached to/from any thing or device. Also, certain commands could take tags as input in order to perform operations on multiple things/devices.

## Out-of-Scope

## User Experience Walkthrough


## Implementation

### Project Changes

Commands that could regard multiple things or devices could be changed in order to accept tags.

These commands can be:

**list commands**:

`thing list --tag <key0>=<value0>,<key1>=<value1>` to list all the things having all the tags passed

`device list --tag <key0>=<value0>,<key1>=<value1>` to list all the devices having all the tags passed

alternative: `--filter` instead of `--tag`


**delete commands**:

`thing delete --tag <key0>=<value0>,<key1>=<value1>` to delete all the things having all the tags passed

`device delete --tag <key0>=<value0>,<key1>=<value1>` to delete all the devices having all the tags passed


**ota command**:

`ota upload --device-tag <key0>=<value0>,<key1>=<value1> --file <sketch-file.ino.bin>` to perform an upload via ota to all the devices having all the tags passed


To be decided, **which flag is mandatory and which is optional**:
In delete and ota commands, the `--id` flag should become **optional** instead of mandatory.
Then, if neither `--id` nor `--tag` is passed, the command could return an error telling the user to specify at least one of the two flags.
On the other hand, if both flags are passed, we could follow different approaches: return an error, use only one flag (only tags or only id), try to use both flags.

Another thing to be decided is **how to handle errors**:
- Try to execute the command on all the indicated resources, without stopping in case of errors. At the end, print all the errors details.
- Stop as soon as an error is encountered.

### Breaking Change

The changes listed above should not break anything, the commands could be used as before.

### Design

New commands should be introduced in order to add and delete tags to devices and things. Here are some alternatives:

Implementing a tag command:
`arduino-cloud-cli tag create --thing <thingID> --tags <key0>=<value0>,<key1>=<value1>`

Adding a tag subcommand in device and thing commands:
`arduino-cloud-cli thing create-tags --thing <thingID> --tags <key0>=<value0>,<key1>=<value1>` and same for device


### Documentation Changes

Readme should be updated

## Additional Notes

https://arduino.atlassian.net/jira/software/projects/IOT/boards/277?selectedIssue=IOT-1359