MongoDB Atlas API client, written in C#, working with .NET Core.
This is particularly interesting in order to automate your Cloud infrastructure (from a pipeline for instance).
Examples:
# List your organizations
mdbatlas list orgs
# get your first project id
mdbatlas list projects --query id
# get last events
mdbatlas list events -p <projectid>
# display IP while list
mdbatlas list whitelist -p <projectid>
As a requirement, you only have to install the latest .NET Core CLI (open source tool with a minimized footprint).
As a .NET global tool, mdbatlas
is installed from the NuGet package:
dotnet tool install --global mdbatlas
An API key must be created in MongoDB Atlas. If you're not familier with it, the instructions are given in the page Configure Atlas API Access.
This action should provide you with the public key and the private key.
- Use the tool
config
action
mdbatlas config --publickey <publickey> --privatekey <privatekey>
- (alternative) Set environment variables
SET mdbatlas__PublicKey=<publickey>
SET mdbatlas__PrivateKey=<privatekey>
# display tool version
mdbatlas --version
# display help
mdbatlas --help
# configure
mdbatlas config --publickey mypublickey --privatekey mysecretprivatekey
# list all the organizations your account have access to
mdbatlas list orgs
# get the first project id
mdbatlas list projects --query id
# list recents events for a given project
mdbatlas list events --project myprojectid
# list all IP whitelist record for a given project
mdbatlas list whitelist --project myprojectid
# add entries to IP whitelist for a given project (will only add the ones not already defined)
mdbatlas edit whitelist --project myprojectid --values "W.X.Y.Z:My first IP comment,A.B.C.D:Second ip comment"
# delete specific entries in the IP whitelist of a given project
mdbatlas delete whitelist --project myprojectid --values --values "W.X.Y.Z,A.B.C.D"
The tool can be easily uninstalled with:
dotnet tool uninstall -g mdbatlas
- .NET Core SDK must be installed
# build the .NET solution
dotnet build
# run the console app
dotnet src/ConsoleApp/bin/Debug/netcoreapp3.1/mdbatlas.dll --help
# pack the projects
dotnet pack
# install from local package
dotnet tool update -g mdbatlas --add-source=src/ConsoleApp/nupkg --version 1.1.0-alpha-000000
# run the tool
mdbatlas list orgs
# uninstall the tool
dotnet tool uninstall -g mdbatlas
This table presents all the resources provided by MongoDB Atlas API with the status of their integration in the client (:heavy_check_mark: = implemented).
Resource | Method |
---|---|
Event | FindAllByOrganizationId, FindOneByIdAndProjectId, FindAllByProjectId:heavy_check_mark:, FindOneByIdAndProjectId |
Organization | FindAll:heavy_check_mark:, FindOneById, FindAllOrganizationUsers, FindAllOrganizationProjects, Rename, Delete |
Project | FindAll:heavy_check_mark:, FindOneById, FindOneByName:heavy_check_mark:, Create, Delete, GetProjectTeams, AssignTeamToProject, DeleteUserFromProject |
Project IP Whitelist | FindAllByProjectId:heavy_check_mark:, FindOneByIdAndProjectId, Create:heavy_check_mark:, Delete |
Root | |
Database Users | |
Custom MongoDB Roles | |
Invoices | |
Teams | |
Clusters | |
Global Clusters | |
Alerts | |
Alert Configurations | |
Maintenance Windows | |
LDAP Configuration | |
Full Text Search | |
Continuous Backup Snapshots | |
Continuous Backup Snapshot Schedule | |
Continuous Backup Restore Job | |
Cloud Provider and On-demand Snapshots | |
Cloud Provider Snapshot Restore Job | |
Cloud Provider Snapshot Backup Policy | |
M2/M5 Snapshots | |
M2/M5 Snapshot Restore Jobs | |
Checkpoints | |
Network Peering | |
Private Endpoints | |
Personal API Key Whitelist | |
Programmatic API Keys | |
Monitoring and Logs | |
Performance Advisor | |
Auditing | |
Encryption at Rest | |
Atlas Users | |
Events | FindAllByProjectId:heavy_check_mark: |
Access Tracking | |
Data Lakes |