client

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2016 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlertCmd = &cobra.Command{
	Use:          "alert",
	Short:        "Manage alerts",
	Long:         "Manage alerts",
	SilenceUsage: false,
}
View Source
var AlertCreate = &cobra.Command{
	Use:   "create",
	Short: "Create alert",
	Long:  "Create alert",
	Run: func(cmd *cobra.Command, args []string) {
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if client == nil {
			os.Exit(1)
		}
		alert := api.NewAlert()
		alert.Name = alertName
		alert.Description = alertDescription
		alert.Select = alertSelect
		alert.Action = alertAction
		alert.Test = alertTest
		if errs := validator.Validate(alert); errs != nil {
			fmt.Println("Error: ", errs)
			cmd.Usage()
			os.Exit(1)
		}
		if err := client.Create("alert", &alert); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
		printJSON(&alert)
	},
}
View Source
var AlertDelete = &cobra.Command{
	Use:   "delete [alert]",
	Short: "Delete alert",
	Long:  "Delete alert",
	PreRun: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(1)
		}
	},
	Run: func(cmd *cobra.Command, args []string) {
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if client == nil {
			os.Exit(1)
		}
		if err := client.Delete("alert", args[0]); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
	},
}
View Source
var AlertGet = &cobra.Command{
	Use:   "get [alert]",
	Short: "Display alert",
	Long:  "Display alert",
	PreRun: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(1)
		}
	},
	Run: func(cmd *cobra.Command, args []string) {
		var alert api.Alert
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if err := client.Get("alert", args[0], &alert); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
		printJSON(&alert)
	},
}
View Source
var AlertList = &cobra.Command{
	Use:   "list",
	Short: "List alerts",
	Long:  "List alerts",
	Run: func(cmd *cobra.Command, args []string) {
		var alerts map[string]api.Alert
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if client == nil {
			os.Exit(1)
		}
		if err := client.List("alert", &alerts); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
		printJSON(alerts)
	},
}
View Source
var CaptureCmd = &cobra.Command{
	Use:          "capture",
	Short:        "Manage captures",
	Long:         "Manage captures",
	SilenceUsage: false,
}
View Source
var CaptureCreate = &cobra.Command{
	Use:   "create",
	Short: "Create capture",
	Long:  "Create capture",
	Run: func(cmd *cobra.Command, args []string) {
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if client == nil {
			os.Exit(1)
		}
		capture := api.NewCapture(gremlinQuery, bpfFilter)
		capture.Name = captureName
		capture.Description = captureDescription
		capture.Type = captureType
		if err := validator.Validate(capture); err != nil {
			fmt.Println(err.Error())
			cmd.Usage()
			os.Exit(1)
		}
		if err := client.Create("capture", &capture); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
		printJSON(&capture)
	},
}
View Source
var CaptureDelete = &cobra.Command{
	Use:   "delete [capture]",
	Short: "Delete capture",
	Long:  "Delete capture",
	PreRun: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(1)
		}
	},
	Run: func(cmd *cobra.Command, args []string) {
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if client == nil {
			os.Exit(1)
		}
		if err := client.Delete("capture", args[0]); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
	},
}
View Source
var CaptureGet = &cobra.Command{
	Use:   "get [capture]",
	Short: "Display capture",
	Long:  "Display capture",
	PreRun: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Usage()
			os.Exit(1)
		}
	},
	Run: func(cmd *cobra.Command, args []string) {
		var capture api.Capture
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if err := client.Get("capture", args[0], &capture); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
		printJSON(&capture)
	},
}
View Source
var CaptureList = &cobra.Command{
	Use:   "list",
	Short: "List captures",
	Long:  "List captures",
	Run: func(cmd *cobra.Command, args []string) {
		var captures map[string]api.Capture
		client := api.NewCrudClientFromConfig(&authenticationOpts)
		if client == nil {
			os.Exit(1)
		}
		if err := client.List("capture", &captures); err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}
		printJSON(captures)
	},
}
View Source
var Client = &cobra.Command{
	Use:          "client",
	Short:        "Skydive client",
	Long:         "Skydive client",
	SilenceUsage: true,
}
View Source
var TopologyCmd = &cobra.Command{
	Use:          "topology",
	Short:        "Request on topology",
	Long:         "Request on topology",
	SilenceUsage: false,
}
View Source
var TopologyRequest = &cobra.Command{
	Use:   "query",
	Short: "query topology",
	Long:  "query topology",
	Run: func(cmd *cobra.Command, args []string) {
		body, err := SendGremlinQuery(&authenticationOpts, gremlinQuery)
		if err != nil {
			logging.GetLogger().Errorf(err.Error())
			os.Exit(1)
		}

		var values interface{}

		decoder := json.NewDecoder(body)
		decoder.UseNumber()

		err = decoder.Decode(&values)
		if err != nil {
			logging.GetLogger().Errorf("Unable to decode response: %s", err.Error())
			os.Exit(1)
		}

		printJSON(values)
	},
}

Functions

func SendGremlinQuery added in v0.4.0

func SendGremlinQuery(auth *shttp.AuthenticationOpts, query string) (io.ReadCloser, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL