cli

package
v0.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Mainflux CLI

Build

From the project root:

make cli

Usage

Service
Get Mainflux Things services Health Check
mainfluxlabs-cli health
Users management
Create User
mainfluxlabs-cli users create <user_email> <user_password>
Login User
mainfluxlabs-cli users token <user_email> <user_password>
Retrieve User
mainfluxlabs-cli users get <user_token>
Update User Metadata
mainfluxlabs-cli users update '{"key1":"value1", "key2":"value2"}' <user_token>
Update User Password
mainfluxlabs-cli users password <old_password> <password> <user_token>
System Provisioning
Create Group
mainfluxlabs-cli groups create '{"name":"<group_name>"}' <org_id> <user_token>
Create Thing
mainfluxlabs-cli things create '{"name":"<thing_name>","profile_id":"<profile_id>"}' <group_id> <user_token>
Create Thing with metadata
mainfluxlabs-cli things create '{"name":"<thing_name>","profile_id":"<profile_id>","metadata": {\"key1\":\"value1\"}}' <group_id> <user_token>
Bulk Provision Things
mainfluxlabs-cli provision things <file> <user_token>
  • file - A CSV or JSON file containing things
  • user_token - A valid user auth token for the current system
Update Thing
mainfluxlabs-cli things update '{"name":"<new_name>","profile_id":"<profile_id>"}' <thing_id> <user_token>
Remove Thing
mainfluxlabs-cli things delete <thing_id> <user_token>
Retrieve a subset list of provisioned Things
mainfluxlabs-cli things get all --offset=1 --limit=5 <user_token>
Retrieve Thing By ID
mainfluxlabs-cli things get <thing_id> <user_token>
Create Profile
mainfluxlabs-cli profiles create '{"name":"<profile_name>"}' <group_id> <user_token>
Bulk Provision Profiles
mainfluxlabs-cli provision profiles <file> <user_token>
  • file - A CSV or JSON file containing profiles
  • user_token - A valid user auth token for the current system
Update Profile
mainfluxlabs-cli profiles update '{"name":"<new_name>"}' <profile_id> <user_token>
Remove Profile
mainfluxlabs-cli profiles delete <profile_id> <user_token>
Retrieve a subset list of provisioned Profiles
mainfluxlabs-cli profiles get all --offset=1 --limit=5 <user_token>
Retrieve Profile By ID
mainfluxlabs-cli profiles get <profile_id> <user_token>
Retrieve a Profile by Thing
mainfluxlabs-cli profiles thing <thing_id> <user_token>
Retrieve a subset list of Things by Profile
mainfluxlabs-cli things profile <profile_id> <user_token>
Messaging
Send a message over HTTP
mainfluxlabs-cli messages send <profile_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
mainfluxlabs-cli messages read <profile_id> <thing_auth_token>
Groups
Create new group
mainfluxlabs-cli groups create '{"name":"<group_name>","description":"<description>","metadata":{"key":"value",...}}' <org_id> <user_token>
Delete group
mainfluxlabs-cli groups delete <group_id> <user_token>
Get group by id
mainfluxlabs-cli groups get <group_id> <user_token>
List all groups
mainfluxlabs-cli groups get all <user_token>
Update group
mainfluxlabs-cli groups update '{"name":"<new_name>"}' <group_id> <user_token>
List things by group
mainfluxlabs-cli groups things <group_id> <user_token>
View group by thing
mainfluxlabs-cli groups thing <thing_id> <user_token>
List profiles by group
mainfluxlabs-cli groups profiles <group_id> <user_token>
View group by profile
mainfluxlabs-cli groups profile <profile_id> <user_token>
Orgs
Create new org
mainfluxlabs-cli orgs create '{"name":"<org_name>","description":"<description>","metadata":{"key":"value",...}}' <user_token>
Get org by id
mainfluxlabs-cli orgs get <org_id> <user_token>
List all orgs
mainfluxlabs-cli orgs get all <user_token>
Update org
mainfluxlabs-cli orgs update '{"name":"<new_name>"}' <org_id> <user_token>
Delete org
mainfluxlabs-cli orgs delete <org_id> <user_token>
Assign user to an org
mainfluxlabs-cli orgs assign '[{"member_id":"<member_id>","email":"<email>","role":"<role>"}]' <org_id> <user_token>
Unassign user from org
mainfluxlabs-cli orgs unassign '["<member_id>"]' <org_id> <user_token>
Update members
mainfluxlabs-cli orgs update-members '[{"member_id":"<member_id>","role":"<new_role>"}]' <org_id> <user_token>
List users by org
mainfluxlabs-cli orgs members <org_id> <user_token>
List orgs that user belongs to
mainfluxlabs-cli orgs memberships <member_id> <user_token>
Webhooks
Create new webhooks
mainfluxlabs-cli webhooks create '[{"name":"<webhook_name>","url":"<http://webhook-url.com>","headers":{"key":"value",...}}]' <group_id> <user_token>
Get webhook by id
mainfluxlabs-cli webhooks get by-id <id> <user_token>
Get webhooks by group
mainfluxlabs-cli webhooks get group <group_id> <user_token>
Update webhook
mainfluxlabs-cli webhooks update '{"name":"<new_name>","url":"<http://webhook-url.com>"}' <webhook_id> <user_token>
Delete webhooks
mainfluxlabs-cli webhooks delete '["<webhook_id>"]' <group_id> <user_token>
Keys management
Issue a new Key
mainfluxlabs-cli keys issue <duration> <user_token>
Remove API key from database
mainfluxlabs-cli keys revoke <key_id> <user_token>
Retrieve API key with given id
mainfluxlabs-cli keys retrieve <key_id> <user_token>

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Limit query parameter
	Limit uint = 10
	// Offset query parameter
	Offset uint = 0
	// Name query parameter
	Name string = ""
	// Email query parameter
	Email string = ""
	// Metadata query parameter
	Metadata string = ""
	// ConfigPath config path parameter
	ConfigPath string = ""
	// RawOutput raw output mode
	RawOutput bool = false
)

Functions

func NewCertsCmd

func NewCertsCmd() *cobra.Command

NewCertsCmd returns certificate command.

func NewGroupRolesCmd

func NewGroupRolesCmd() *cobra.Command

NewGroupRolesCmd returns users command.

func NewGroupsCmd

func NewGroupsCmd() *cobra.Command

NewGroupsCmd returns users command.

func NewHealthCmd

func NewHealthCmd() *cobra.Command

NewHealthCmd returns health check command.

func NewKeysCmd

func NewKeysCmd() *cobra.Command

NewKeysCmd returns keys command.

func NewMessagesCmd

func NewMessagesCmd() *cobra.Command

NewMessagesCmd returns messages command.

func NewOrgsCmd

func NewOrgsCmd() *cobra.Command

NewOrgsCmd returns users command.

func NewProfilesCmd added in v0.24.0

func NewProfilesCmd() *cobra.Command

NewProfilesCmd returns profiles command.

func NewProvisionCmd

func NewProvisionCmd() *cobra.Command

NewProvisionCmd returns provision command.

func NewThingsCmd

func NewThingsCmd() *cobra.Command

NewThingsCmd returns things command.

func NewUsersCmd

func NewUsersCmd() *cobra.Command

NewUsersCmd returns users command.

func NewWebhooksCmd

func NewWebhooksCmd() *cobra.Command

NewWebhooksCmd returns users command.

func ParseConfig

func ParseConfig()

func SetSDK

func SetSDK(s mfxsdk.SDK)

SetSDK sets mainflux SDK instance.

Types

type Config

type Config struct {
	Offset    uint   `toml:"offset"`
	Limit     uint   `toml:"limit"`
	Name      string `toml:"name"`
	RawOutput bool   `toml:"raw_output"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL