@@ -26,6 +26,7 @@ import {
26
26
AcknowledgedResponse ,
27
27
CreateSnapshotResponse ,
28
28
RestoreSnapshotResponse ,
29
+ CatSnapshots ,
29
30
} from "../models/interfaces" ;
30
31
import { FailedServerResponse , ServerResponse } from "../models/types" ;
31
32
import { MDSEnabledClientService } from "./MDSEnabledClientService" ;
@@ -539,12 +540,8 @@ export default class SnapshotManagementService extends MDSEnabledClientService {
539
540
} ) ) as CatRepository [ ] ;
540
541
541
542
for ( let i = 0 ; i < res . length ; i ++ ) {
542
- const getSnapshotRes : GetSnapshotResponse = ( await callWithRequest ( "snapshot.get" , {
543
- repository : res [ i ] . id ,
544
- snapshot : "_all" ,
545
- ignore_unavailable : true ,
546
- } ) ) as GetSnapshotResponse ;
547
- res [ i ] . snapshotCount = getSnapshotRes . snapshots . length ;
543
+ let catSnapshotResponse = await this . _safecatSnapshotForRepo ( callWithRequest , res [ i ] . id ) ;
544
+ res [ i ] . snapshotCount = catSnapshotResponse ?. length ;
548
545
}
549
546
550
547
return response . custom ( {
@@ -559,6 +556,24 @@ export default class SnapshotManagementService extends MDSEnabledClientService {
559
556
}
560
557
} ;
561
558
559
+ private async _safecatSnapshotForRepo (
560
+ callWithRequest : ( endpoint : string , clientParams : Record < string , any > , options ?: LegacyCallAPIOptions | undefined ) => Promise < unknown > ,
561
+ repositoryName : string
562
+ ) : Promise < CatSnapshots [ ] | undefined > {
563
+ try {
564
+ const catSnapshotRes : CatSnapshots [ ] = ( await callWithRequest ( "cat.snapshots" , {
565
+ format : "json" ,
566
+ repository : repositoryName ,
567
+ ignore_unavailable : true ,
568
+ } ) ) as CatSnapshots [ ] ;
569
+
570
+ return catSnapshotRes ;
571
+ } catch ( err ) {
572
+ console . error ( `Index Management - SnapshotManagementService - _safeCatSnapshot:` , err ) ;
573
+ return undefined ;
574
+ }
575
+ }
576
+
562
577
deleteRepository = async (
563
578
context : RequestHandlerContext ,
564
579
request : OpenSearchDashboardsRequest ,
0 commit comments