@@ -119,6 +119,72 @@ func backupRestoreBuilder(c *core.Command) *core.Command {
119119 return c
120120}
121121
122+ func backupListBuilder (c * core.Command ) * core.Command {
123+ type customBackup struct {
124+ ID string `json:"ID"`
125+ Name string `json:"name"`
126+ InstanceID string `json:"instance_ID"`
127+ Exported bool `json:"exported"`
128+ Status rdb.DatabaseBackupStatus `json:"status"`
129+ }
130+
131+ c .View = & core.View {
132+ Fields : []* core.ViewField {
133+ {
134+ Label : "ID" ,
135+ FieldName : "ID" ,
136+ },
137+ {
138+ Label : "Name" ,
139+ FieldName : "Name" ,
140+ },
141+ {
142+ Label : "Status" ,
143+ FieldName : "Status" ,
144+ },
145+ {
146+ Label : "Instance ID" ,
147+ FieldName : "InstanceID" ,
148+ },
149+ {
150+ Label : "Exported" ,
151+ FieldName : "Exported" ,
152+ },
153+ },
154+ }
155+
156+ c .AddInterceptors (func (ctx context.Context , argsI interface {}, runner core.CommandRunner ) (i interface {}, err error ) {
157+ listBackupResp , err := runner (ctx , argsI )
158+ if err != nil {
159+ return listBackupResp , err
160+ }
161+ backupList := listBackupResp .([]* rdb.DatabaseBackup )
162+ var res []customBackup
163+ for _ , backup := range backupList {
164+ res = append (res , customBackup {
165+ ID : backup .ID ,
166+ Name : backup .Name ,
167+ Status : backup .Status ,
168+ InstanceID : backup .InstanceID ,
169+ Exported : isExported (backup .DownloadURLExpiresAt ),
170+ })
171+ }
172+ return res , nil
173+ })
174+
175+ return c
176+ }
177+
178+ func isExported (expirationDate * time.Time ) bool {
179+ var exported bool
180+ if expirationDate == nil {
181+ exported = false
182+ } else {
183+ exported = time .Now ().Before (* expirationDate )
184+ }
185+ return exported
186+ }
187+
122188func getDefaultFileName (rawURL string ) (string , error ) {
123189 u , err := url .Parse (rawURL )
124190 if err != nil {
0 commit comments