MG-1965 - Process Event Logs (#2057)

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-27 17:38:20 +03:00
committed by GitHub
parent b0e37dacf4
commit 0794363a3c
66 changed files with 3968 additions and 447 deletions
+7
View File
@@ -27,6 +27,7 @@ const (
defCertsURL string = defURL + ":9019"
defInvitationsURL string = defURL + ":9020"
defHTTPURL string = defURL + ":8008"
defJournalURL string = defURL + ":9021"
defTLSVerification bool = false
defOffset string = "0"
defLimit string = "10"
@@ -43,6 +44,7 @@ type remotes struct {
BootstrapURL string `toml:"bootstrap_url"`
CertsURL string `toml:"certs_url"`
InvitationsURL string `toml:"invitations_url"`
JournalURL string `toml:"journal_url"`
TLSVerification bool `toml:"tls_verification"`
}
@@ -112,6 +114,7 @@ func ParseConfig(sdkConf mgxsdk.Config) (mgxsdk.Config, error) {
BootstrapURL: defBootstrapURL,
CertsURL: defCertsURL,
InvitationsURL: defInvitationsURL,
JournalURL: defJournalURL,
TLSVerification: defTLSVerification,
},
Filter: filter{
@@ -198,6 +201,10 @@ func ParseConfig(sdkConf mgxsdk.Config) (mgxsdk.Config, error) {
sdkConf.InvitationsURL = config.Remotes.InvitationsURL
}
if sdkConf.JournalURL == "" && config.Remotes.JournalURL != "" {
sdkConf.JournalURL = config.Remotes.JournalURL
}
sdkConf.TLSVerification = config.Remotes.TLSVerification || sdkConf.TLSVerification
return sdkConf, nil
+50
View File
@@ -0,0 +1,50 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
package cli
import (
mgxsdk "github.com/absmach/magistrala/pkg/sdk/go"
"github.com/spf13/cobra"
)
var cmdJournal = cobra.Command{
Use: "get <entity_type> <entity_id> <user_auth_token>",
Short: "Get journal",
Long: "Get journal\n" +
"Usage:\n" +
"\tmagistrala-cli journal get <entity_type> <entity_id> <user_auth_token> - lists journal logs\n" +
"\tmagistrala-cli journal get <entity_type> <entity_id> <user_auth_token> --offset <offset> --limit <limit> - lists journal logs with provided offset and limit\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 3 {
logUsage(cmd.Use)
return
}
pageMetadata := mgxsdk.PageMetadata{
Offset: Offset,
Limit: Limit,
}
journal, err := sdk.Journal(args[0], args[1], pageMetadata, args[2])
if err != nil {
logError(err)
return
}
logJSON(journal)
},
}
// NewJournalCmd returns journal log command.
func NewJournalCmd() *cobra.Command {
cmd := cobra.Command{
Use: "journal get",
Short: "journal log",
Long: `journal to read journal log`,
}
cmd.AddCommand(&cmdJournal)
return &cmd
}