cli

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 28 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Mainflux CLI

Build

From the project root:

make cli

Usage

Remote deployment

The --url flag derives every service URL from the deployment base URL, and an explicitly set service URL flag takes precedence.

mainfluxlabs-cli --url https://example.com things get all <user_token>
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> <group_id> <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 <user_token>
Retrieve Thing by ID
mainfluxlabs-cli things get by-id <thing_id> <user_token>
Retrieve Things by Profile
mainfluxlabs-cli things get by-profile <profile_id> <user_token>
Retrieve Metadata by Key
mainfluxlabs-cli things metadata <thing_key>
Retrieve Thing ID by Key
mainfluxlabs-cli things identify <thing_key>
Create Profile
mainfluxlabs-cli profiles create '{"name":"<profile_name>"}' <group_id> <user_token>
Bulk Provision Profiles
mainfluxlabs-cli provision profiles <file> <group_id> <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 <user_token>
Retrieve Profile by ID
mainfluxlabs-cli profiles get by-id <profile_id> <user_token>
Retrieve a Profile by Thing
mainfluxlabs-cli profiles get by-thing <thing_id> <user_token>
Messaging
Send a message over HTTP
mainfluxlabs-cli messages send [subtopic] '[{"bn":"Dev1","n":"temp","v":20}, {"n":"hum","v":40}, {"bn":"Dev2", "n":"temp","v":20}, {"n":"hum","v":40}]' <thing_key>
Read messages over HTTP
  • Read messages from a specific subtopic by adding a flag -s=<subtopic>
  • Reading SenML messages is the default. To read JSON messages add the flag -f=json
  • Setting the by-admin flag allows the admin to list all messages of a certain format, from all things
  • If by-admin is set, auth_token will be admin_token, otherwise auth_token is thing_key
mainfluxlabs-cli messages read [by-admin] <auth_token>
Groups
Create 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>
Create Group Membership
mainfluxlabs-cli group_memberships create '[{"member_id":"<member_id>","email":"<email>","role":"<role>"}]' <group_id> <user_token>
Remove Group Membership
mainfluxlabs-cli group_memberships delete '["<member_id>"]' <group_id> <user_token>
Update Group Membership
mainfluxlabs-cli group_memberships update '[{"member_id":"<member_id>","role":"<new_role>"}]' <group_id> <user_token>
List Group Memberships
mainfluxlabs-cli group_memberships get <group_id> <user_token>
Orgs
Create 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>
Create Org Membership
mainfluxlabs-cli org_memberships create '[{"member_id":"<member_id>","email":"<email>","role":"<role>"}]' <org_id> <user_token>
Remove Org Membership
mainfluxlabs-cli org_memberships delete '["<member_id>"]' <org_id> <user_token>
Get Org Membership
mainfluxlabs-cli org_memberships get <all | member_id> <org_id> <user_token>
Update Org Membership
mainfluxlabs-cli org_memberships update '[{"member_id":"<member_id>","role":"<new_role>"}]' <org_id> <user_token>
List Org Membership
mainfluxlabs-cli org_memberships members <org_id> <user_token>
Webhooks
Create Webhooks
mainfluxlabs-cli webhooks create '[{"name":"<webhook_name>","url":"<http://webhook-url.com>","headers":{"key":"value",...}}]' <thing_id> <user_token>
Get Webhook by ID
mainfluxlabs-cli webhooks get by-id <id> <user_token>
Get Webhooks by Group
mainfluxlabs-cli webhooks get by-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>"]' <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>
Benchmark

Provision orgs, groups, transformer profiles, and things, then publish backfilled JSON messages over the HTTP adapter to load-test ingestion and storage.

Run a benchmark
mainfluxlabs-cli benchmark <username> <password>
Run against a remote deployment
mainfluxlabs-cli benchmark <username> <password> --url https://example.com
Flags
Flag Default Description
--orgs 3 Number of orgs to create
--groups 5 Number of groups per org
--things 100 Number of things to create
--messages 10000 Number of messages to send
--rate 0 Approximate maximum messages per second, 0 disables the limit
--batch 100 Maximum number of messages per HTTP request
--backfill-days 30 Spread message timestamps over the last N days
--mtls false Authenticate a random half of the things over mutual TLS

Each request carries a random number of messages between 1 and --batch, sent as a JSON object for a single message and as a JSON array otherwise. The sustained ingestion rate is bounded by the database insert rate, so --rate should be set to that rate to prevent the message broker buffer from overflowing.

With --mtls, the selected things obtain client certificates from the certs service and publish over HTTPS without the Authorization header, so the deployment must verify client certificates and still accept the header from the remaining things.

The results report the requests and messages per authentication type and the failed requests per cause.

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 = ""
	// Format query parameter
	Format string = ""
	// Subtopic query parameter
	Subtopic string = ""
	// RawOutput raw output mode
	RawOutput bool = false
	// HTTPAdapterURL HTTP adapter base URL
	HTTPAdapterURL string = ""
	// TLSVerification TLS certificate verification mode
	TLSVerification bool = false
	// ThingID query parameter
	ThingID string = ""
	// Protocol query parameter
	Protocol string = ""
	// From timestamp query parameter (milliseconds)
	From int64 = 0
	// To timestamp query parameter (milliseconds)
	To int64 = 0
	// Dir sort direction query parameter (asc/desc)
	Dir string = ""
	// KeyVal JSON payload key-value pairs in the key:value, key or :value form, where the first colon separates the key from the value
	KeyVal []string
	// AggInterval aggregation interval (microsecond, millisecond, second, minute, hour, day, week, month, year)
	AggInterval string = ""
	// AggValue aggregation value
	AggValue uint = 1
	// AggType aggregation type (min, max, avg, count)
	AggType string = ""
	// AggField aggregation fields (comma-separated)
	AggField string = ""
	// SenMLName SenML name filter
	SenMLName string = ""
	// SenMLValue SenML numeric value filter
	SenMLValue float64 = 0
	// Comparator comparison operator (SenML: eq, lt, le, gt, ge; JSON: eq, starts_with, contains)
	Comparator string = ""
	// BoolValue SenML boolean value filter
	BoolValue bool = false
	// StringValue SenML string value filter
	StringValue string = ""
	// DataValue SenML data value filter
	DataValue string = ""
	// ConvertFormat export format (json/csv)
	ConvertFormat string = "json"
	// TimeFormat export time format
	TimeFormat string = ""
)

Functions

func NewBenchmarkCmd added in v0.46.0

func NewBenchmarkCmd() *cobra.Command

NewBenchmarkCmd returns the benchmark command.

func NewCertsCmd

func NewCertsCmd() *cobra.Command

NewCertsCmd returns certificate command.

func NewGroupMembershipsCmd added in v0.29.0

func NewGroupMembershipsCmd() *cobra.Command

NewGroupMembershipsCmd 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 NewOrgMembershipsCmd added in v0.29.0

func NewOrgMembershipsCmd() *cobra.Command

NewOrgMembershipsCmd returns users 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 SetSDK

func SetSDK(s mfxsdk.SDK)

SetSDK sets mainflux SDK instance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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