Mainflux.mainflux/cli
Arvindh cd82cc5a43
NOISSUE: Listing of shared things with users & Update SDK (#1923)
* NOISSUE - Fix Bugs (#20)

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add Connect Disconnect endpoints (#23)

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix list of things in a channel and Add connect disconnect endpoint

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix list of things in a channel and Add connect disconnect endpoint

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add: Things share with users (#25)

* fix list of things in a channel and Add connect disconnect endpoint

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: things share with other users

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add: Listing of things, channels, groups, users  (#26)

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add: List of user groups & removed repeating code in groups (#29)

* removed repeating code in list groups

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: list of user group

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: otel handler operator name for endpoints

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* add: listing of shared things and users

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: listing of shared things and users

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: new SDK

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: new SDK

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: comment

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: sdk function names

Signed-off-by: Arvindh <arvindh91@gmail.com>

* update: api spec

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: channels connect request

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: listing of clients and groups

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: CLI

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: array len comparision

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: nginx

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2023-10-17 15:38:06 +02:00
..
README.md NOISSUE- update health method in SDK (#1881) 2023-08-08 14:42:32 +02:00
bootstrap.go NOISSUE - Change import name aliases (#1868) 2023-08-11 11:30:25 +02:00
certs.go MF-1506 - Group-based Access Control (#1716) 2023-06-14 12:40:37 +02:00
channels.go NOISSUE: Listing of shared things with users & Update SDK (#1923) 2023-10-17 15:38:06 +02:00
config.go NOISSUE - Change import name aliases (#1868) 2023-08-11 11:30:25 +02:00
consumers.go MF-1340 - Add CLI config TOML file (#1858) 2023-08-08 12:01:59 +02:00
doc.go MF-1506 - Group-based Access Control (#1716) 2023-06-14 12:40:37 +02:00
groups.go NOISSUE: Listing of shared things with users & Update SDK (#1923) 2023-10-17 15:38:06 +02:00
health.go NOISSUE- update health method in SDK (#1881) 2023-08-08 14:42:32 +02:00
message.go NOISSUE - Update Read Message CLI (#1696) 2023-01-10 12:00:12 +01:00
provision.go NOISSUE - Switch to Google Zanzibar Access control approach (#1919) 2023-10-15 22:02:13 +02:00
sdk.go MF-1506 - Group-based Access Control (#1716) 2023-06-14 12:40:37 +02:00
things.go NOISSUE: Listing of shared things with users & Update SDK (#1923) 2023-10-17 15:38:06 +02:00
users.go NOISSUE: Listing of shared things with users & Update SDK (#1923) 2023-10-17 15:38:06 +02:00
utils.go NOISSUE - Change import name aliases (#1868) 2023-08-11 11:30:25 +02:00

README.md

Mainflux CLI

Build

From the project root:

make cli

Usage

Service

Get Mainflux Services Health Check

mainflux-cli health <service>

Users management

Create User

mainflux-cli users create <user_name> <user_email> <user_password>

mainflux-cli users create <user_name> <user_email> <user_password> <user_token>

Login User

mainflux-cli users token <user_email> <user_password>

Get User

mainflux-cli users get <user_id> <user_token>

Get Users

mainflux-cli users get all <user_token>

Update User Metadata

mainflux-cli users update <user_id> '{"name":"value1", "metadata":{"value2": "value3"}}' <user_token>

Update User Password

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

Enable User

mainflux-cli users enable <user_id> <user_token>

Disable User

mainflux-cli users disable <user_id> <user_token>

System Provisioning

Create Thing

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

Create Thing with metadata

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

Bulk Provision Things

mainflux-cli provision things <file> <user_token>
  • file - A CSV or JSON file containing thing names (must have extension .csv or .json)
  • user_token - A valid user auth token for the current system

An example CSV file might be:

thing1,
thing2,
thing3,

in which the first column is the thing's name.

A comparable JSON file would be

[
  {
    "name": "<thing1_name>",
    "status": "enabled"
  },
  {
    "name": "<thing2_name>",
    "status": "disabled"
  },
  {
    "name": "<thing3_name>",
    "status": "enabled",
    "credentials": {
      "identity": "<thing3_identity>",
      "secret": "<thing3_secret>"
    }
  }
]

With JSON you can be able to specify more fields of the channels you want to create

Update Thing

mainflux-cli things update <thing_id> '{"name":"value1", "metadata":{"key1": "value2"}}' <user_token>

Identify Thing

mainflux-cli things identify <thing_key>

Enable Thing

mainflux-cli things enable <thing_id> <user_token>

Disable Thing

mainflux-cli things disable <thing_id> <user_token>

Get Thing

mainflux-cli things get <thing_id> <user_token>

Get Things

mainflux-cli things get all <user_token>

Get a subset list of provisioned Things

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

Create Channel

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

Bulk Provision Channels

mainflux-cli provision channels <file> <user_token>
  • file - A CSV or JSON file containing channel names (must have extension .csv or .json)
  • user_token - A valid user auth token for the current system

An example CSV file might be:

<channel1_name>,
<channel2_name>,
<channel3_name>,

in which the first column is channel names.

A comparable JSON file would be

[
  {
    "name": "<channel1_name>",
    "description": "<channel1_description>",
    "status": "enabled"
  },
  {
    "name": "<channel2_name>",
    "description": "<channel2_description>",
    "status": "disabled"
  },
  {
    "name": "<channel3_name>",
    "description": "<channel3_description>",
    "status": "enabled"
  }
]

With JSON you can be able to specify more fields of the channels you want to create

Update Channel

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

Enable Channel

mainflux-cli channels enable <channel_id> <user_token>

Disable Channel

mainflux-cli channels disable <channel_id> <user_token>

Get Channel

mainflux-cli channels get <channel_id> <user_token>

Get Channels

mainflux-cli channels get all <user_token>

Get a subset list of provisioned Channels

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

Access control

Connect Thing to Channel

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

Bulk Connect Things to Channels

mainflux-cli provision connect <file> <user_token>
  • file - A CSV or JSON file containing thing and channel ids (must have extension .csv or .json)
  • user_token - A valid user auth token for the current system

An example CSV file might be

<thing_id1>,<channel_id1>
<thing_id2>,<channel_id2>

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

{
  "client_ids": ["<thing_id1>", "<thing_id2>"],
  "group_ids": ["<channel_id1>", "<channel_id2>"]
}

Disconnect Thing from Channel

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

Get a subset list of Channels connected to Thing

mainflux-cli things connections <thing_id> <user_token>

Get a subset list of Things connected to Channel

mainflux-cli channels connections <channel_id> <user_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_secret>

Read messages over HTTP

mainflux-cli messages read <channel_id> <user_token> -R <reader_url>

Bootstrap

Add configuration

mainflux-cli bootstrap create '{"external_id": "myExtID", "external_key": "myExtKey", "name": "myName", "content": "myContent"}' <user_token> -b <bootstrap-url>

View configuration

mainflux-cli bootstrap get <thing_id> <user_token> -b <bootstrap-url>

Update configuration

mainflux-cli bootstrap update '{"thing_id":"<thing_id>", "name": "newName", "content": "newContent"}' <user_token> -b <bootstrap-url>

Remove configuration

mainflux-cli bootstrap remove <thing_id> <user_token> -b <bootstrap-url>

Bootstrap configuration

mainflux-cli bootstrap bootstrap <external_id> <external_key> -b <bootstrap-url>

Groups

Create Group

mainflux-cli groups create '{"name":"<group_name>","description":"<description>","parentID":"<parent_id>","metadata":"<metadata>"}' <user_token>

Get Group

mainflux-cli groups get <group_id> <user_token>

Get Groups

mainflux-cli groups get all <user_token>

Get Group Members

mainflux-cli groups members <group_id> <user_token>

Get Memberships

mainflux-cli groups membership <member_id> <user_token>

Assign Members to Group

mainflux-cli groups assign <member_ids> <member_type> <group_id> <user_token>

Unassign Members to Group

mainflux-cli groups unassign <member_ids> <group_id>  <user_token>

Enable Group

mainflux-cli groups enable <group_id> <user_token>

Disable Group

mainflux-cli groups disable <group_id> <user_token>