File tree Expand file tree Collapse file tree 2 files changed +60
-7
lines changed Expand file tree Collapse file tree 2 files changed +60
-7
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,38 @@ export class InspectClusterTool extends AtlasToolBase {
3131 throw new Error ( "Cluster not found" ) ;
3232 }
3333
34+ const regionConfigs = ( cluster . replicationSpecs || [ ] )
35+ . map (
36+ ( replicationSpec ) =>
37+ ( replicationSpec . regionConfigs || [ ] ) as {
38+ providerName : string ;
39+ electableSpecs ?: {
40+ instanceSize : string ;
41+ } ;
42+ readOnlySpecs ?: {
43+ instanceSize : string ;
44+ } ;
45+ } [ ]
46+ )
47+ . flat ( )
48+ . map ( ( regionConfig ) => {
49+ return {
50+ providerName : regionConfig . providerName ,
51+ instanceSize : regionConfig . electableSpecs ?. instanceSize || regionConfig . readOnlySpecs ?. instanceSize ,
52+ } ;
53+ } ) ;
54+
55+ const instanceSize = ( regionConfigs . length <= 0 ? undefined : regionConfigs [ 0 ] . instanceSize ) || "UNKNOWN" ;
56+
57+ const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED" ;
58+
3459 return {
3560 content : [
3661 {
3762 type : "text" ,
38- text : `Cluster Name | State | MongoDB Version | Connection String
39- ----------------|----------------|----------------|----------------|----------------
40- ${ cluster . name } | ${ cluster . stateName } | ${ cluster . mongoDBVersion || "N/A" } | ${ cluster . connectionStrings ?. standard || "N/A" } `,
63+ text : `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
64+ ----------------|----------------|----------------|----------------|----------------|----------------
65+ ${ cluster . name } | ${ clusterInstanceType } | ${ clusterInstanceType == "DEDICATED" ? instanceSize : "N/A" } | ${ cluster . stateName } | ${ cluster . mongoDBVersion || "N/A" } | ${ cluster . connectionStrings ?. standardSrv || cluster . connectionStrings ?. standard || "N/A" } `,
4166 } ,
4267 ] ,
4368 } ;
Original file line number Diff line number Diff line change @@ -79,9 +79,37 @@ ${rows}`,
7979 }
8080 const rows = clusters . results
8181 . map ( ( cluster ) => {
82- const connectionString = cluster . connectionStrings ?. standard || "N/A" ;
82+ const connectionString =
83+ cluster . connectionStrings ?. standardSrv || cluster . connectionStrings ?. standard || "N/A" ;
8384 const mongoDBVersion = cluster . mongoDBVersion || "N/A" ;
84- return `${ cluster . name } | ${ cluster . stateName } | ${ mongoDBVersion } | ${ connectionString } ` ;
85+ const regionConfigs = ( cluster . replicationSpecs || [ ] )
86+ . map (
87+ ( replicationSpec ) =>
88+ ( replicationSpec . regionConfigs || [ ] ) as {
89+ providerName : string ;
90+ electableSpecs ?: {
91+ instanceSize : string ;
92+ } ;
93+ readOnlySpecs ?: {
94+ instanceSize : string ;
95+ } ;
96+ } [ ]
97+ )
98+ . flat ( )
99+ . map ( ( regionConfig ) => {
100+ return {
101+ providerName : regionConfig . providerName ,
102+ instanceSize :
103+ regionConfig . electableSpecs ?. instanceSize || regionConfig . readOnlySpecs ?. instanceSize ,
104+ } ;
105+ } ) ;
106+
107+ const instanceSize =
108+ ( regionConfigs . length <= 0 ? undefined : regionConfigs [ 0 ] . instanceSize ) || "UNKNOWN" ;
109+
110+ const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED" ;
111+
112+ return `${ cluster . name } | ${ clusterInstanceType } | ${ clusterInstanceType == "DEDICATED" ? instanceSize : "N/A" } | ${ cluster . stateName } | ${ mongoDBVersion } | ${ connectionString } ` ;
85113 } )
86114 . join ( "\n" ) ;
87115 return {
@@ -92,8 +120,8 @@ ${rows}`,
92120 } ,
93121 {
94122 type : "text" ,
95- text : `Cluster Name | State | MongoDB Version | Connection String
96- ----------------|----------------|----------------|----------------|----------------
123+ text : `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
124+ ----------------|----------------|----------------|----------------|----------------|----------------
97125${ rows } `,
98126 } ,
99127 ] ,
You can’t perform that action at this time.
0 commit comments