forked from usnistgov/ndn-dpdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathndt.go
77 lines (71 loc) · 1.36 KB
/
ndt.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"github.com/urfave/cli/v2"
)
func init() {
var name string
defineCommand(&cli.Command{
Category: "ndt",
Name: "list-ndt",
Usage: "List NDT entries",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "filter by `name`",
Destination: &name,
},
},
Action: func(c *cli.Context) error {
vars := map[string]any{}
if name != "" {
vars["name"] = name
}
return clientDoPrint(c.Context, `
query queryNdt($name: Name) {
ndt(name: $name) {
index
value
hits
}
}
`, vars, "ndt")
},
})
}
func init() {
var name string
var value int
defineCommand(&cli.Command{
Category: "ndt",
Name: "update-ndt",
Usage: "Update an NDT entry",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "`name` to derive entry index",
Destination: &name,
Required: true,
},
&cli.IntFlag{
Name: "value",
Usage: "entry `value`",
Destination: &value,
Required: true,
},
},
Action: func(c *cli.Context) error {
return clientDoPrint(c.Context, `
mutation updateNdt($name: Name!, $value: Int!) {
updateNdt(name: $name, value: $value) {
index
value
hits
}
}
`, map[string]any{
"name": name,
"value": value,
}, "updateNdt")
},
})
}