@@ -7,14 +7,15 @@ import (
7
7
"time"
8
8
9
9
dmsV1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1"
10
+ dmsV2 "github.com/actiontech/dms/pkg/dms-common/api/dms/v2"
10
11
"github.com/actiontech/dms/pkg/dms-common/dmsobject"
11
12
dmsCommonAes "github.com/actiontech/dms/pkg/dms-common/pkg/aes"
12
13
"github.com/actiontech/sqle/sqle/errors"
13
14
"github.com/actiontech/sqle/sqle/model"
14
15
"github.com/actiontech/sqle/sqle/pkg/params"
15
16
)
16
17
17
- func getInstances (ctx context.Context , req dmsV1 .ListDBServiceReq ) ([]* model.Instance , error ) {
18
+ func getInstances (ctx context.Context , req dmsV2 .ListDBServiceReq ) ([]* model.Instance , error ) {
18
19
var ret = make ([]* model.Instance , 0 )
19
20
20
21
var limit , pageIndex uint32 = 20 , 1
@@ -55,7 +56,7 @@ func getInstances(ctx context.Context, req dmsV1.ListDBServiceReq) ([]*model.Ins
55
56
return ret , nil
56
57
}
57
58
58
- func getInstance (ctx context.Context , req dmsV1 .ListDBServiceReq ) (* model.Instance , bool , error ) {
59
+ func getInstance (ctx context.Context , req dmsV2 .ListDBServiceReq ) (* model.Instance , bool , error ) {
59
60
newCtx , cancel := context .WithTimeout (ctx , 10 * time .Second )
60
61
defer cancel ()
61
62
@@ -145,21 +146,21 @@ func convertInstance(instance *dmsV1.ListDBService) (*model.Instance, error) {
145
146
}
146
147
147
148
func GetInstancesInProject (ctx context.Context , projectUid string ) ([]* model.Instance , error ) {
148
- return getInstances (ctx , dmsV1 .ListDBServiceReq {
149
+ return getInstances (ctx , dmsV2 .ListDBServiceReq {
149
150
ProjectUid : projectUid ,
150
151
})
151
152
}
152
153
153
- func GetInstancesInProjectByTypeAndBusiness (ctx context.Context , projectUid , dbType , business string ) ([]* model.Instance , error ) {
154
- return getInstances (ctx , dmsV1 .ListDBServiceReq {
155
- ProjectUid : projectUid ,
156
- FilterByDBType : dbType ,
157
- FilterByBusiness : business ,
154
+ func GetInstancesInProjectByTypeAndBusiness (ctx context.Context , projectUid , dbType , environmentTag string ) ([]* model.Instance , error ) {
155
+ return getInstances (ctx , dmsV2 .ListDBServiceReq {
156
+ ProjectUid : projectUid ,
157
+ FilterByDBType : dbType ,
158
+ FilterByEnvironmentTag : environmentTag ,
158
159
})
159
160
}
160
161
161
162
func GetInstancesNameInProjectByRuleTemplateName (ctx context.Context , projectUid , ruleTemplateName string ) ([]string , error ) {
162
- instances , err := getInstances (ctx , dmsV1 .ListDBServiceReq {
163
+ instances , err := getInstances (ctx , dmsV2 .ListDBServiceReq {
163
164
ProjectUid : projectUid ,
164
165
})
165
166
@@ -178,7 +179,7 @@ func GetInstancesNameInProjectByRuleTemplateName(ctx context.Context, projectUid
178
179
}
179
180
180
181
func GetInstancesNameByRuleTemplateName (ctx context.Context , ruleTemplateName string ) ([]string , error ) {
181
- instances , err := getInstances (ctx , dmsV1 .ListDBServiceReq {})
182
+ instances , err := getInstances (ctx , dmsV2 .ListDBServiceReq {})
182
183
183
184
if err != nil {
184
185
return nil , err
@@ -199,7 +200,7 @@ func GetInstanceInProjectByName(ctx context.Context, projectUid, name string) (*
199
200
return nil , false , nil
200
201
}
201
202
202
- return getInstance (ctx , dmsV1 .ListDBServiceReq {
203
+ return getInstance (ctx , dmsV2 .ListDBServiceReq {
203
204
PageSize : 1 ,
204
205
FilterByName : name ,
205
206
ProjectUid : projectUid ,
@@ -208,7 +209,7 @@ func GetInstanceInProjectByName(ctx context.Context, projectUid, name string) (*
208
209
209
210
func GetInstancesInProjectByNames (ctx context.Context , projectUid string , names []string ) (instances []* model.Instance , err error ) {
210
211
for _ , name := range names {
211
- instance , isExist , err := getInstance (ctx , dmsV1 .ListDBServiceReq {
212
+ instance , isExist , err := getInstance (ctx , dmsV2 .ListDBServiceReq {
212
213
PageSize : 1 ,
213
214
FilterByName : name ,
214
215
ProjectUid : projectUid ,
@@ -229,7 +230,7 @@ func GetInstancesInProjectByNames(ctx context.Context, projectUid string, names
229
230
func GetInstanceNamesInProjectByIds (ctx context.Context , projectUid string , instanceIds []string ) ([]string , error ) {
230
231
ret := make ([]string , 0 )
231
232
for _ , instanceId := range instanceIds {
232
- instance , exist , err := getInstance (ctx , dmsV1 .ListDBServiceReq {
233
+ instance , exist , err := getInstance (ctx , dmsV2 .ListDBServiceReq {
233
234
PageSize : 1 ,
234
235
FilterByUID : instanceId ,
235
236
ProjectUid : projectUid ,
@@ -250,7 +251,7 @@ func GetInstanceNamesInProjectByIds(ctx context.Context, projectUid string, inst
250
251
func GetInstanceNamesInProject (ctx context.Context , projectUid string ) ([]string , error ) {
251
252
ret := make ([]string , 0 )
252
253
253
- instances , err := getInstances (ctx , dmsV1 .ListDBServiceReq {
254
+ instances , err := getInstances (ctx , dmsV2 .ListDBServiceReq {
254
255
PageSize : 1 ,
255
256
ProjectUid : projectUid ,
256
257
})
@@ -271,7 +272,7 @@ func GetInstancesByIdWithoutError(instanceId string) (instance model.Instance) {
271
272
return
272
273
}
273
274
274
- inst , exist , err := getInstance (context .TODO (), dmsV1 .ListDBServiceReq {
275
+ inst , exist , err := getInstance (context .TODO (), dmsV2 .ListDBServiceReq {
275
276
PageSize : 1 ,
276
277
FilterByUID : instanceId ,
277
278
})
@@ -286,7 +287,7 @@ func GetInstancesById(ctx context.Context, instanceId string) (*model.Instance,
286
287
return nil , false , nil
287
288
}
288
289
289
- return getInstance (ctx , dmsV1 .ListDBServiceReq {
290
+ return getInstance (ctx , dmsV2 .ListDBServiceReq {
290
291
PageSize : 1 ,
291
292
FilterByUID : instanceId ,
292
293
})
@@ -295,7 +296,7 @@ func GetInstancesById(ctx context.Context, instanceId string) (*model.Instance,
295
296
func GetInstancesByIds (ctx context.Context , instanceIds []uint64 ) ([]* model.Instance , error ) {
296
297
ret := make ([]* model.Instance , 0 )
297
298
for _ , instanceId := range instanceIds {
298
- instance , exist , err := getInstance (ctx , dmsV1 .ListDBServiceReq {
299
+ instance , exist , err := getInstance (ctx , dmsV2 .ListDBServiceReq {
299
300
PageSize : 1 ,
300
301
FilterByUID : strconv .FormatUint (instanceId , 10 ),
301
302
})
@@ -316,7 +317,7 @@ func GetInstanceIdNameMapByIds(ctx context.Context, instanceIds []uint64) (map[u
316
317
// todo: remove duplicate instance id
317
318
ret := make (map [uint64 ]string )
318
319
for _ , instanceId := range instanceIds {
319
- instance , exist , err := getInstance (ctx , dmsV1 .ListDBServiceReq {
320
+ instance , exist , err := getInstance (ctx , dmsV2 .ListDBServiceReq {
320
321
PageSize : 1 ,
321
322
FilterByUID : strconv .FormatUint (instanceId , 10 ),
322
323
})
@@ -338,7 +339,7 @@ func GetInstanceInProjectById(ctx context.Context, projectUid string, instanceId
338
339
return nil , false , nil
339
340
}
340
341
341
- return getInstance (ctx , dmsV1 .ListDBServiceReq {
342
+ return getInstance (ctx , dmsV2 .ListDBServiceReq {
342
343
PageSize : 1 ,
343
344
FilterByUID : strconv .FormatUint (instanceId , 10 ),
344
345
ProjectUid : projectUid ,
@@ -348,7 +349,7 @@ func GetInstanceInProjectById(ctx context.Context, projectUid string, instanceId
348
349
func GetInstancesInProjectByIds (ctx context.Context , projectUid string , instanceIds []uint64 ) ([]* model.Instance , error ) {
349
350
ret := make ([]* model.Instance , 0 )
350
351
for _ , instanceId := range instanceIds {
351
- instance , exist , err := getInstance (ctx , dmsV1 .ListDBServiceReq {
352
+ instance , exist , err := getInstance (ctx , dmsV2 .ListDBServiceReq {
352
353
PageSize : 1 ,
353
354
FilterByUID : strconv .FormatUint (instanceId , 10 ),
354
355
ProjectUid : projectUid ,
@@ -372,7 +373,7 @@ type InstanceTypeCount struct {
372
373
}
373
374
374
375
func GetInstanceCountGroupType (ctx context.Context ) ([]InstanceTypeCount , error ) {
375
- instances , err := getInstances (ctx , dmsV1 .ListDBServiceReq {})
376
+ instances , err := getInstances (ctx , dmsV2 .ListDBServiceReq {})
376
377
377
378
if err != nil {
378
379
return nil , err
0 commit comments