5
5
"math"
6
6
"time"
7
7
8
+ "github.com/google/uuid"
8
9
"golang.org/x/xerrors"
9
10
10
11
"github.com/coder/coder/v2/codersdk"
@@ -32,8 +33,8 @@ func (r *RootCmd) listInterceptions() *serpent.Command {
32
33
startedAfterRaw string
33
34
provider string
34
35
model string
36
+ afterIDRaw string
35
37
limit int64
36
- offset int64
37
38
)
38
39
39
40
return & serpent.Command {
@@ -70,18 +71,18 @@ func (r *RootCmd) listInterceptions() *serpent.Command {
70
71
Default :"" ,
71
72
Value :serpent .StringOf (& model ),
72
73
},
74
+ {
75
+ Flag :"after-id" ,
76
+ Description :"The ID of the last result on the previous page to use as a pagination cursor." ,
77
+ Default :"" ,
78
+ Value :serpent .StringOf (& afterIDRaw ),
79
+ },
73
80
{
74
81
Flag :"limit" ,
75
82
Description :`The limit of results to return.` ,
76
83
Default :"100" ,
77
84
Value :serpent .Int64Of (& limit ),
78
85
},
79
- {
80
- Flag :"offset" ,
81
- Description :`The offset of results to return.` ,
82
- Default :"0" ,
83
- Value :serpent .Int64Of (& offset ),
84
- },
85
86
},
86
87
Handler :func (inv * serpent.Invocation )error {
87
88
client ,err := r .InitClient (inv )
@@ -105,6 +106,14 @@ func (r *RootCmd) listInterceptions() *serpent.Command {
105
106
}
106
107
}
107
108
109
+ afterID := uuid .Nil
110
+ if afterIDRaw != "" {
111
+ afterID ,err = uuid .Parse (afterIDRaw )
112
+ if err != nil {
113
+ return xerrors .Errorf ("parse after_id filter value %q: %w" ,afterIDRaw ,err )
114
+ }
115
+ }
116
+
108
117
if limit > math .MaxInt32 {
109
118
return xerrors .Errorf ("limit value to high" )
110
119
}
@@ -115,10 +124,9 @@ func (r *RootCmd) listInterceptions() *serpent.Command {
115
124
exCli := codersdk .NewExperimentalClient (client )
116
125
resp ,err := exCli .AIBridgeListInterceptions (inv .Context (), codersdk.AIBridgeListInterceptionsFilter {
117
126
Pagination : codersdk.Pagination {
127
+ AfterID :afterID ,
118
128
// #nosec G115 - Safe conversion for pagination limit which is expected to be within int32 range
119
129
Limit :int (limit ),
120
- // #nosec G115 - Safe conversion for pagination offset which is expected to be within int32 range
121
- Offset :int (offset ),
122
130
},
123
131
Initiator :initiator ,
124
132
StartedBefore :startedBefore ,