@@ -98,6 +98,61 @@ needMoreItems:
98
98
99
99
}
100
100
101
+ func (me * MysqlService ) DescribeBackupsByMysqlIdRegion (ctx context.Context ,
102
+ mysqlId string ,
103
+ leftNumber int64 , region string ) (backupInfos []* cdb.BackupInfo , errRet error ) {
104
+
105
+ logId := tccommon .GetLogId (ctx )
106
+
107
+ listInitSize := leftNumber
108
+ if listInitSize > 500 {
109
+ listInitSize = 500
110
+ }
111
+ backupInfos = make ([]* cdb.BackupInfo , 0 , listInitSize )
112
+
113
+ request := cdb .NewDescribeBackupsRequest ()
114
+ request .InstanceId = & mysqlId
115
+
116
+ var offset , limit int64 = 0 , 50
117
+ needMoreItems:
118
+ if leftNumber <= 0 {
119
+ return
120
+ }
121
+ if leftNumber < limit {
122
+ limit = leftNumber
123
+ }
124
+ request .Limit = & limit
125
+ request .Offset = & offset
126
+ defer func () {
127
+ if errRet != nil {
128
+ log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
129
+ logId , request .GetAction (), request .ToJsonString (), errRet .Error ())
130
+ }
131
+ }()
132
+
133
+ ratelimit .Check (request .GetAction ())
134
+
135
+ response , err := me .client .UseMysqlClientRegion (region ).DescribeBackups (request )
136
+ if err != nil {
137
+ errRet = err
138
+ return
139
+ }
140
+
141
+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
142
+ logId , request .GetAction (), request .ToJsonString (), response .ToJsonString ())
143
+
144
+ totalCount := * response .Response .TotalCount
145
+ leftNumber = leftNumber - limit
146
+ offset += limit
147
+
148
+ backupInfos = append (backupInfos , response .Response .Items ... )
149
+ if leftNumber > 0 && totalCount - offset > 0 {
150
+ goto needMoreItems
151
+ }
152
+ return backupInfos , nil
153
+
154
+ }
155
+
101
156
func (me * MysqlService ) CreateBackup (ctx context.Context , mysqlId string ) (backupId int64 , errRet error ) {
102
157
103
158
logId := tccommon .GetLogId (ctx )
0 commit comments