Skip to content

Commit abc55f2

Browse files
committed
fix: operation ids in the openapi spec
1 parent 15fb57f commit abc55f2

20 files changed

+1590
-4857
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"fix": "npm run fix:lint && npm run reformat",
5353
"fix:lint": "eslint . --fix",
5454
"reformat": "prettier --write .",
55-
"generate": "./scripts/generate.sh && npm run generate:arguments",
55+
"generate": "npm run generate:api && npm run generate:arguments",
56+
"generate:api": "./scripts/generate.sh",
5657
"generate:arguments": "tsx scripts/generateArguments.ts",
5758
"test": "vitest --project eslint-rules --project unit-and-integration --coverage",
5859
"pretest:accuracy": "npm run build",

scripts/cleanupAtlasTestLeftovers.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function isOlderThanTwoHours(date: string): boolean {
1212
}
1313

1414
async function findTestOrganization(client: ApiClient): Promise<AtlasOrganization> {
15-
const orgs = await client.listOrganizations();
15+
const orgs = await client.listOrgs();
1616
const testOrg = orgs?.results?.find((org) => org.name === "MongoDB MCP Test");
1717

1818
if (!testOrg) {
@@ -23,7 +23,7 @@ async function findTestOrganization(client: ApiClient): Promise<AtlasOrganizatio
2323
}
2424

2525
async function findAllTestProjects(client: ApiClient, orgId: string): Promise<Group[]> {
26-
const projects = await client.listOrganizationProjects({
26+
const projects = await client.getOrgGroups({
2727
params: {
2828
path: {
2929
orgId,
@@ -101,7 +101,7 @@ async function main(): Promise<void> {
101101

102102
// Try to delete the project
103103
try {
104-
await apiClient.deleteProject({
104+
await apiClient.deleteGroup({
105105
params: {
106106
path: {
107107
groupId: project.id,

scripts/filter.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ async function readStdin(): Promise<string> {
1919

2020
function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
2121
const allowedOperations = [
22-
"listProjects",
23-
"listOrganizations",
24-
"getProject",
25-
"createProject",
26-
"deleteProject",
22+
"listGroups",
23+
"listOrgs",
24+
"getGroup",
25+
"createGroup",
26+
"deleteGroup",
2727
"listClusters",
2828
"listFlexClusters",
2929
"getCluster",
@@ -32,19 +32,19 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
3232
"createFlexCluster",
3333
"deleteCluster",
3434
"deleteFlexCluster",
35-
"listClustersForAllProjects",
35+
"listClusterDetails",
3636
"createDatabaseUser",
3737
"deleteDatabaseUser",
3838
"listDatabaseUsers",
39-
"listProjectIpAccessLists",
40-
"createProjectIpAccessList",
41-
"deleteProjectIpAccessList",
42-
"listOrganizationProjects",
39+
"listAccessListEntries",
40+
"createAccessListEntry",
41+
"deleteAccessListEntry",
42+
"getOrgGroups",
4343
"listAlerts",
44-
"listDropIndexes",
44+
"listDropIndexSuggestions",
4545
"listClusterSuggestedIndexes",
4646
"listSchemaAdvice",
47-
"listSlowQueries",
47+
"listSlowQueryLogs",
4848
];
4949

5050
const filteredPaths = {};

src/common/atlas/accessListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function makeCurrentIpAccessListEntry(
2727
export async function ensureCurrentIpInAccessList(apiClient: ApiClient, projectId: string): Promise<boolean> {
2828
const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
2929
try {
30-
await apiClient.createProjectIpAccessList({
30+
await apiClient.createAccessListEntry({
3131
params: { path: { groupId: projectId } },
3232
body: [entry],
3333
});

src/common/atlas/apiClient.ts

Lines changed: 7 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class ApiClient {
307307

308308
// DO NOT EDIT. This is auto-generated code.
309309
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
310-
async listClustersForAllProjects(options?: FetchOptions<operations["listClustersForAllProjects"]>) {
310+
async listClusterDetails(options?: FetchOptions<operations["listClusterDetails"]>) {
311311
const { data, error, response } = await this.client.GET("/api/atlas/v2/clusters", options);
312312
if (error) {
313313
throw ApiClientError.fromError(response, error);
@@ -316,7 +316,7 @@ export class ApiClient {
316316
}
317317

318318
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
319-
async listProjects(options?: FetchOptions<operations["listProjects"]>) {
319+
async listGroups(options?: FetchOptions<operations["listGroups"]>) {
320320
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups", options);
321321
if (error) {
322322
throw ApiClientError.fromError(response, error);
@@ -325,7 +325,7 @@ export class ApiClient {
325325
}
326326

327327
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
328-
async createProject(options: FetchOptions<operations["createProject"]>) {
328+
async createGroup(options: FetchOptions<operations["createGroup"]>) {
329329
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups", options);
330330
if (error) {
331331
throw ApiClientError.fromError(response, error);
@@ -334,15 +334,15 @@ export class ApiClient {
334334
}
335335

336336
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
337-
async deleteProject(options: FetchOptions<operations["deleteProject"]>) {
337+
async deleteGroup(options: FetchOptions<operations["deleteGroup"]>) {
338338
const { error, response } = await this.client.DELETE("/api/atlas/v2/groups/{groupId}", options);
339339
if (error) {
340340
throw ApiClientError.fromError(response, error);
341341
}
342342
}
343343

344344
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
345-
async getProject(options: FetchOptions<operations["getProject"]>) {
345+
async getGroup(options: FetchOptions<operations["getGroup"]>) {
346346
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}", options);
347347
if (error) {
348348
throw ApiClientError.fromError(response, error);
@@ -351,213 +351,7 @@ export class ApiClient {
351351
}
352352

353353
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
354-
async listProjectIpAccessLists(options: FetchOptions<operations["listProjectIpAccessLists"]>) {
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 createProjectIpAccessList(options: FetchOptions<operations["createProjectIpAccessList"]>) {
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 deleteProjectIpAccessList(options: FetchOptions<operations["deleteProjectIpAccessList"]>) {
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["listAlerts"]>) {
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["listClusters"]>) {
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["createCluster"]>) {
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["deleteCluster"]>) {
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["getCluster"]>) {
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 listDropIndexes(options: FetchOptions<operations["listDropIndexes"]>) {
434-
const { data, error, response } = await this.client.GET(
435-
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/dropIndexSuggestions",
436-
options
437-
);
438-
if (error) {
439-
throw ApiClientError.fromError(response, error);
440-
}
441-
return data;
442-
}
443-
444-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
445-
async listSchemaAdvice(options: FetchOptions<operations["listSchemaAdvice"]>) {
446-
const { data, error, response } = await this.client.GET(
447-
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/schemaAdvice",
448-
options
449-
);
450-
if (error) {
451-
throw ApiClientError.fromError(response, error);
452-
}
453-
return data;
454-
}
455-
456-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
457-
async listClusterSuggestedIndexes(options: FetchOptions<operations["listClusterSuggestedIndexes"]>) {
458-
const { data, error, response } = await this.client.GET(
459-
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/suggestedIndexes",
460-
options
461-
);
462-
if (error) {
463-
throw ApiClientError.fromError(response, error);
464-
}
465-
return data;
466-
}
467-
468-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
469-
async listDatabaseUsers(options: FetchOptions<operations["listDatabaseUsers"]>) {
470-
const { data, error, response } = await this.client.GET(
471-
"/api/atlas/v2/groups/{groupId}/databaseUsers",
472-
options
473-
);
474-
if (error) {
475-
throw ApiClientError.fromError(response, error);
476-
}
477-
return data;
478-
}
479-
480-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
481-
async createDatabaseUser(options: FetchOptions<operations["createDatabaseUser"]>) {
482-
const { data, error, response } = await this.client.POST(
483-
"/api/atlas/v2/groups/{groupId}/databaseUsers",
484-
options
485-
);
486-
if (error) {
487-
throw ApiClientError.fromError(response, error);
488-
}
489-
return data;
490-
}
491-
492-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
493-
async deleteDatabaseUser(options: FetchOptions<operations["deleteDatabaseUser"]>) {
494-
const { error, response } = await this.client.DELETE(
495-
"/api/atlas/v2/groups/{groupId}/databaseUsers/{databaseName}/{username}",
496-
options
497-
);
498-
if (error) {
499-
throw ApiClientError.fromError(response, error);
500-
}
501-
}
502-
503-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
504-
async listFlexClusters(options: FetchOptions<operations["listFlexClusters"]>) {
505-
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/flexClusters", options);
506-
if (error) {
507-
throw ApiClientError.fromError(response, error);
508-
}
509-
return data;
510-
}
511-
512-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
513-
async createFlexCluster(options: FetchOptions<operations["createFlexCluster"]>) {
514-
const { data, error, response } = await this.client.POST(
515-
"/api/atlas/v2/groups/{groupId}/flexClusters",
516-
options
517-
);
518-
if (error) {
519-
throw ApiClientError.fromError(response, error);
520-
}
521-
return data;
522-
}
523-
524-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
525-
async deleteFlexCluster(options: FetchOptions<operations["deleteFlexCluster"]>) {
526-
const { error, response } = await this.client.DELETE(
527-
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
528-
options
529-
);
530-
if (error) {
531-
throw ApiClientError.fromError(response, error);
532-
}
533-
}
534-
535-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
536-
async getFlexCluster(options: FetchOptions<operations["getFlexCluster"]>) {
537-
const { data, error, response } = await this.client.GET(
538-
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
539-
options
540-
);
541-
if (error) {
542-
throw ApiClientError.fromError(response, error);
543-
}
544-
return data;
545-
}
546-
547-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
548-
async listSlowQueries(options: FetchOptions<operations["listSlowQueries"]>) {
549-
const { data, error, response } = await this.client.GET(
550-
"/api/atlas/v2/groups/{groupId}/processes/{processId}/performanceAdvisor/slowQueryLogs",
551-
options
552-
);
553-
if (error) {
554-
throw ApiClientError.fromError(response, error);
555-
}
556-
return data;
557-
}
558-
559-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
560-
async listOrganizations(options?: FetchOptions<operations["listOrganizations"]>) {
354+
async listOrgs(options?: FetchOptions<operations["listOrgs"]>) {
561355
const { data, error, response } = await this.client.GET("/api/atlas/v2/orgs", options);
562356
if (error) {
563357
throw ApiClientError.fromError(response, error);
@@ -566,7 +360,7 @@ export class ApiClient {
566360
}
567361

568362
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
569-
async listOrganizationProjects(options: FetchOptions<operations["listOrganizationProjects"]>) {
363+
async getOrgGroups(options: FetchOptions<operations["getOrgGroups"]>) {
570364
const { data, error, response } = await this.client.GET("/api/atlas/v2/orgs/{orgId}/groups", options);
571365
if (error) {
572366
throw ApiClientError.fromError(response, error);

0 commit comments

Comments
 (0)