MG-1529 - User Removal (#2122)

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
This commit is contained in:
b1ackd0t
2024-06-28 12:13:04 +03:00
committed by GitHub
parent 0794363a3c
commit 2fe2f850c2
67 changed files with 1816 additions and 1148 deletions
+6
View File
@@ -45,6 +45,7 @@ type remotes struct {
CertsURL string `toml:"certs_url"`
InvitationsURL string `toml:"invitations_url"`
JournalURL string `toml:"journal_url"`
HostURL string `toml:"host_url"`
TLSVerification bool `toml:"tls_verification"`
}
@@ -115,6 +116,7 @@ func ParseConfig(sdkConf mgxsdk.Config) (mgxsdk.Config, error) {
CertsURL: defCertsURL,
InvitationsURL: defInvitationsURL,
JournalURL: defJournalURL,
HostURL: defURL,
TLSVerification: defTLSVerification,
},
Filter: filter{
@@ -205,6 +207,10 @@ func ParseConfig(sdkConf mgxsdk.Config) (mgxsdk.Config, error) {
sdkConf.JournalURL = config.Remotes.JournalURL
}
if sdkConf.HostURL == "" && config.Remotes.HostURL != "" {
sdkConf.HostURL = config.Remotes.HostURL
}
sdkConf.TLSVerification = config.Remotes.TLSVerification || sdkConf.TLSVerification
return sdkConf, nil
+19 -2
View File
@@ -338,7 +338,24 @@ var cmdUsers = []cobra.Command{
logJSON(user)
},
},
{
Use: "delete <user_id> <user_auth_token>",
Short: "Delete user",
Long: "Delete user by id\n" +
"Usage:\n" +
"\tmagistrala-cli users delete <user_id> $USERTOKEN - delete user with <user_id>\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
logUsage(cmd.Use)
return
}
if err := sdk.DeleteUser(args[0], args[1]); err != nil {
logError(err)
return
}
logOK()
},
},
{
Use: "channels <user_id> <user_auth_token>",
Short: "List channels",
@@ -451,7 +468,7 @@ var cmdUsers = []cobra.Command{
// NewUsersCmd returns users command.
func NewUsersCmd() *cobra.Command {
cmd := cobra.Command{
Use: "users [create | get | update | token | password | enable | disable | channels | things | groups]",
Use: "users [create | get | update | token | password | enable | disable | delete | channels | things | groups]",
Short: "Users management",
Long: `Users management: create accounts and tokens"`,
}