# Mainflux CLI ## Build From the project root: ```bash make cli ``` ## Usage ### Service #### Get the version of Mainflux services ```bash mainflux-cli version ``` ### Users management #### Create User ```bash mainflux-cli users create ``` #### Login User ```bash mainflux-cli users token ``` #### Retrieve User ```bash mainflux-cli users get ``` #### Update User Metadata ```bash mainflux-cli users update '{"key1":"value1", "key2":"value2"}' ``` #### Update User Password ```bash mainflux-cli users password ``` ### 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 things * `user_auth_token` - A valid user auth token for the current system #### Update Thing ```bash mainflux-cli things update '{"id":"", "name":"myNewName"}' ``` #### Remove Thing ```bash mainflux-cli things delete ``` #### Retrieve a subset list of provisioned Things ```bash mainflux-cli things get all --offset=1 --limit=5 ``` #### Retrieve Thing By ID ```bash mainflux-cli things get ``` #### Create Channel ```bash mainflux-cli channels create '{"name":"myChannel"}' ``` #### Bulk Provision Channels ```bash mainflux-cli provision channels ``` * `file` - A CSV or JSON file containing channels * `user_auth_token` - A valid user auth token for the current system #### Update Channel ```bash mainflux-cli channels update '{"id":"","name":"myNewName"}' ``` #### Remove Channel ```bash mainflux-cli channels delete ``` #### Retrieve a subset list of provisioned Channels ```bash mainflux-cli channels get all --offset=1 --limit=5 ``` #### Retrieve Channel By ID ```bash mainflux-cli channels get ``` ### 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 * `user_auth_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 { "thing_ids": [ "", "" ], "channel_ids": [ "", "" ] } ``` #### Disconnect Thing from Channel ```bash mainflux-cli things disconnect ``` #### Retrieve a subset list of Channels connected to Thing ```bash mainflux-cli things connections ``` #### Retrieve 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 ``` ### Bootstrap #### Add configuration ```bash mainflux-cli bootstrap add '{"external_id": "myExtID", "external_key": "myExtKey", "name": "myName", "content": "myContent"}' ``` #### View configuration ```bash mainflux-cli bootstrap view ``` #### Update configuration ```bash mainflux-cli bootstrap update '{"MFThing":"", "name": "newName", "content": "newContent"}' ``` #### Remove configuration ```bash mainflux-cli bootstrap remove ``` #### Bootstrap configuration ```bash mainflux-cli bootstrap bootstrap ```