@@ -55,14 +55,6 @@ export class ApiClient {
55
55
} ,
56
56
} ;
57
57
58
- private readonly errorMiddleware : Middleware = {
59
- async onResponse ( { response } ) {
60
- if ( ! response . ok ) {
61
- throw await ApiClientError . fromResponse ( response ) ;
62
- }
63
- } ,
64
- } ;
65
-
66
58
constructor ( options : ApiClientOptions ) {
67
59
this . options = {
68
60
...options ,
@@ -91,7 +83,6 @@ export class ApiClient {
91
83
} ) ;
92
84
this . client . use ( this . authMiddleware ) ;
93
85
}
94
- this . client . use ( this . errorMiddleware ) ;
95
86
}
96
87
97
88
public hasCredentials ( ) : boolean {
@@ -151,83 +142,152 @@ export class ApiClient {
151
142
152
143
// DO NOT EDIT. This is auto-generated code.
153
144
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 ApiClientError . fromError ( response , error ) ;
148
+ }
155
149
return data ;
156
150
}
157
151
158
152
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 ApiClientError . fromError ( response , error ) ;
156
+ }
160
157
return data ;
161
158
}
162
159
163
160
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 ApiClientError . fromError ( response , error ) ;
164
+ }
165
165
return data ;
166
166
}
167
167
168
168
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 ApiClientError . fromError ( response , error ) ;
172
+ }
170
173
}
171
174
172
175
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 ApiClientError . fromError ( response , error ) ;
179
+ }
174
180
return data ;
175
181
}
176
182
177
183
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 ApiClientError . fromError ( response , error ) ;
187
+ }
179
188
return data ;
180
189
}
181
190
182
191
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 ApiClientError . fromError ( response , error ) ;
195
+ }
184
196
return data ;
185
197
}
186
198
187
199
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 ApiClientError . fromError ( response , error ) ;
206
+ }
189
207
}
190
208
191
209
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 ApiClientError . fromError ( response , error ) ;
213
+ }
193
214
return data ;
194
215
}
195
216
196
217
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 ApiClientError . fromError ( response , error ) ;
221
+ }
198
222
return data ;
199
223
}
200
224
201
225
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 ApiClientError . fromError ( response , error ) ;
232
+ }
203
233
}
204
234
205
235
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 ApiClientError . fromError ( response , error ) ;
242
+ }
207
243
return data ;
208
244
}
209
245
210
246
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 ApiClientError . fromError ( response , error ) ;
253
+ }
212
254
return data ;
213
255
}
214
256
215
257
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 ApiClientError . fromError ( response , error ) ;
264
+ }
217
265
return data ;
218
266
}
219
267
220
268
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 ApiClientError . fromError ( response , error ) ;
275
+ }
222
276
}
223
277
224
278
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 ApiClientError . fromError ( response , error ) ;
282
+ }
226
283
return data ;
227
284
}
228
285
229
286
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 ApiClientError . fromError ( response , error ) ;
290
+ }
231
291
return data ;
232
292
}
233
293
0 commit comments