Skip to content

Implementation for Atlas Service Discovery Programmatic Access#267

Open
xingfan-git wants to merge 10 commits into
mainfrom
xingfan/discoveratlas
Open

Implementation for Atlas Service Discovery Programmatic Access#267
xingfan-git wants to merge 10 commits into
mainfrom
xingfan/discoveratlas

Conversation

@xingfan-git

Copy link
Copy Markdown
Contributor

@xingfan-git xingfan-git self-assigned this Sep 11, 2025
@xingfan-git xingfan-git requested a review from a team as a code owner September 11, 2025 12:21
Copilot AI review requested due to automatic review settings September 11, 2025 12:21
@xingfan-git xingfan-git changed the title [DRAFT]Implementation for Atlas Service Discovery Promatically access [DRAFT]Implementation for Atlas Service Discovery Programmatic access Sep 11, 2025
@xingfan-git xingfan-git changed the title [DRAFT]Implementation for Atlas Service Discovery Programmatic access [DRAFT]Implementation for Atlas Service Discovery Programmatic Access Sep 11, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements MongoDB Atlas Service Discovery functionality by adding programmatic access to Atlas APIs. It introduces a new plugin module for the service-mongo-atlas service that handles both OAuth 2.0 and HTTP Digest authentication methods for Atlas API operations.

Key changes include:

  • Addition of Atlas HTTP client for API communication with authentication support
  • Credential caching system for Atlas organizations with OAuth token management
  • Atlas administration client for managing projects, clusters, database users, and IP access lists

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/plugins/service-mongo-atlas/utils/AtlasHttpClient.ts HTTP client for Atlas API requests with OAuth and Digest authentication
src/plugins/service-mongo-atlas/utils/AtlasCredentialCache.ts Credential storage and management for Atlas organizations
src/plugins/service-mongo-atlas/utils/AtlasAuthManager.ts Authentication manager for OAuth token handling and credential management
src/plugins/service-mongo-atlas/utils/AtlasAdministrationClient.ts Administration client for Atlas resource management operations
package.json Added digest-fetch dependency for HTTP Digest authentication
l10n/bundle.l10n.json Added localization strings for Atlas-related error messages

Comment thread src/plugins/service-mongo-atlas/utils/AtlasHttpClient.ts Outdated
Comment on lines +124 to +125
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
const client = new DigestClient(publicKey, privateKey) as DigestFetchClient;

Copilot AI Sep 11, 2025

Copy link

Choose a reason for hiding this comment

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

The eslint-disable comment and type assertion suggest potential type safety issues. Consider creating proper type definitions for DigestClient instead of disabling the safety check and using type assertions.

Copilot uses AI. Check for mistakes.
Comment thread src/plugins/service-mongo-atlas/utils/AtlasHttpClient.ts Outdated
Comment thread src/plugins/service-mongo-atlas/utils/AtlasHttpClient.ts Outdated
clientId,
clientSecret,
},
digest: undefined, // Clear any existing digest credentials

Copilot AI Sep 11, 2025

Copy link

Choose a reason for hiding this comment

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

Explicitly setting digest to undefined when setting OAuth credentials could be simplified by restructuring the credential object or using a more explicit credential switching mechanism to avoid potential confusion.

Copilot uses AI. Check for mistakes.
Comment thread src/plugins/service-mongo-atlas/utils/AtlasCredentialCache.ts Outdated
Comment thread src/plugins/service-mongo-atlas/utils/AtlasAuthManager.ts Outdated
value: string;
}>;
withDefaultAlertsSettings?: boolean;
}

Copilot AI Sep 11, 2025

Copy link

Choose a reason for hiding this comment

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

The AtlasProject interface is missing proper return type annotations. According to the coding guidelines, TypeScript interfaces should be used for object shapes and all properties should have explicit types.

Copilot generated this review using guidance from repository custom instructions.
@xingfan-git xingfan-git changed the title [DRAFT]Implementation for Atlas Service Discovery Programmatic Access Implementation for Atlas Service Discovery Programmatic Access Sep 14, 2025
@xingfan-git

Copy link
Copy Markdown
Contributor Author

@tnaum-ms
The tests are placed in the folder: src/plugins/service-mongo-atlas/tests/
The pagination is controlled by parameters in options: pageNum, itemsPerPage and includeCount

@xingfan-git xingfan-git requested a review from Copilot September 14, 2025 13:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Comment thread src/plugins/service-mongo-atlas/utils/AtlasHttpClient.ts Outdated
Comment thread src/plugins/service-mongo-atlas/utils/AtlasCredentialCache.ts
}

// Add 60 second buffer to avoid edge cases
return Date.now() < oauth.tokenExpiry - 60000;

Copilot AI Sep 14, 2025

Copy link

Choose a reason for hiding this comment

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

The 60-second buffer (60000ms) is a magic number. Consider extracting this as a named constant like TOKEN_EXPIRY_BUFFER_MS = 60000 to improve code readability and maintainability.

Copilot uses AI. Check for mistakes.
@tnaum-ms tnaum-ms added this to the 0.9.0 milestone Nov 24, 2025
@tnaum-ms tnaum-ms changed the base branch from next to main May 21, 2026 10:37
@tnaum-ms tnaum-ms removed this from the 0.9.0 milestone Jun 15, 2026
@tnaum-ms tnaum-ms added this to the 0.10.0 milestone Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Authentication for MongoDB Atlas Discovery Service Discovery: MongoDB Atlas: Programmatic access

4 participants