cli

package
v0.16.0 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: 23 Imported by: 0

README

SuperMQ CLI

Build

From the project root:

make cli

Usage

Service
Get SuperMQ Services Health Check
supermq-cli health <service>
Users management
Create User
supermq-cli users create <user_name> <user_email> <user_password>

supermq-cli users create <user_name> <user_email> <user_password> <user_token>
Login User
supermq-cli users token <user_email> <user_password>
Get User
supermq-cli users get <user_id> <user_token>
Get Users
supermq-cli users get all <user_token>
Update User Metadata
supermq-cli users update <user_id> '{"name":"value1", "metadata":{"value2": "value3"}}' <user_token>
Update User Password
supermq-cli users password <old_password> <password> <user_token>
Enable User
supermq-cli users enable <user_id> <user_token>
Disable User
supermq-cli users disable <user_id> <user_token>
System Provisioning
Create Client
supermq-cli clients create '{"name":"myClient"}' <user_token>
Create Client with metadata
supermq-cli clients create '{"name":"myClient", "metadata": {"key1":"value1"}}' <user_token>
Bulk Provision Clients
supermq-cli provision clients <file> <user_token>
  • file - A CSV or JSON file containing client names (must have extension .csv or .json)
  • user_token - A valid user auth token for the current system

An example CSV file might be:

client1,
client2,
client3,

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

A comparable JSON file would be

[
  {
    "name": "<client1_name>",
    "status": "enabled"
  },
  {
    "name": "<client2_name>",
    "status": "disabled"
  },
  {
    "name": "<client3_name>",
    "status": "enabled",
    "credentials": {
      "identity": "<client3_identity>",
      "secret": "<client3_secret>"
    }
  }
]

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

Update Client
supermq-cli clients update <client_id> '{"name":"value1", "metadata":{"key1": "value2"}}' <user_token>
Identify Client
supermq-cli clients identify <client_key>
Enable Client
supermq-cli clients enable <client_id> <user_token>
Disable Client
supermq-cli clients disable <client_id> <user_token>
Get Client
supermq-cli clients get <client_id> <user_token>
Get Clients
supermq-cli clients get all <user_token>
Get a subset list of provisioned Clients
supermq-cli clients get all --offset=1 --limit=5 <user_token>
Create Channel
supermq-cli channels create '{"name":"myChannel"}' <user_token>
Bulk Provision Channels
supermq-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
supermq-cli channels update '{"id":"<channel_id>","name":"myNewName"}' <user_token>
Enable Channel
supermq-cli channels enable <channel_id> <user_token>
Disable Channel
supermq-cli channels disable <channel_id> <user_token>
Get Channel
supermq-cli channels get <channel_id> <user_token>
Get Channels
supermq-cli channels get all <user_token>
Get a subset list of provisioned Channels
supermq-cli channels get all --offset=1 --limit=5 <user_token>
Access control
Connect Client to Channel
supermq-cli clients connect <client_id> <channel_id> <user_token>
Bulk Connect Clients to Channels
supermq-cli provision connect <file> <user_token>
  • file - A CSV or JSON file containing client 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

<client_id1>,<channel_id1>
<client_id2>,<channel_id2>

in which the first column is client IDs and the second column is channel IDs. A connection will be created for each client to each channel. This example would result in 4 connections being created.

A comparable JSON file would be

{
  "client_ids": ["<client_id1>", "<client_id2>"],
  "group_ids": ["<channel_id1>", "<channel_id2>"]
}
Disconnect Client from Channel
supermq-cli clients disconnect <client_id> <channel_id> <user_token>
Get a subset list of Channels connected to Client
supermq-cli clients connections <client_id> <user_token>
Get a subset list of Clients connected to Channel
supermq-cli channels connections <channel_id> <user_token>
Messaging
Send a message over HTTP
supermq-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}]' <client_secret>
Read messages over HTTP
supermq-cli messages read <channel_id> <user_token> -R <reader_url>
Bootstrap
Add configuration
supermq-cli bootstrap create '{"external_id": "myExtID", "external_key": "myExtKey", "name": "myName", "content": "myContent"}' <user_token> -b <bootstrap-url>
View configuration
supermq-cli bootstrap get <client_id> <user_token> -b <bootstrap-url>
Update configuration
supermq-cli bootstrap update '{"client_id":"<client_id>", "name": "newName", "content": "newContent"}' <user_token> -b <bootstrap-url>
Remove configuration
supermq-cli bootstrap remove <client_id> <user_token> -b <bootstrap-url>
Bootstrap configuration
supermq-cli bootstrap bootstrap <external_id> <external_key> -b <bootstrap-url>
Groups
Create Group
supermq-cli groups create '{"name":"<group_name>","description":"<description>","parentID":"<parent_id>","metadata":"<metadata>"}' <user_token>
Get Group
supermq-cli groups get <group_id> <user_token>
Get Groups
supermq-cli groups get all <user_token>
Get Group Members
supermq-cli groups members <group_id> <user_token>
Get Memberships
supermq-cli groups membership <member_id> <user_token>
Assign Members to Group
supermq-cli groups assign <member_ids> <member_type> <group_id> <user_token>
Unassign Members to Group
supermq-cli groups unassign <member_ids> <group_id>  <user_token>
Enable Group
supermq-cli groups enable <group_id> <user_token>
Disable Group
supermq-cli groups disable <group_id> <user_token>

Documentation

Overview

Package cli contains the domain concept definitions needed to support SuperMQ CLI functionality.

Index

Constants

View Source
const (
	PublishType   = "publish"
	SubscribeType = "subscribe"
)

Variables

View Source
var (
	// Limit query parameter.
	Limit uint64 = 10
	// Offset query parameter.
	Offset uint64 = 0
	// Name query parameter.
	Name string = ""
	// Identity query parameter.
	Identity string = ""
	// Metadata query parameter.
	Metadata string = ""
	// Status query parameter.
	Status string = ""
	// ConfigPath config path parameter.
	ConfigPath string = ""
	// State query parameter.
	State string = ""
	// Topic query parameter.
	Topic string = ""
	// Contact query parameter.
	Contact string = ""
	// RawOutput raw output mode.
	RawOutput bool = false
	// Username query parameter.
	Username string = ""
	// FirstName query parameter.
	FirstName string = ""
	// LastName query parameter.
	LastName string = ""
)

Functions

func NewBootstrapCmd

func NewBootstrapCmd() *cobra.Command

NewBootstrapCmd returns bootstrap command.

func NewCertsCmd

func NewCertsCmd() *cobra.Command

NewCertsCmd returns certificate command.

func NewChannelAssignCmds

func NewChannelAssignCmds() *cobra.Command

func NewChannelUnassignCmds

func NewChannelUnassignCmds() *cobra.Command

func NewChannelsCmd

func NewChannelsCmd() *cobra.Command

NewChannelsCmd returns channels command.

func NewClientsCmd

func NewClientsCmd() *cobra.Command

NewClientsCmd returns clients command.

func NewConfigCmd

func NewConfigCmd() *cobra.Command

New config command to store params to local TOML file.

func NewDomainAssignCmds

func NewDomainAssignCmds() *cobra.Command

func NewDomainUnassignCmds

func NewDomainUnassignCmds() *cobra.Command

func NewDomainsCmd

func NewDomainsCmd() *cobra.Command

NewDomainsCmd returns domains command.

func NewGroupAssignCmds

func NewGroupAssignCmds() *cobra.Command

func NewGroupUnassignCmds

func NewGroupUnassignCmds() *cobra.Command

func NewGroupsCmd

func NewGroupsCmd() *cobra.Command

NewGroupsCmd returns users command.

func NewHealthCmd

func NewHealthCmd() *cobra.Command

NewHealthCmd returns health check command.

func NewInvitationsCmd

func NewInvitationsCmd() *cobra.Command

NewInvitationsCmd returns invitations command.

func NewJournalCmd

func NewJournalCmd() *cobra.Command

NewJournalCmd returns journal log command.

func NewMessagesCmd

func NewMessagesCmd() *cobra.Command

NewMessagesCmd returns messages command.

func NewProvisionCmd

func NewProvisionCmd() *cobra.Command

NewProvisionCmd returns provision command.

func NewSubscriptionCmd

func NewSubscriptionCmd() *cobra.Command

NewSubscriptionCmd returns subscription command.

func NewUsersCmd

func NewUsersCmd() *cobra.Command

NewUsersCmd returns users command.

func ParseConfig

func ParseConfig(sdkConf smqsdk.Config) (smqsdk.Config, error)

ParseConfig - parses the config file.

func SetSDK

func SetSDK(s smqsdk.SDK)

SetSDK sets supermq 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