Python API for the MongoDB Atlas API

jdrumgoole, updated 🕥 2022-12-09 05:18:38

Atlascli - A Python API for MongoDB Atlas

The MongoDB database as a service offering Atlas provides a complete and well documented REST API.

Installation

The easiest way to install the atlascli is with pip.

```shell C:\Users\joe>pip install atlascli Looking in indexes: https://test.pypi.org/simple/ Processing c:\users\joe\appdata\local\pip\cache\wheels\6c\2f\e8\7f33b6b37b40424f1d00d54048aaa63fd47c7b289e790a997d\atlascli-0.2.5b5-py3-none-any.whl Requirement already satisfied: python-dateutil in c:\users\joe.virtualenvs\joe-93pxapbd\lib\site-packages (from atlascli) (2.8.1) Requirement already satisfied: requests in c:\users\joe.virtualenvs\joe-93pxapbd\lib\site-packages (from atlascli) (2.5.4.1) Requirement already satisfied: six>=1.5 in c:\users\joe.virtualenvs\joe-93pxapbd\lib\site-packages (from python-dateutil->atlascli) (1.10.0) Installing collected packages: atlascli Successfully installed atlascli-0.2.5b

C:\Users\joe> ```

Once the installation completes you can confirm it has worked by running

```shell C:\Users\joe>atlascli -h usage: atlascli [-h] [--publickey PUBLICKEY] [--privatekey PRIVATEKEY] [--pause PAUSE_CLUSTER] [--resume RESUME_CLUSTER] [--list] [--listproj] [--listcluster] [--cluster CLUSTER] [--project_id PROJECT_ID_LIST] [--debug]

A command line program to list organizations,projects and clusters on a MongoDB Atlas organization.

optional arguments: -h, --help show this help message and exit --publickey PUBLICKEY MongoDB Atlas public API key --privatekey PRIVATEKEY MongoDB Atlas private API key --pause PAUSE_CLUSTER pause named cluster in project specified by project_id Note that clusters that have been resumed cannot be pausedfor the next 60 minutes --resume RESUME_CLUSTER resume named cluster in project specified by project_id --list List everything in the organization --listproj List all projects --listcluster List all clusters --cluster CLUSTER list all elements for for project_id:cluster_name --project_id PROJECT_ID_LIST specify project for cluster that is to be paused --debug Turn on logging at debug level

Version: 0.2.5b5

C:\Users\joe> ```

The Python Atlas API wraps the REST API in a more Pythonic API based around an AtlasAPI class.

The library assumes the existence of two environment variables:

  • ATLAS_PUBLIC_KEY : The public key value defined by the Atlas programmatic API key
  • ATLAS_PRIVATE_KEY : The private key defined by the Atlas programmatic API key.

These can be passed in on the command line as well as parameters --publickey and --privatekey.

See the section below on how to create a programmatic Atlas API key.

How to create an Atlas API Key

You can create keys at the Organization level by selecting the access menu item on the left hand side menu:

API Start Screen

Once you create a key you then need to assign it permissions. If you pick the default youwill have to add this key explicitly to every project that you want to manage via the API.

API Permissions Screen

On the next screen you can collect your API key. You will only get to see it once so please make sure to take a copy.

API Create Key Screen

Not on this screen we obliterate part of the key so it can't been seen.

Finally you need to whitelist any nodes that are going to originate API requests.

API Create Key Screen

You are now ready to start using your API key.

Using your keys

Both parts of the key required to access your account. Rather than passing them in on the command line the atlascli program these can read them from the environment variables ATLAS_PRIVATE_KEY and ATLAS_PUBLIC_KEY.

Issues

Bump certifi from 2021.5.30 to 2022.12.7

opened on 2022-12-09 05:18:37 by dependabot[bot]

Bumps certifi from 2021.5.30 to 2022.12.7.

Commits


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/jdrumgoole/atlascli/network/alerts).

Bump ipython from 7.24.1 to 7.31.1

opened on 2022-01-21 19:09:08 by dependabot[bot]

Bumps ipython from 7.24.1 to 7.31.1.

Commits


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/jdrumgoole/atlascli/network/alerts).

Cant connect to Project or cluster key not accepting

opened on 2019-12-01 13:54:32 by darshana-danrox

I have given key details on the terminal and also try define as env variable but none working

Note : ip white listed

$ echo $ATLAS_PUBLIC_KEY SxxxxWxxxx $ echo $ATLAS_PRIVATE_KEY xc4xxxxxxxx-4xxxxx1-xxxxx-xxxxxxxx6xx $ atlascli --publickey xxxxxxxxxu --privatekey fcx9xxxxxxxx-4xxxx1-8xxxx-4xxxxxx `` Traceback (most recent call last): File "/usr/local/bin/atlascli", line 11, in <module> load_entry_point('mongodbatlas==0.2.3b2', 'console_scripts', 'atlascli')() File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/atlascli.py", line 192, in main File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/api.py", line 50, in get_this_organization File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/atlasorganization.py", line 9, in __init__ File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/atlasresource.py", line 22, in __init__ File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/apimixin.py", line 62, in __init__ File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/atlaskey.py", line 35, in get_from_env File "/usr/local/lib/python3.7/site-packages/mongodbatlas-0.2.3b2-py3.7.egg/mongodbatlas/atlaskey.py", line 30, in getenvmongodbatlas.errors.AtlasEnvironmentError: Private key environment variable 'ATLAS_PUBLIC_KEY' is not set`

Joe Drumgoole

Developer Relations

GitHub Repository

atlas mongodb-atlas pythonic-api python3