Beispiel #1
0
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)))
	}
}
Beispiel #2
0
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)))
}
Beispiel #3
0
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))
	}
}
Beispiel #4
0
// 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)
		}
	},
}
Beispiel #5
0
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"))
		}
	},
}
Beispiel #6
0
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"))
		}
	},
}
Beispiel #7
0
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"))
	},
}
Beispiel #8
0
func contacts(sinceSeconds string) {
	fmt.Print(internal.GetWantReturn("/user/me/contacts/" + sinceSeconds))
}
Beispiel #9
0
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"))
		}
	},
}
Beispiel #10
0
func groupsList(skip, limit string) {
	fmt.Print(internal.GetWantReturn(fmt.Sprintf("/groups?skip=%s&limit=%s", skip, limit)))
}
Beispiel #11
0
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"))
		}
	},
}
Beispiel #12
0
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"))
		}
	},
}
Beispiel #13
0
func user(path string) {
	fmt.Print(internal.GetWantReturn("/user" + path))
}
Beispiel #14
0
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"))
		}
	},
}
Beispiel #15
0
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"))
		}
	},
}
Beispiel #16
0
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"))
		}
	},
}
Beispiel #17
0
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 + "&notLabel=" + criteriaNotLabel
	}
	if criteriaAndLabel != "" {
		c = c + "&andLabel=" + criteriaAndLabel
	}
	if criteriaTag != "" {
		c = c + "&tag=" + criteriaTag
	}
	if criteriaNotTag != "" {
		c = c + "&notTag=" + 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)))
}