# Mainflux CLI ## Build From the project root: ```bash make cli ``` ## Usage ### Service #### Get Mainflux Services Health Check ```bash mainflux-cli health ``` ### Users management #### Create User ```bash mainflux-cli users create mainflux-cli users create ``` #### Login User ```bash mainflux-cli users token ``` #### Get User ```bash mainflux-cli users get ``` #### Get Users ```bash mainflux-cli users get all ``` #### Update User Metadata ```bash mainflux-cli users update '{"name":"value1", "metadata":{"value2": "value3"}}' ``` #### Update User Password ```bash mainflux-cli users password ``` #### Enable User ```bash mainflux-cli users enable ``` #### Disable User ```bash mainflux-cli users disable ``` ### System Provisioning #### Create Thing ```bash mainflux-cli things create '{"name":"myThing"}' ``` #### Create Thing with metadata ```bash mainflux-cli things create '{"name":"myThing", "metadata": {"key1":"value1"}}' ``` #### Bulk Provision Things ```bash mainflux-cli provision things ``` - `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: ```csv thing1, thing2, thing3, ``` in which the first column is the thing's name. A comparable JSON file would be ```json [ { "name": "", "status": "enabled" }, { "name": "", "status": "disabled" }, { "name": "", "status": "enabled", "credentials": { "identity": "", "secret": "" } } ] ``` With JSON you can be able to specify more fields of the channels you want to create #### Update Thing ```bash mainflux-cli things update '{"name":"value1", "metadata":{"key1": "value2"}}' ``` #### Identify Thing ```bash mainflux-cli things identify ``` #### Enable Thing ```bash mainflux-cli things enable ``` #### Disable Thing ```bash mainflux-cli things disable ``` #### Get Thing ```bash mainflux-cli things get ``` #### Get Things ```bash mainflux-cli things get all ``` #### Get a subset list of provisioned Things ```bash mainflux-cli things get all --offset=1 --limit=5 ``` #### Create Channel ```bash mainflux-cli channels create '{"name":"myChannel"}' ``` #### Bulk Provision Channels ```bash mainflux-cli provision channels ``` - `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: ```csv , , , ``` in which the first column is channel names. A comparable JSON file would be ```json [ { "name": "", "description": "", "status": "enabled" }, { "name": "", "description": "", "status": "disabled" }, { "name": "", "description": "", "status": "enabled" } ] ``` With JSON you can be able to specify more fields of the channels you want to create #### Update Channel ```bash mainflux-cli channels update '{"id":"","name":"myNewName"}' ``` #### Enable Channel ```bash mainflux-cli channels enable ``` #### Disable Channel ```bash mainflux-cli channels disable ``` #### Get Channel ```bash mainflux-cli channels get ``` #### Get Channels ```bash mainflux-cli channels get all ``` #### Get a subset list of provisioned Channels ```bash mainflux-cli channels get all --offset=1 --limit=5 ``` ### Access control #### Connect Thing to Channel ```bash mainflux-cli things connect ``` #### Bulk Connect Things to Channels ```bash mainflux-cli provision connect ``` - `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 ```csv , , ``` 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 ```json { "client_ids": ["", ""], "group_ids": ["", ""] } ``` #### Disconnect Thing from Channel ```bash mainflux-cli things disconnect ``` #### Get a subset list of Channels connected to Thing ```bash mainflux-cli things connections ``` #### Get a subset list of Things connected to Channel ```bash mainflux-cli channels connections ``` ### Messaging #### Send a message over HTTP ```bash mainflux-cli messages send '[{"bn":"Dev1","n":"temp","v":20}, {"n":"hum","v":40}, {"bn":"Dev2", "n":"temp","v":20}, {"n":"hum","v":40}]' ``` #### Read messages over HTTP ```bash mainflux-cli messages read -R ``` ### Bootstrap #### Add configuration ```bash mainflux-cli bootstrap create '{"external_id": "myExtID", "external_key": "myExtKey", "name": "myName", "content": "myContent"}' -b ``` #### View configuration ```bash mainflux-cli bootstrap get -b ``` #### Update configuration ```bash mainflux-cli bootstrap update '{"thing_id":"", "name": "newName", "content": "newContent"}' -b ``` #### Remove configuration ```bash mainflux-cli bootstrap remove -b ``` #### Bootstrap configuration ```bash mainflux-cli bootstrap bootstrap -b ``` ### Groups #### Create Group ```bash mainflux-cli groups create '{"name":"","description":"","parentID":"","metadata":""}' ``` #### Get Group ```bash mainflux-cli groups get ``` #### Get Groups ```bash mainflux-cli groups get all ``` #### Get Group Members ```bash mainflux-cli groups members ``` #### Get Memberships ```bash mainflux-cli groups membership ``` #### Assign Members to Group ```bash mainflux-cli groups assign ``` #### Unassign Members to Group ```bash mainflux-cli groups unassign ``` #### Enable Group ```bash mainflux-cli groups enable ``` #### Disable Group ```bash mainflux-cli groups disable ```