|
1 | 1 | import config from "../../config.js"; |
2 | | -import createClient, { Middleware } from "openapi-fetch"; |
| 2 | +import createClient, { FetchOptions, Middleware } from "openapi-fetch"; |
3 | 3 |
|
4 | | -import { paths, ClusterDescription20240805, NetworkPermissionEntry, CloudDatabaseUser } from "./openapi.js"; |
| 4 | +import { paths, operations } from "./openapi.js"; |
5 | 5 |
|
6 | 6 | export interface OAuthToken { |
7 | 7 | access_token: string; |
@@ -238,105 +238,53 @@ export class ApiClient { |
238 | 238 | } |
239 | 239 | } |
240 | 240 |
|
241 | | - async listProjects() { |
242 | | - const { data } = await this.client.GET(`/api/atlas/v2/groups`); |
| 241 | + async listProjects(options?: FetchOptions<operations["listProjects"]>) { |
| 242 | + const { data } = await this.client.GET(`/api/atlas/v2/groups`, options); |
243 | 243 | return data; |
244 | 244 | } |
245 | 245 |
|
246 | | - async listProjectIpAccessLists(groupId: string) { |
247 | | - const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/accessList`, { |
248 | | - params: { |
249 | | - path: { |
250 | | - groupId, |
251 | | - }, |
252 | | - }, |
253 | | - }); |
| 246 | + async listProjectIpAccessLists(options: FetchOptions<operations["listProjectIpAccessLists"]>) { |
| 247 | + const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/accessList`, options); |
254 | 248 | return data; |
255 | 249 | } |
256 | 250 |
|
257 | | - async createProjectIpAccessList(groupId: string, ...entries: NetworkPermissionEntry[]) { |
258 | | - const { data } = await this.client.POST(`/api/atlas/v2/groups/{groupId}/accessList`, { |
259 | | - params: { |
260 | | - path: { |
261 | | - groupId, |
262 | | - }, |
263 | | - }, |
264 | | - body: entries, |
265 | | - }); |
| 251 | + async createProjectIpAccessList(options: FetchOptions<operations["createProjectIpAccessList"]>) { |
| 252 | + const { data } = await this.client.POST(`/api/atlas/v2/groups/{groupId}/accessList`, options); |
266 | 253 | return data; |
267 | 254 | } |
268 | 255 |
|
269 | | - async getProject(groupId: string) { |
270 | | - const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}`, { |
271 | | - params: { |
272 | | - path: { |
273 | | - groupId, |
274 | | - }, |
275 | | - }, |
276 | | - }); |
| 256 | + async getProject(options: FetchOptions<operations["getProject"]>) { |
| 257 | + const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}`, options); |
277 | 258 | return data; |
278 | 259 | } |
279 | 260 |
|
280 | | - async listClusters(groupId: string) { |
281 | | - const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/clusters`, { |
282 | | - params: { |
283 | | - path: { |
284 | | - groupId, |
285 | | - }, |
286 | | - }, |
287 | | - }); |
| 261 | + async listClusters(options: FetchOptions<operations["listClusters"]>) { |
| 262 | + const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/clusters`, options); |
288 | 263 | return data; |
289 | 264 | } |
290 | 265 |
|
291 | | - async listClustersForAllProjects() { |
292 | | - const { data } = await this.client.GET(`/api/atlas/v2/clusters`); |
| 266 | + async listClustersForAllProjects(options?: FetchOptions<operations["listClustersForAllProjects"]>) { |
| 267 | + const { data } = await this.client.GET(`/api/atlas/v2/clusters`, options); |
293 | 268 | return data; |
294 | 269 | } |
295 | 270 |
|
296 | | - async getCluster(groupId: string, clusterName: string) { |
297 | | - const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/clusters/{clusterName}`, { |
298 | | - params: { |
299 | | - path: { |
300 | | - groupId, |
301 | | - clusterName, |
302 | | - }, |
303 | | - }, |
304 | | - }); |
| 271 | + async getCluster(options: FetchOptions<operations["getCluster"]>) { |
| 272 | + const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/clusters/{clusterName}`, options); |
305 | 273 | return data; |
306 | 274 | } |
307 | 275 |
|
308 | | - async createCluster(groupId: string, cluster: ClusterDescription20240805) { |
309 | | - const { data } = await this.client.POST("/api/atlas/v2/groups/{groupId}/clusters", { |
310 | | - params: { |
311 | | - path: { |
312 | | - groupId, |
313 | | - }, |
314 | | - }, |
315 | | - body: cluster, |
316 | | - }); |
| 276 | + async createCluster(options: FetchOptions<operations["createCluster"]>) { |
| 277 | + const { data } = await this.client.POST("/api/atlas/v2/groups/{groupId}/clusters", options); |
317 | 278 | return data; |
318 | 279 | } |
319 | 280 |
|
320 | | - async createDatabaseUser(groupId: string, user: CloudDatabaseUser) { |
321 | | - const { data } = await this.client.POST("/api/atlas/v2/groups/{groupId}/databaseUsers", { |
322 | | - params: { |
323 | | - path: { |
324 | | - groupId, |
325 | | - }, |
326 | | - }, |
327 | | - body: user, |
328 | | - }); |
| 281 | + async createDatabaseUser(options: FetchOptions<operations["createDatabaseUser"]>) { |
| 282 | + const { data } = await this.client.POST("/api/atlas/v2/groups/{groupId}/databaseUsers", options); |
329 | 283 | return data; |
330 | 284 | } |
331 | 285 |
|
332 | | - async listDatabaseUsers(groupId: string) { |
333 | | - const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/databaseUsers`, { |
334 | | - params: { |
335 | | - path: { |
336 | | - groupId, |
337 | | - }, |
338 | | - }, |
339 | | - }); |
| 286 | + async listDatabaseUsers(options: FetchOptions<operations["listDatabaseUsers"]>) { |
| 287 | + const { data } = await this.client.GET(`/api/atlas/v2/groups/{groupId}/databaseUsers`, options); |
340 | 288 | return data; |
341 | 289 | } |
342 | 290 | } |
0 commit comments