Skip to content

.NET Core client for MongoDB Atlas, the Database-as-a-Service to manage MongoDB clusters!

License

Notifications You must be signed in to change notification settings

devpro/mongodb-atlas-dotnet-client

Repository files navigation

MongoDB Atlas .NET Client

Build Status Quality Gate Status Coverage Nuget

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>

User manual

How to install

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

How to configure

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.

⚠️ Make sure your IP is in the Api key white list!

  • Use the tool config action
mdbatlas config --publickey <publickey> --privatekey <privatekey>
  • (alternative) Set environment variables
SET mdbatlas__PublicKey=<publickey>
SET mdbatlas__PrivateKey=<privatekey>

How to use

Quick start

# 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

Examples

# 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"

How to uninstall

The tool can be easily uninstalled with:

dotnet tool uninstall -g mdbatlas

Contribue

Requirements

Local project debug

# build the .NET solution
dotnet build

# run the console app
dotnet src/ConsoleApp/bin/Debug/netcoreapp3.1/mdbatlas.dll --help

Local installation

# 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

References

Microsoft documentation

MongoDB documentation

MongoDB Atlas API features

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

MongoDB Atlas clients in other languages

About

.NET Core client for MongoDB Atlas, the Database-as-a-Service to manage MongoDB clusters!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages