Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"fix": "npm run fix:lint && npm run reformat",
"fix:lint": "eslint . --fix",
"reformat": "prettier --write .",
"generate": "./scripts/generate.sh && npm run generate:arguments",
"generate": "npm run generate:api && npm run generate:arguments",
"generate:api": "./scripts/generate.sh",
"generate:arguments": "tsx scripts/generateArguments.ts",
"test": "vitest --project eslint-rules --project unit-and-integration --coverage",
"pretest:accuracy": "npm run build",
Expand Down
6 changes: 3 additions & 3 deletions scripts/cleanupAtlasTestLeftovers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function isOlderThanTwoHours(date: string): boolean {
}

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

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

async function findAllTestProjects(client: ApiClient, orgId: string): Promise<Group[]> {
const projects = await client.listOrganizationProjects({
const projects = await client.getOrgGroups({
params: {
path: {
orgId,
Expand Down Expand Up @@ -101,7 +101,7 @@ async function main(): Promise<void> {

// Try to delete the project
try {
await apiClient.deleteProject({
await apiClient.deleteGroup({
params: {
path: {
groupId: project.id,
Expand Down
24 changes: 12 additions & 12 deletions scripts/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ async function readStdin(): Promise<string> {

function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
const allowedOperations = [
"listProjects",
"listOrganizations",
"getProject",
"createProject",
"deleteProject",
"listGroups",
"listOrgs",
"getGroup",
"createGroup",
"deleteGroup",
"listClusters",
"listFlexClusters",
"getCluster",
Expand All @@ -32,19 +32,19 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
"createFlexCluster",
"deleteCluster",
"deleteFlexCluster",
"listClustersForAllProjects",
"listClusterDetails",
"createDatabaseUser",
"deleteDatabaseUser",
"listDatabaseUsers",
"listProjectIpAccessLists",
"createProjectIpAccessList",
"deleteProjectIpAccessList",
"listOrganizationProjects",
"listAccessListEntries",
"createAccessListEntry",
"deleteAccessListEntry",
"getOrgGroups",
"listAlerts",
"listDropIndexes",
"listDropIndexSuggestions",
"listClusterSuggestedIndexes",
"listSchemaAdvice",
"listSlowQueries",
"listSlowQueryLogs",
];

const filteredPaths = {};
Expand Down
2 changes: 1 addition & 1 deletion src/common/atlas/accessListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function makeCurrentIpAccessListEntry(
export async function ensureCurrentIpInAccessList(apiClient: ApiClient, projectId: string): Promise<boolean> {
const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
try {
await apiClient.createProjectIpAccessList({
await apiClient.createAccessListEntry({
params: { path: { groupId: projectId } },
body: [entry],
});
Expand Down
220 changes: 7 additions & 213 deletions src/common/atlas/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class ApiClient {

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

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

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

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

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

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listProjectIpAccessLists(options: FetchOptions<operations["listProjectIpAccessLists"]>) {
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/accessList", options);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async createProjectIpAccessList(options: FetchOptions<operations["createProjectIpAccessList"]>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] what happened to all these delete ones, are they unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm checking

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to do with x-xgen-operation-id-override

const { data, error, response } = await this.client.POST("/api/atlas/v2/groups/{groupId}/accessList", options);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async deleteProjectIpAccessList(options: FetchOptions<operations["deleteProjectIpAccessList"]>) {
const { error, response } = await this.client.DELETE(
"/api/atlas/v2/groups/{groupId}/accessList/{entryValue}",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listAlerts(options: FetchOptions<operations["listAlerts"]>) {
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/alerts", options);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listClusters(options: FetchOptions<operations["listClusters"]>) {
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/clusters", options);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async createCluster(options: FetchOptions<operations["createCluster"]>) {
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups/{groupId}/clusters", options);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async deleteCluster(options: FetchOptions<operations["deleteCluster"]>) {
const { error, response } = await this.client.DELETE(
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async getCluster(options: FetchOptions<operations["getCluster"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listDropIndexes(options: FetchOptions<operations["listDropIndexes"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/dropIndexSuggestions",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listSchemaAdvice(options: FetchOptions<operations["listSchemaAdvice"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/schemaAdvice",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listClusterSuggestedIndexes(options: FetchOptions<operations["listClusterSuggestedIndexes"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/performanceAdvisor/suggestedIndexes",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listDatabaseUsers(options: FetchOptions<operations["listDatabaseUsers"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/databaseUsers",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async createDatabaseUser(options: FetchOptions<operations["createDatabaseUser"]>) {
const { data, error, response } = await this.client.POST(
"/api/atlas/v2/groups/{groupId}/databaseUsers",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async deleteDatabaseUser(options: FetchOptions<operations["deleteDatabaseUser"]>) {
const { error, response } = await this.client.DELETE(
"/api/atlas/v2/groups/{groupId}/databaseUsers/{databaseName}/{username}",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listFlexClusters(options: FetchOptions<operations["listFlexClusters"]>) {
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/flexClusters", options);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async createFlexCluster(options: FetchOptions<operations["createFlexCluster"]>) {
const { data, error, response } = await this.client.POST(
"/api/atlas/v2/groups/{groupId}/flexClusters",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async deleteFlexCluster(options: FetchOptions<operations["deleteFlexCluster"]>) {
const { error, response } = await this.client.DELETE(
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async getFlexCluster(options: FetchOptions<operations["getFlexCluster"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listSlowQueries(options: FetchOptions<operations["listSlowQueries"]>) {
const { data, error, response } = await this.client.GET(
"/api/atlas/v2/groups/{groupId}/processes/{processId}/performanceAdvisor/slowQueryLogs",
options
);
if (error) {
throw ApiClientError.fromError(response, error);
}
return data;
}

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async listOrganizations(options?: FetchOptions<operations["listOrganizations"]>) {
async listOrgs(options?: FetchOptions<operations["listOrgs"]>) {
const { data, error, response } = await this.client.GET("/api/atlas/v2/orgs", options);
if (error) {
throw ApiClientError.fromError(response, error);
Expand All @@ -566,7 +360,7 @@ export class ApiClient {
}

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