func usersList(skip, limit string) { if withGroups { fmt.Print(internal.GetWantReturn(fmt.Sprintf("/users?skip=%s&limit=%s&withGroups=true", skip, limit))) } else { fmt.Print(internal.GetWantReturn(fmt.Sprintf("/users?skip=%s&limit=%s", skip, limit))) } }
func topicsList(skip string, limit string) { n := "" if criteriaTopic != "" { n += "&topic=" + criteriaTopic } if criteriaIDTopic != "" { n += "&idTopic=" + criteriaIDTopic } if criteriaDescription != "" { n += "&Description=" + criteriaDescription } if criteriaDateMinCreation != "" { n += "&DateMinCreation=" + criteriaDateMinCreation } if criteriaDateMaxCreation != "" { n += "&DateMaxCreation=" + criteriaDateMaxCreation } if criteriaGetNbMsgUnread != "" { n += "&getNbMsgUnread=" + criteriaGetNbMsgUnread } if criteriaGetForTatAdmin == "true" { n += "&getForTatAdmin=" + criteriaGetForTatAdmin } fmt.Print(internal.GetWantReturn(fmt.Sprintf("/topics?skip=%s&limit=%s%s", skip, limit, n))) }
func userVerify(username, tokenVerify string) { url := fmt.Sprintf("/user/verify/%s/%s", username, tokenVerify) r := internal.GetWantReturn(url) var verifyJSON verifyJSON err := json.Unmarshal([]byte(r), &verifyJSON) internal.Check(err) // Display return to user (contains clear password) fmt.Printf(r) if save && verifyJSON.Password != "" && verifyJSON.Username != "" && verifyJSON.URL != "" { verifyJSON.Message = "" jsonStr, err := json.MarshalIndent(verifyJSON, "", " ") internal.Check(err) jsonStr = append(jsonStr, '\n') filename := internal.ConfigFile dir := path.Dir(filename) if _, err := os.Stat(dir); os.IsNotExist(err) { internal.Check(os.Mkdir(dir, 0740)) } internal.Check(ioutil.WriteFile(filename, jsonStr, 0600)) } }
// VERSION of tatcli const VERSION = "0.51.1" var versionNewLine bool func init() { Cmd.Flags().BoolVarP(&versionNewLine, "versionNewLine", "", true, "New line after version number. If true, display Version Engine too") } // Cmd version var Cmd = &cobra.Command{ Use: "version", Short: "Display Version of tatcli and tat engine if configured : tatcli version", Long: `tatcli version`, Aliases: []string{"v"}, Run: func(cmd *cobra.Command, args []string) { if versionNewLine { fmt.Printf("Version tatcli : %s\n", VERSION) internal.ReadConfig() if viper.GetString("url") == "" { fmt.Fprintf(os.Stderr, "Version Engine : No Engine Configured. See tatcli config --help\n") } else { fmt.Printf("Version Engine on %s : %s\n", viper.GetString("url"), internal.GetWantReturn("/version")) } } else { fmt.Print(VERSION) } }, }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsDBReplSetGetConfig = &cobra.Command{ Use: "dbReplSetGetConfig", Short: "DB Stats: tatcli stats dbReplSetGetConfig", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbReplSetGetConfig --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/db/replSetGetConfig")) } }, }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsDBSlowestQueries = &cobra.Command{ Use: "dbSlowestQueries", Short: "DB Stats slowest Queries: tatcli stats dbSlowestQueries", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbSlowestQueriess --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/db/slowestQueries")) } }, }
package socket import ( "fmt" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdSocketDump = &cobra.Command{ Use: "dump", Short: "Dump websocket admin variables: tatcli socket dump", Aliases: []string{"d"}, Run: func(cmd *cobra.Command, args []string) { fmt.Print(internal.GetWantReturn("/sockets/dump")) }, }
func contacts(sinceSeconds string) { fmt.Print(internal.GetWantReturn("/user/me/contacts/" + sinceSeconds)) }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsDBServerStatus = &cobra.Command{ Use: "dbServerStatus", Short: "DB Stats: tatcli stats dbServerStatus", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbServerStatus --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/db/serverStatus")) } }, }
func groupsList(skip, limit string) { fmt.Print(internal.GetWantReturn(fmt.Sprintf("/groups?skip=%s&limit=%s", skip, limit))) }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsCount = &cobra.Command{ Use: "count", Short: "Count all messages, groups, presences, users, groups, topics: tatcli stats count", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats count --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/count")) } }, }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsDBReplSetGetStatus = &cobra.Command{ Use: "dbReplSetGetStatus", Short: "DB Stats: tatcli stats dbReplSetGetStatus", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbReplSetGetStatus --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/db/replSetGetStatus")) } }, }
func user(path string) { fmt.Print(internal.GetWantReturn("/user" + path)) }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsDistribution = &cobra.Command{ Use: "distribution", Short: "Distribution of messages per topics: tatcli stats distribution", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats distribution --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/distribution")) } }, }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsDBStats = &cobra.Command{ Use: "dbstats", Short: "DB Stats: tatcli stats dbstats", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats db --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/db/stats")) } }, }
package stats import ( "fmt" "os" "github.com/ovh/tatcli/internal" "github.com/spf13/cobra" ) var cmdStatsInstance = &cobra.Command{ Use: "instance", Short: "Info about current instance of engine", Run: func(cmd *cobra.Command, args []string) { if len(args) >= 1 { fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats instance --help\n") cmd.Usage() } else { fmt.Print(internal.GetWantReturn("/stats/instance")) } }, }
func messagesList(topic string, skip, limit string) { c := "" if treeView != "" { c = c + "&treeView=" + treeView } if criteriaIDMessage != "" { c = c + "&idMessage=" + criteriaIDMessage } if criteriaInReplyOfID != "" { c = c + "&inReplyOfID=" + criteriaInReplyOfID } if criteriaInReplyOfIDRoot != "" { c = c + "&inReplyOfIDRoot=" + criteriaInReplyOfIDRoot } if criteriaAllIDMessage != "" { c = c + "&allIDMessage=" + criteriaAllIDMessage } if criteriaText != "" { c = c + "&text=" + criteriaText } if criteriaTopic != "" { c = c + "&topic=" + criteriaTopic } if criteriaLabel != "" { c = c + "&label=" + criteriaLabel } if criteriaNotLabel != "" { c = c + "¬Label=" + criteriaNotLabel } if criteriaAndLabel != "" { c = c + "&andLabel=" + criteriaAndLabel } if criteriaTag != "" { c = c + "&tag=" + criteriaTag } if criteriaNotTag != "" { c = c + "¬Tag=" + criteriaNotTag } if criteriaAndTag != "" { c = c + "&andTag=" + criteriaAndTag } if criteriaDateMinCreation != "" { c = c + "&dateMinCreation=" + criteriaDateMinCreation } if criteriaDateMaxCreation != "" { c = c + "&dateMaxCreation=" + criteriaDateMaxCreation } if criteriaDateMinUpdate != "" { c = c + "&dateMinUpdate=" + criteriaDateMinUpdate } if criteriaDateMaxUpdate != "" { c = c + "&dateMaxUpdate=" + criteriaDateMaxUpdate } if criteriaUsername != "" { c = c + "&username="******"" { c = c + "&limitMinNbReplies=" + criteriaLimitMinNbReplies } if criteriaLimitMaxNbReplies != "" { c = c + "&limitMaxNbReplies=" + criteriaLimitMaxNbReplies } fmt.Print(internal.GetWantReturn(fmt.Sprintf("/messages%s?skip=%s&limit=%s%s", topic, skip, limit, c))) }