@@ -55,14 +55,6 @@ export class ApiClient {
5555 } ,
5656 } ;
5757
58- private readonly errorMiddleware : Middleware = {
59- async onResponse ( { response } ) {
60- if ( ! response . ok ) {
61- throw await ApiClientError . fromResponse ( response ) ;
62- }
63- } ,
64- } ;
65-
6658 constructor ( options : ApiClientOptions ) {
6759 this . options = {
6860 ...options ,
@@ -91,7 +83,6 @@ export class ApiClient {
9183 } ) ;
9284 this . client . use ( this . authMiddleware ) ;
9385 }
94- this . client . use ( this . errorMiddleware ) ;
9586 }
9687
9788 public hasCredentials ( ) : boolean {
@@ -151,83 +142,152 @@ export class ApiClient {
151142
152143 // DO NOT EDIT. This is auto-generated code.
153144 async listClustersForAllProjects ( options ?: FetchOptions < operations [ "listClustersForAllProjects" ] > ) {
154- const { data } = await this . client . GET ( "/api/atlas/v2/clusters" , options ) ;
145+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/clusters" , options ) ;
146+ if ( error ) {
147+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
148+ }
155149 return data ;
156150 }
157151
158152 async listProjects ( options ?: FetchOptions < operations [ "listProjects" ] > ) {
159- const { data } = await this . client . GET ( "/api/atlas/v2/groups" , options ) ;
153+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/groups" , options ) ;
154+ if ( error ) {
155+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
156+ }
160157 return data ;
161158 }
162159
163160 async createProject ( options : FetchOptions < operations [ "createProject" ] > ) {
164- const { data } = await this . client . POST ( "/api/atlas/v2/groups" , options ) ;
161+ const { data, error, response } = await this . client . POST ( "/api/atlas/v2/groups" , options ) ;
162+ if ( error ) {
163+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
164+ }
165165 return data ;
166166 }
167167
168168 async deleteProject ( options : FetchOptions < operations [ "deleteProject" ] > ) {
169- await this . client . DELETE ( "/api/atlas/v2/groups/{groupId}" , options ) ;
169+ const { error, response } = await this . client . DELETE ( "/api/atlas/v2/groups/{groupId}" , options ) ;
170+ if ( error ) {
171+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
172+ }
170173 }
171174
172175 async getProject ( options : FetchOptions < operations [ "getProject" ] > ) {
173- const { data } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}" , options ) ;
176+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}" , options ) ;
177+ if ( error ) {
178+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
179+ }
174180 return data ;
175181 }
176182
177183 async listProjectIpAccessLists ( options : FetchOptions < operations [ "listProjectIpAccessLists" ] > ) {
178- const { data } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}/accessList" , options ) ;
184+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}/accessList" , options ) ;
185+ if ( error ) {
186+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
187+ }
179188 return data ;
180189 }
181190
182191 async createProjectIpAccessList ( options : FetchOptions < operations [ "createProjectIpAccessList" ] > ) {
183- const { data } = await this . client . POST ( "/api/atlas/v2/groups/{groupId}/accessList" , options ) ;
192+ const { data, error, response } = await this . client . POST ( "/api/atlas/v2/groups/{groupId}/accessList" , options ) ;
193+ if ( error ) {
194+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
195+ }
184196 return data ;
185197 }
186198
187199 async deleteProjectIpAccessList ( options : FetchOptions < operations [ "deleteProjectIpAccessList" ] > ) {
188- await this . client . DELETE ( "/api/atlas/v2/groups/{groupId}/accessList/{entryValue}" , options ) ;
200+ const { error, response } = await this . client . DELETE (
201+ "/api/atlas/v2/groups/{groupId}/accessList/{entryValue}" ,
202+ options
203+ ) ;
204+ if ( error ) {
205+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
206+ }
189207 }
190208
191209 async listClusters ( options : FetchOptions < operations [ "listClusters" ] > ) {
192- const { data } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}/clusters" , options ) ;
210+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}/clusters" , options ) ;
211+ if ( error ) {
212+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
213+ }
193214 return data ;
194215 }
195216
196217 async createCluster ( options : FetchOptions < operations [ "createCluster" ] > ) {
197- const { data } = await this . client . POST ( "/api/atlas/v2/groups/{groupId}/clusters" , options ) ;
218+ const { data, error, response } = await this . client . POST ( "/api/atlas/v2/groups/{groupId}/clusters" , options ) ;
219+ if ( error ) {
220+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
221+ }
198222 return data ;
199223 }
200224
201225 async deleteCluster ( options : FetchOptions < operations [ "deleteCluster" ] > ) {
202- await this . client . DELETE ( "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" , options ) ;
226+ const { error, response } = await this . client . DELETE (
227+ "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" ,
228+ options
229+ ) ;
230+ if ( error ) {
231+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
232+ }
203233 }
204234
205235 async getCluster ( options : FetchOptions < operations [ "getCluster" ] > ) {
206- const { data } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" , options ) ;
236+ const { data, error, response } = await this . client . GET (
237+ "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}" ,
238+ options
239+ ) ;
240+ if ( error ) {
241+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
242+ }
207243 return data ;
208244 }
209245
210246 async listDatabaseUsers ( options : FetchOptions < operations [ "listDatabaseUsers" ] > ) {
211- const { data } = await this . client . GET ( "/api/atlas/v2/groups/{groupId}/databaseUsers" , options ) ;
247+ const { data, error, response } = await this . client . GET (
248+ "/api/atlas/v2/groups/{groupId}/databaseUsers" ,
249+ options
250+ ) ;
251+ if ( error ) {
252+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
253+ }
212254 return data ;
213255 }
214256
215257 async createDatabaseUser ( options : FetchOptions < operations [ "createDatabaseUser" ] > ) {
216- const { data } = await this . client . POST ( "/api/atlas/v2/groups/{groupId}/databaseUsers" , options ) ;
258+ const { data, error, response } = await this . client . POST (
259+ "/api/atlas/v2/groups/{groupId}/databaseUsers" ,
260+ options
261+ ) ;
262+ if ( error ) {
263+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
264+ }
217265 return data ;
218266 }
219267
220268 async deleteDatabaseUser ( options : FetchOptions < operations [ "deleteDatabaseUser" ] > ) {
221- await this . client . DELETE ( "/api/atlas/v2/groups/{groupId}/databaseUsers/{databaseName}/{username}" , options ) ;
269+ const { error, response } = await this . client . DELETE (
270+ "/api/atlas/v2/groups/{groupId}/databaseUsers/{databaseName}/{username}" ,
271+ options
272+ ) ;
273+ if ( error ) {
274+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
275+ }
222276 }
223277
224278 async listOrganizations ( options ?: FetchOptions < operations [ "listOrganizations" ] > ) {
225- const { data } = await this . client . GET ( "/api/atlas/v2/orgs" , options ) ;
279+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/orgs" , options ) ;
280+ if ( error ) {
281+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
282+ }
226283 return data ;
227284 }
228285
229286 async listOrganizationProjects ( options : FetchOptions < operations [ "listOrganizationProjects" ] > ) {
230- const { data } = await this . client . GET ( "/api/atlas/v2/orgs/{orgId}/groups" , options ) ;
287+ const { data, error, response } = await this . client . GET ( "/api/atlas/v2/orgs/{orgId}/groups" , options ) ;
288+ if ( error ) {
289+ throw new ApiClientError ( "error calling Atlas API" , response , error ) ;
290+ }
231291 return data ;
232292 }
233293
0 commit comments