forked from mistsys/go-tenable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
46 lines (39 loc) · 1.03 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package tenablecmd
import (
"context"
"fmt"
"github.com/spf13/cobra"
)
var serverCmd = &cobra.Command{
Use: "server COMMAND",
Short: "Use the Tenable server API",
Args: cobra.MinimumNArgs(1),
}
// serverStatus represents the "server/status" command
var serverStatusCmd = &cobra.Command{
Use: "status",
Short: "Query server status.",
Run: func(cmd *cobra.Command, args []string) {
_, response, err := client.Server.Status(context.Background())
if err != nil {
fmt.Printf("Error getting server status. %s", err)
}
outputter.Output(response.BodyJson())
},
}
var serverPropertiesCmd = &cobra.Command{
Use: "properties",
Short: "Query server properties.",
Run: func(cmd *cobra.Command, args []string) {
_, response, err := client.Server.Properties(context.Background())
if err != nil {
fmt.Println("Error getting server properties.", err)
}
outputter.Output(response.BodyJson())
},
}
func init() {
rootCmd.AddCommand(serverCmd)
serverCmd.AddCommand(serverStatusCmd)
serverCmd.AddCommand(serverPropertiesCmd)
}