Skip to content

Commit bd9a99c

Browse files
committed
multi: allow querying actions by group ID
1 parent 3c837a9 commit bd9a99c

File tree

5 files changed

+108
-58
lines changed

5 files changed

+108
-58
lines changed

cmd/litcli/actions.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ var listActionsCommand = cli.Command{
3535
},
3636
cli.StringFlag{
3737
Name: "session_id",
38-
Usage: "The session ID to filter the actions by. If " +
39-
"left empty, then all actions will be " +
40-
"returned.",
38+
Usage: "The hex encoded session ID to filter the " +
39+
"actions by. If left empty, then all actions " +
40+
"will be returned.",
4141
},
4242
cli.Uint64Flag{
4343
Name: "start_timestamp",
@@ -84,6 +84,16 @@ var listActionsCommand = cli.Command{
8484
"index_offset is the index of the action in " +
8585
"the db regardless of filter.",
8686
},
87+
cli.StringFlag{
88+
Name: "group_id",
89+
Usage: "The hex encoded group ID to filter the " +
90+
"actions by. The group ID is the same for " +
91+
"all sessions that have been linked. If a " +
92+
"session has no linked sessions then the " +
93+
"group ID will be the same as the " +
94+
"session ID. This flag will be ignored if " +
95+
"the `session_id` flag is set.",
96+
},
8797
},
8898
}
8999

@@ -109,6 +119,14 @@ func listActions(ctx *cli.Context) error {
109119
}
110120
}
111121

122+
var groupID []byte
123+
if ctx.String("group_id") != "" {
124+
groupID, err = hex.DecodeString(ctx.String("group_id"))
125+
if err != nil {
126+
return err
127+
}
128+
}
129+
112130
resp, err := client.ListActions(
113131
ctxb, &litrpc.ListActionsRequest{
114132
SessionId: sessionID,
@@ -122,6 +140,7 @@ func listActions(ctx *cli.Context) error {
122140
CountTotal: ctx.Bool("count_total"),
123141
StartTimestamp: ctx.Uint64("start_timestamp"),
124142
EndTimestamp: ctx.Uint64("end_timestamp"),
143+
GroupId: groupID,
125144
},
126145
)
127146
if err != nil {

litrpc/firewall.pb.go

Lines changed: 66 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

litrpc/firewall.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ message ListActionsRequest {
120120
considered.
121121
*/
122122
uint64 end_timestamp = 11 [jstype = JS_STRING];
123+
124+
/*
125+
If specified, then only actions under the given group will be queried.
126+
*/
127+
bytes group_id = 12;
123128
}
124129

125130
message ListActionsResponse {

litrpc/firewall.swagger.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@
197197
"type": "string",
198198
"format": "uint64",
199199
"description": "If specified, then only actions created before the given timestamp will be\nconsidered."
200+
},
201+
"group_id": {
202+
"type": "string",
203+
"format": "byte",
204+
"description": "If specified, then only actions under the given group will be queried."
200205
}
201206
}
202207
},

session_rpcserver.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,16 @@ func (s *sessionRpcServer) ListActions(_ context.Context,
725725
if err != nil {
726726
return nil, err
727727
}
728+
} else if req.GroupId != nil {
729+
groupID, err := session.IDFromBytes(req.GroupId)
730+
if err != nil {
731+
return nil, err
732+
}
733+
734+
actions, err = db.ListGroupActions(groupID, filterFn)
735+
if err != nil {
736+
return nil, err
737+
}
728738
} else {
729739
actions, lastIndex, totalCount, err = db.ListActions(
730740
filterFn, query,

0 commit comments

Comments
 (0)