11import  config  from  "../../config.js" ; 
22import  createClient ,  {  Client ,  FetchOptions ,  Middleware  }  from  "openapi-fetch" ; 
33import  {  AccessToken ,  ClientCredentials  }  from  "simple-oauth2" ; 
4- 
4+ import   {   ApiClientError   }   from   "./apiClientError.js" ; 
55import  {  paths ,  operations  }  from  "./openapi.js" ; 
66
77const  ATLAS_API_VERSION  =  "2025-03-12" ; 
88
9- export  class  ApiClientError  extends  Error  { 
10-     response ?: Response ; 
11- 
12-     constructor ( message : string ,  response : Response  |  undefined  =  undefined )  { 
13-         super ( message ) ; 
14-         this . name  =  "ApiClientError" ; 
15-         this . response  =  response ; 
16-     } 
17- 
18-     static  async  fromResponse ( response : Response ,  message ?: string ) : Promise < ApiClientError >  { 
19-         message  ||=  `error calling Atlas API` ; 
20-         try  { 
21-             const  text  =  await  response . text ( ) ; 
22-             return  new  ApiClientError ( `${ message } ${ response . status } ${ response . statusText } ${ text }  ,  response ) ; 
23-         }  catch  { 
24-             return  new  ApiClientError ( `${ message } ${ response . status } ${ response . statusText }  ,  response ) ; 
25-         } 
26-     } 
27- } 
28- 
299export  interface  ApiClientOptions  { 
3010    credentials ?: { 
3111        clientId : string ; 
@@ -79,15 +59,13 @@ export class ApiClient {
7959        } , 
8060    } ; 
8161
82-     constructor ( options : ApiClientOptions )  { 
83-         const  defaultOptions  =  { 
84-             baseUrl : "https://cloud.mongodb.com/" , 
85-             userAgent : `AtlasMCP/${ config . version } ${ process . platform } ${ process . arch } ${ process . env . HOSTNAME  ||  "unknown" }  , 
86-         } ; 
87- 
62+     constructor ( options ?: ApiClientOptions )  { 
8863        this . options  =  { 
89-             ...defaultOptions , 
9064            ...options , 
65+             baseUrl : options ?. baseUrl  ||  "https://cloud.mongodb.com/" , 
66+             userAgent :
67+                 options ?. userAgent  || 
68+                 `AtlasMCP/${ config . version } ${ process . platform } ${ process . arch } ${ process . env . HOSTNAME  ||  "unknown" }  , 
9169        } ; 
9270
9371        this . client  =  createClient < paths > ( { 
@@ -138,38 +116,39 @@ export class ApiClient {
138116        } > ; 
139117    } 
140118
141-     async  listProjects ( options ?: FetchOptions < operations [ "listProjects" ] > )  { 
142-         const  {  data }  =  await  this . client . GET ( `/api/atlas/v2/groups` ,  options ) ; 
119+     // DO NOT EDIT. This is auto-generated code. 
120+     async  listClustersForAllProjects ( options ?: FetchOptions < operations [ "listClustersForAllProjects" ] > )  { 
121+         const  {  data }  =  await  this . client . GET ( "/api/atlas/v2/clusters" ,  options ) ; 
143122        return  data ; 
144123    } 
145124
146-     async  listProjectIpAccessLists ( options : FetchOptions < operations [ "listProjectIpAccessLists " ] > )  { 
147-         const  {  data }  =  await  this . client . GET ( ` /api/atlas/v2/groups/{groupId}/accessList` ,  options ) ; 
125+     async  listProjects ( options ? : FetchOptions < operations [ "listProjects " ] > )  { 
126+         const  {  data }  =  await  this . client . GET ( " /api/atlas/v2/groups" ,  options ) ; 
148127        return  data ; 
149128    } 
150129
151-     async  createProjectIpAccessList ( options : FetchOptions < operations [ "createProjectIpAccessList " ] > )  { 
152-         const  {  data }  =  await  this . client . POST ( ` /api/atlas/v2/groups/{groupId}/accessList` ,  options ) ; 
130+     async  createProject ( options : FetchOptions < operations [ "createProject " ] > )  { 
131+         const  {  data }  =  await  this . client . POST ( " /api/atlas/v2/groups" ,  options ) ; 
153132        return  data ; 
154133    } 
155134
156135    async  getProject ( options : FetchOptions < operations [ "getProject" ] > )  { 
157-         const  {  data }  =  await  this . client . GET ( ` /api/atlas/v2/groups/{groupId}` ,  options ) ; 
136+         const  {  data }  =  await  this . client . GET ( " /api/atlas/v2/groups/{groupId}" ,  options ) ; 
158137        return  data ; 
159138    } 
160139
161-     async  listClusters ( options : FetchOptions < operations [ "listClusters " ] > )  { 
162-         const  {  data }  =  await  this . client . GET ( ` /api/atlas/v2/groups/{groupId}/clusters` ,  options ) ; 
140+     async  listProjectIpAccessLists ( options : FetchOptions < operations [ "listProjectIpAccessLists " ] > )  { 
141+         const  {  data }  =  await  this . client . GET ( " /api/atlas/v2/groups/{groupId}/accessList" ,  options ) ; 
163142        return  data ; 
164143    } 
165144
166-     async  listClustersForAllProjects ( options ? : FetchOptions < operations [ "listClustersForAllProjects " ] > )  { 
167-         const  {  data }  =  await  this . client . GET ( ` /api/atlas/v2/clusters` ,  options ) ; 
145+     async  createProjectIpAccessList ( options : FetchOptions < operations [ "createProjectIpAccessList " ] > )  { 
146+         const  {  data }  =  await  this . client . POST ( " /api/atlas/v2/groups/{groupId}/accessList" ,  options ) ; 
168147        return  data ; 
169148    } 
170149
171-     async  getCluster ( options : FetchOptions < operations [ "getCluster " ] > )  { 
172-         const  {  data }  =  await  this . client . GET ( ` /api/atlas/v2/groups/{groupId}/clusters/{clusterName}` ,  options ) ; 
150+     async  listClusters ( options : FetchOptions < operations [ "listClusters " ] > )  { 
151+         const  {  data }  =  await  this . client . GET ( " /api/atlas/v2/groups/{groupId}/clusters" ,  options ) ; 
173152        return  data ; 
174153    } 
175154
@@ -178,13 +157,19 @@ export class ApiClient {
178157        return  data ; 
179158    } 
180159
181-     async  createDatabaseUser ( options : FetchOptions < operations [ "createDatabaseUser " ] > )  { 
182-         const  {  data }  =  await  this . client . POST ( "/api/atlas/v2/groups/{groupId}/databaseUsers " ,  options ) ; 
160+     async  getCluster ( options : FetchOptions < operations [ "getCluster " ] > )  { 
161+         const  {  data }  =  await  this . client . GET ( "/api/atlas/v2/groups/{groupId}/clusters/{clusterName} " ,  options ) ; 
183162        return  data ; 
184163    } 
185164
186165    async  listDatabaseUsers ( options : FetchOptions < operations [ "listDatabaseUsers" ] > )  { 
187-         const  {  data }  =  await  this . client . GET ( `/api/atlas/v2/groups/{groupId}/databaseUsers` ,  options ) ; 
166+         const  {  data }  =  await  this . client . GET ( "/api/atlas/v2/groups/{groupId}/databaseUsers" ,  options ) ; 
167+         return  data ; 
168+     } 
169+ 
170+     async  createDatabaseUser ( options : FetchOptions < operations [ "createDatabaseUser" ] > )  { 
171+         const  {  data }  =  await  this . client . POST ( "/api/atlas/v2/groups/{groupId}/databaseUsers" ,  options ) ; 
188172        return  data ; 
189173    } 
174+     // DO NOT EDIT. This is auto-generated code. 
190175} 
0 commit comments