Mainflux.mainflux/cli
Manuel Imperiale 09cbc3f14b
MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558)
* MF-1551 - Fix Cobra usage commands and clean unnecessary struct types

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Use linux syntax for cmd usage description

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix typo

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix cmd.Use

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2022-02-11 13:22:57 +01:00
..
README.md NOISSUE - Add API keys functions to CLI (#1537) 2022-01-27 15:42:31 +01:00
bootstrap.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
certs.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
channels.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
config.go MF 1413 - Use per-service URL in SDK (#1444) 2021-08-11 16:58:10 +02:00
groups.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
health.go MF-1308 - Use IETF Health Check standard (#1541) 2022-01-24 21:18:53 +01:00
keys.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
message.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
provision.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
sdk.go MF-1190 - Add pkg for library packages (#1191) 2020-06-03 15:16:19 +02:00
things.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
users.go MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) 2022-02-11 13:22:57 +01:00
utils.go NOISSUE - Revert cli to use user token from command args (#1339) 2021-01-28 11:29:32 +01:00

README.md

Mainflux CLI

Build

From the project root:

make cli

Usage

Service

Get Mainflux Things services Health Check

mainflux-cli health

Users management

Create User

mainflux-cli users create <user_email> <user_password>

Login User

mainflux-cli users token <user_email> <user_password>

Retrieve User

mainflux-cli users get <user_auth_token>

Update User Metadata

mainflux-cli users update '{"key1":"value1", "key2":"value2"}' <user_auth_token>

Update User Password

mainflux-cli users password <old_password> <password> <user_auth_token>

System Provisioning

Create Thing

mainflux-cli things create '{"name":"myThing"}' <user_auth_token>

Create Thing with metadata

mainflux-cli things create '{"name":"myThing", "metadata": {\"key1\":\"value1\"}}' <user_auth_token>

Bulk Provision Things

mainflux-cli provision things <file> <user_auth_token>
  • file - A CSV or JSON file containing things
  • user_auth_token - A valid user auth token for the current system

Update Thing

mainflux-cli things update '{"id":"<thing_id>", "name":"myNewName"}' <user_auth_token>

Remove Thing

mainflux-cli things delete <thing_id> <user_auth_token>

Retrieve a subset list of provisioned Things

mainflux-cli things get all --offset=1 --limit=5 <user_auth_token>

Retrieve Thing By ID

mainflux-cli things get <thing_id> <user_auth_token>

Create Channel

mainflux-cli channels create '{"name":"myChannel"}' <user_auth_token>

Bulk Provision Channels

mainflux-cli provision channels <file> <user_auth_token>
  • file - A CSV or JSON file containing channels
  • user_auth_token - A valid user auth token for the current system

Update Channel

mainflux-cli channels update '{"id":"<channel_id>","name":"myNewName"}' <user_auth_token>

Remove Channel

mainflux-cli channels delete <channel_id> <user_auth_token>

Retrieve a subset list of provisioned Channels

mainflux-cli channels get all --offset=1 --limit=5 <user_auth_token>

Retrieve Channel By ID

mainflux-cli channels get <channel_id> <user_auth_token>

Access control

Connect Thing to Channel

mainflux-cli things connect <thing_id> <channel_id> <user_auth_token>

Bulk Connect Things to Channels

mainflux-cli provision connect <file> <user_auth_token>
  • file - A CSV or JSON file containing thing and channel ids
  • user_auth_token - A valid user auth token for the current system

An example CSV file might be

<thing_id>,<channel_id>
<thing_id>,<channel_id>

in which the first column is thing IDs and the second column is channel IDs. A connection will be created for each thing to each channel. This example would result in 4 connections being created.

A comparable JSON file would be

{
    "thing_ids": [
        "<thing_id>",
        "<thing_id>"
    ],
    "channel_ids": [
        "<channel_id>",
        "<channel_id>"
    ]
}

Disconnect Thing from Channel

mainflux-cli things disconnect <thing_id> <channel_id> <user_auth_token>

Retrieve a subset list of Channels connected to Thing

mainflux-cli things connections <thing_id> <user_auth_token>

Retrieve a subset list of Things connected to Channel

mainflux-cli channels connections <channel_id> <user_auth_token>

Messaging

Send a message over HTTP

mainflux-cli messages send <channel_id> '[{"bn":"Dev1","n":"temp","v":20}, {"n":"hum","v":40}, {"bn":"Dev2", "n":"temp","v":20}, {"n":"hum","v":40}]' <thing_auth_token>

Read messages over HTTP

mainflux-cli messages read <channel_id> <thing_auth_token>

Bootstrap

Add configuration

mainflux-cli bootstrap add '{"external_id": "myExtID", "external_key": "myExtKey", "name": "myName", "content": "myContent"}' <user_auth_token>

View configuration

mainflux-cli bootstrap view <thing_id> <user_auth_token>

Update configuration

mainflux-cli bootstrap update '{"MFThing":"<thing_id>", "name": "newName", "content": "newContent"}' <user_auth_token>

Remove configuration

mainflux-cli bootstrap remove <thing_id> <user_auth_token>

Bootstrap configuration

mainflux-cli bootstrap bootstrap <external_id> <external_key>

Groups

Create new group

mainflux-cli groups create '{"name":"<group_name>","parent_id":"<parent_group_id>","description":"<description>","metadata":{"key":"value",...}}' <user_auth_token>

Delete group

mainflux-cli groups delete <group_id> <user_auth_token>

Get group with id

mainflux-cli groups get <group_id> <user_auth_token>

List all groups

mainflux-cli groups get all <user_auth_token>

List children groups for some group

mainflux-cli groups get children <parent_group_id> <user_auth_token>

Assign user to a group

mainflux-cli groups assign <user_id> <group_id> <user_auth_token>

Unassign user from group

mainflux-cli groups unassign <user_id> <group_id> <user_auth_token>

List users for a group

mainflux-cli groups members <group_id> <user_auth_token>

List groups that user belongs to

mainflux-cli groups membership <user_id> <user_auth_token>

Keys management

Issue a new Key

mainflux-cli keys issue <duration> <user_auth_token>

Remove API key from database

mainflux-cli keys revoke <key_id> <user_auth_token>

Retrieve API key with given id

mainflux-cli keys retrieve <key_id> <user_auth_token>