Skip to content

Commit cfbc95d

Browse files
committed
fix
1 parent abc55f2 commit cfbc95d

File tree

4 files changed

+4656
-1299
lines changed

4 files changed

+4656
-1299
lines changed

scripts/apply.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async function main(): Promise<void> {
3636
path: string;
3737
method: string;
3838
operationId: string;
39+
methodName: string;
3940
requiredParams: boolean;
4041
tag: string;
4142
hasResponseBody: boolean;
@@ -45,7 +46,9 @@ async function main(): Promise<void> {
4546
for (const path in openapi.paths) {
4647
for (const method in openapi.paths[path]) {
4748
// @ts-expect-error This is a workaround for the OpenAPI types
48-
const operation = openapi.paths[path][method] as OpenAPIV3_1.OperationObject;
49+
const operation = openapi.paths[path][method] as OpenAPIV3_1.OperationObject & {
50+
"x-xgen-operation-id-override": string;
51+
};
4952

5053
if (!operation.operationId || !operation.tags?.length) {
5154
continue;
@@ -81,6 +84,7 @@ async function main(): Promise<void> {
8184
operations.push({
8285
path,
8386
method: method.toUpperCase(),
87+
methodName: operation["x-xgen-operation-id-override"] || operation.operationId || "",
8488
operationId: operation.operationId || "",
8589
requiredParams,
8690
hasResponseBody,
@@ -91,9 +95,9 @@ async function main(): Promise<void> {
9195

9296
const operationOutput = operations
9397
.map((operation) => {
94-
const { operationId, method, path, requiredParams, hasResponseBody } = operation;
98+
const { methodName, operationId, method, path, requiredParams, hasResponseBody } = operation;
9599
return `// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
96-
async ${operationId}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
100+
async ${methodName}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
97101
const { ${hasResponseBody ? `data, ` : ``}error, response } = await this.client.${method}("${path}", options);
98102
if (error) {
99103
throw ApiClientError.fromError(response, error);

scripts/filter.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,16 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
5151

5252
for (const path in openapi.paths) {
5353
const filteredMethods = {} as OpenAPIV3_1.PathItemObject;
54-
for (const method in openapi.paths[path]) {
55-
// @ts-expect-error This is a workaround for the OpenAPI types
56-
if (allowedOperations.includes((openapi.paths[path][method] as { operationId: string }).operationId)) {
54+
// @ts-expect-error This is a workaround for the OpenAPI types
55+
for (const [method, operation] of Object.entries(openapi.paths[path])) {
56+
const op = operation as OpenAPIV3_1.OperationObject & {
57+
"x-xgen-operation-id-override": string;
58+
};
59+
if (
60+
op.operationId &&
61+
(allowedOperations.includes(op.operationId) ||
62+
allowedOperations.includes(op["x-xgen-operation-id-override"]))
63+
) {
5764
// @ts-expect-error This is a workaround for the OpenAPI types
5865
filteredMethods[method] = openapi.paths[path][method] as OpenAPIV3_1.OperationObject;
5966
}

src/common/atlas/apiClient.ts

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,216 @@ export class ApiClient {
350350
return data;
351351
}
352352

353+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
354+
async listAccessListEntries(options: FetchOptions<operations["listGroupAccessListEntries"]>) {
355+
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/accessList", options);
356+
if (error) {
357+
throw ApiClientError.fromError(response, error);
358+
}
359+
return data;
360+
}
361+
362+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
363+
async createAccessListEntry(options: FetchOptions<operations["createGroupAccessListEntry"]>) {
364+
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups/{groupId}/accessList", options);
365+
if (error) {
366+
throw ApiClientError.fromError(response, error);
367+
}
368+
return data;
369+
}
370+
371+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
372+
async deleteAccessListEntry(options: FetchOptions<operations["deleteGroupAccessListEntry"]>) {
373+
const { error, response } = await this.client.DELETE(
374+
"/api/atlas/v2/groups/{groupId}/accessList/{entryValue}",
375+
options
376+
);
377+
if (error) {
378+
throw ApiClientError.fromError(response, error);
379+
}
380+
}
381+
382+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
383+
async listAlerts(options: FetchOptions<operations["listGroupAlerts"]>) {
384+
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/alerts", options);
385+
if (error) {
386+
throw ApiClientError.fromError(response, error);
387+
}
388+
return data;
389+
}
390+
391+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
392+
async listClusters(options: FetchOptions<operations["listGroupClusters"]>) {
393+
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/clusters", options);
394+
if (error) {
395+
throw ApiClientError.fromError(response, error);
396+
}
397+
return data;
398+
}
399+
400+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
401+
async createCluster(options: FetchOptions<operations["createGroupCluster"]>) {
402+
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups/{groupId}/clusters", options);
403+
if (error) {
404+
throw ApiClientError.fromError(response, error);
405+
}
406+
return data;
407+
}
408+
409+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
410+
async deleteCluster(options: FetchOptions<operations["deleteGroupCluster"]>) {
411+
const { error, response } = await this.client.DELETE(
412+
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
413+
options
414+
);
415+
if (error) {
416+
throw ApiClientError.fromError(response, error);
417+
}
418+
}
419+
420+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
421+
async getCluster(options: FetchOptions<operations["getGroupCluster"]>) {
422+
const { data, error, response } = await this.client.GET(
423+
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
424+
options
425+
);
426+
if (error) {
427+
throw ApiClientError.fromError(response, error);
428+
}
429+
return data;
430+
}
431+
432+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
433+
async listDropIndexSuggestions(
434+
options: FetchOptions<operations["listGroupClusterPerformanceAdvisorDropIndexSuggestions"]>
435+
) {
436+
const { data, error, response } = await this.client.GET(
437+
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/dropIndexSuggestions",
438+
options
439+
);
440+
if (error) {
441+
throw ApiClientError.fromError(response, error);
442+
}
443+
return data;
444+
}
445+
446+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
447+
async listSchemaAdvice(options: FetchOptions<operations["listGroupClusterPerformanceAdvisorSchemaAdvice"]>) {
448+
const { data, error, response } = await this.client.GET(
449+
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/schemaAdvice",
450+
options
451+
);
452+
if (error) {
453+
throw ApiClientError.fromError(response, error);
454+
}
455+
return data;
456+
}
457+
458+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
459+
async listClusterSuggestedIndexes(
460+
options: FetchOptions<operations["listGroupClusterPerformanceAdvisorSuggestedIndexes"]>
461+
) {
462+
const { data, error, response } = await this.client.GET(
463+
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/suggestedIndexes",
464+
options
465+
);
466+
if (error) {
467+
throw ApiClientError.fromError(response, error);
468+
}
469+
return data;
470+
}
471+
472+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
473+
async listDatabaseUsers(options: FetchOptions<operations["listGroupDatabaseUsers"]>) {
474+
const { data, error, response } = await this.client.GET(
475+
"/api/atlas/v2/groups/{groupId}/databaseUsers",
476+
options
477+
);
478+
if (error) {
479+
throw ApiClientError.fromError(response, error);
480+
}
481+
return data;
482+
}
483+
484+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
485+
async createDatabaseUser(options: FetchOptions<operations["createGroupDatabaseUser"]>) {
486+
const { data, error, response } = await this.client.POST(
487+
"/api/atlas/v2/groups/{groupId}/databaseUsers",
488+
options
489+
);
490+
if (error) {
491+
throw ApiClientError.fromError(response, error);
492+
}
493+
return data;
494+
}
495+
496+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
497+
async deleteDatabaseUser(options: FetchOptions<operations["deleteGroupDatabaseUser"]>) {
498+
const { error, response } = await this.client.DELETE(
499+
"/api/atlas/v2/groups/{groupId}/databaseUsers/{databaseName}/{username}",
500+
options
501+
);
502+
if (error) {
503+
throw ApiClientError.fromError(response, error);
504+
}
505+
}
506+
507+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
508+
async listFlexClusters(options: FetchOptions<operations["listGroupFlexClusters"]>) {
509+
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/flexClusters", options);
510+
if (error) {
511+
throw ApiClientError.fromError(response, error);
512+
}
513+
return data;
514+
}
515+
516+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
517+
async createFlexCluster(options: FetchOptions<operations["createGroupFlexCluster"]>) {
518+
const { data, error, response } = await this.client.POST(
519+
"/api/atlas/v2/groups/{groupId}/flexClusters",
520+
options
521+
);
522+
if (error) {
523+
throw ApiClientError.fromError(response, error);
524+
}
525+
return data;
526+
}
527+
528+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
529+
async deleteFlexCluster(options: FetchOptions<operations["deleteGroupFlexCluster"]>) {
530+
const { error, response } = await this.client.DELETE(
531+
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
532+
options
533+
);
534+
if (error) {
535+
throw ApiClientError.fromError(response, error);
536+
}
537+
}
538+
539+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
540+
async getFlexCluster(options: FetchOptions<operations["getGroupFlexCluster"]>) {
541+
const { data, error, response } = await this.client.GET(
542+
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
543+
options
544+
);
545+
if (error) {
546+
throw ApiClientError.fromError(response, error);
547+
}
548+
return data;
549+
}
550+
551+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
552+
async listSlowQueryLogs(options: FetchOptions<operations["listGroupProcessPerformanceAdvisorSlowQueryLogs"]>) {
553+
const { data, error, response } = await this.client.GET(
554+
"/api/atlas/v2/groups/{groupId}/processes/{processId}/performanceAdvisor/slowQueryLogs",
555+
options
556+
);
557+
if (error) {
558+
throw ApiClientError.fromError(response, error);
559+
}
560+
return data;
561+
}
562+
353563
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
354564
async listOrgs(options?: FetchOptions<operations["listOrgs"]>) {
355565
const { data, error, response } = await this.client.GET("/api/atlas/v2/orgs", options);

0 commit comments

Comments
 (0)