Skip to content

Service Discovery: MongoDB Atlas: Programmatic access #259

@tnaum-ms

Description

@tnaum-ms

MongoDB Atlas Management API v2, OAuth2 + HTTP Digest

We will build a new service discovery plugin that programmatically discovers MongoDB Atlas Projects and Clusters so they can appear in the extension's Discovery View. Start working on the the plugin under plugins/mongodb-atlas (or similar under plugins) so it follows the existing provider pattern.

This issue focuses on the programmatic access only.

Programmatic requirements (Atlas Management API v2)

  • API version: Use the Atlas Management API v2 (base: https://cloud.mongodb.com/api/atlas/v2).
  • Authentication: support both
    • OAuth 2.0 Client Credentials flow (preferred): obtain, cache, refresh Bearer tokens; handle scopes and expiry.
    • Legacy HTTP Digest Authentication (Atlas API Keys): support publicKey/privateKey Digest auth as a fallback.
  • Implement the following programmatic operations:
    1. List Projects (groups) and Clusters within a Project.
      • Example v2 endpoints: GET /groups and GET /groups/{PROJECT-ID}/clusters
    2. Read cluster connection strings (connectionStrings field on cluster resource).
      • Example v2 endpoint: GET /groups/{PROJECT-ID}/clusters/{CLUSTER-NAME}
    3. List database users for a Project/Cluster.
      • Example v2 endpoint: GET /groups/{PROJECT-ID}/databaseUsers
    4. Read and write IP access list (firewall) entries for a Project.
      • Example v2 endpoints: GET /groups/{PROJECT-ID}/accessList, POST /groups/{PROJECT-ID}/accessList, DELETE /groups/{PROJECT-ID}/accessList/{ENTRY-ID} (verify exact ops per docs)

Pagination & rate limits

  • Implement generic pagination following Atlas v2 response patterns (links / next / totalCount).
  • Respect HTTP 429 / Retry-After; implement exponential backoff with jitter and sensible max retries.

Testing & quality

  • Unit tests for the HTTP client covering OAuth token flow, Digest auth, pagination, and 429 retry behavior (use mocked HTTP responses).
  • Minimal integration/testing notes in README describing how to obtain API credentials and run manual discovery.

Notes / implementation hints

  • Confirm exact OAuth token endpoint and required scopes from MongoDB Atlas docs during implementation.
  • For Digest auth, prefer a tested library that supports HTTP Digest signing instead of hand-rolling it.
  • Keep the API client thin and testable; surface friendly errors to the UI layer.

Sub-issues

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions