How to use atlasapi - 10 common examples

To help you get started, we’ve selected a few atlasapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mgmonteleone / python-atlasapi / tests / rez.py View on Github external
from atlasapi.atlas import Atlas
from pprint import pprint
from os import environ, getenv

from atlasapi.specs import ListOfHosts, Host
USER = getenv('ATLAS_USER', 'JKKIDWUA')
API_KEY = getenv('ATLAS_KEY', '4e09ab9f-bf2c-41da-90bf-7d7974c330d2')
GROUP_ID = getenv('ATLAS_GROUP', '5b1e92c13b34b93b0230e6e1')
from atlasapi.lib import AtlasPeriods, AtlasUnits, AtlasGranularities
from atlasapi.measurements import AtlasMeasurementTypes

if not USER or not API_KEY or not GROUP_ID:
    raise EnvironmentError('In order to run this smoke test you need ATLAS_USER, AND ATLAS_KEY env variables'
                           'your env variables are {}'.format(environ.__str__()))

a = Atlas(USER,API_KEY,GROUP_ID)


pprint('----------MeasureMents')
output = a.Hosts._get_measurement_for_host(a.Hosts.host_list[0]
                                           ,measurement=AtlasMeasurementTypes.Memory.resident,iterable=True
                                           ,period=AtlasPeriods.WEEKS_4,granularity=AtlasGranularities.MINUTE)

for each in a.Hosts.host_list:
    pprint(each.__dict__)
github mgmonteleone / python-atlasapi / tests / monitoring_logs.py View on Github external
from pprint import pprint
from os import environ, getenv

from atlasapi.specs import ListOfHosts, Host

USER = getenv('ATLAS_USER', None)
API_KEY = getenv('ATLAS_KEY', None)
GROUP_ID = getenv('ATLAS_GROUP', None)
from atlasapi.lib import AtlasPeriods, AtlasUnits, AtlasGranularities
from atlasapi.measurements import AtlasMeasurementTypes
import csv
if not USER or not API_KEY or not GROUP_ID:
    raise EnvironmentError('In order to run this smoke test you need ATLAS_USER, AND ATLAS_KEY env variables'
                           'your env variables are {}'.format(environ.__str__()))

a = Atlas(USER, API_KEY, GROUP_ID)

# Low level Api
# details = a.Hosts._get_all_hosts(pageNum=1, itemsPerPage=100)
# pprint(details)
# print('-----------------Now as iterable ------------------')
# Iterable
# for a_host in a.Hosts.host_names:
#    print(a_host)

pprint('----------MeasureMents')

# a.Hosts._get_measurement_for_host(a.Hosts.host_list[0]
#                                           ,measurement=AtlasMeasurementTypes.Memory.virtual,iterable=True
#                                           ,period=AtlasPeriods.HOURS_24,granularity=AtlasGranularities.MINUTE)
#
# a.Hosts._get_measurement_for_host(a.Hosts.host_list[0]
github mgmonteleone / python-atlasapi / tests / __init__.py View on Github external
self.API_KEY = getenv('ATLAS_KEY', None)
        self.GROUP_ID = getenv('ATLAS_GROUP', None)

        #print("env var is".format(getenv('ATLAS_USER', None)))

        self.TEST_CLUSTER_NAME = TEST_CLUSTER_NAME
        self.TEST_CLUSTER2_NAME = TEST_CLUSTER2_NAME

        self.TEST_CLUSTER_NAME_UNIQUE = TEST_CLUSTER2_NAME_UNIQUE
        self.TEST_CLUSTER2_NAME_UNIQUE = TEST_CLUSTER2_NAME_UNIQUE
        self.TEST_CLUSTER3_NAME_UNIQUE = TEST_CLUSTER3_NAME_UNIQUE

        if not self.USER or not self.API_KEY or not self.GROUP_ID:
            raise EnvironmentError('In order to run this smoke test you need ATLAS_USER, AND ATLAS_KEY env variables'
                                   'your env variables are {}'.format(environ.__str__()))
        self.a = Atlas(self.USER, self.API_KEY, self.GROUP_ID)
github mgmonteleone / python-atlasapi / tests / events.py View on Github external
from atlasapi.atlas import Atlas
from pprint import pprint
from os import environ, getenv
from atlasapi import events
from atlasapi.lib import AtlasPeriods, AtlasUnits, AtlasGranularities

USER = getenv('ATLAS_USER', None)
API_KEY = getenv('ATLAS_KEY', None)
GROUP_ID = getenv('ATLAS_GROUP', None)


if not USER or not API_KEY or not GROUP_ID:
    raise EnvironmentError('In order to run this smoke test you need ATLAS_USER, AND ATLAS_KEY env variables'
                           'your env variables are {}'.format(environ.__str__()))

a = Atlas(USER,API_KEY,GROUP_ID)

# Low level Api
#details = a.Hosts._get_all_hosts(pageNum=1, itemsPerPage=100)
#pprint(details)
#print('-----------------Now as iterable ------------------')
# Iterable
#for a_host in a.Hosts.host_names:
#    print(a_host)

pprint('----------Events')
output = a.Events._get_all_project_events(iterable=True)


for each_event in output:
    pprint(each_event)
github jdrumgoole / MongoDB-Atlas-API / atlasapi / test_atlasapi.py View on Github external
def test_atlas_projects():

    api = AtlasAPI()
    projects = api.get_projects("5a141a774e65811a132a8010")
    assert projects is not None
    assert list(projects) is not None
    assert len(list(projects)) >= 0
github jdrumgoole / MongoDB-Atlas-API / atlasapi / test_atlasapi.py View on Github external
def test_atlas_cluster():

    api = AtlasAPI()
    cluster = api.get_cluster("5a141a774e65811a132a8010", "Foodapedia")
    assert cluster is not None
    assert cluster.name == "Foodapedia"
github jdrumgoole / MongoDB-Atlas-API / atlasapi / test_atlasapi.py View on Github external
def test_atlas_project():

    api = AtlasAPI()
    project = api.get_project("5a141a774e65811a132a8010")
    assert project is not None
    assert project.id == "5a141a774e65811a132a8010"
github jdrumgoole / MongoDB-Atlas-API / atlasapi / test_atlasapi.py View on Github external
def test_atlas_organization():

    api = AtlasAPI()
    org = api.get_organization("599eeced9f78f769464d175c")
    assert org is not None
    assert org.id == "599eeced9f78f769464d175c"
github jdrumgoole / MongoDB-Atlas-API / atlasapi / test_atlasapi.py View on Github external
def test_atlas_organisations():

    api = AtlasAPI()
    orgs = api.get_organisations(limi=200)
    list_of_orgs = list(orgs)
    assert list_of_orgs is not None
    assert len(list_of_orgs) == 200

    with pytest.raises(AtlasInitialisationError):
        api = AtlasAPI(page_size=0)

    with pytest.raises(AtlasInitialisationError):
        api = AtlasAPI(page_size=501)

    with pytest.raises(AtlasInitialisationError):
        api = AtlasAPI(page_size=-1)
github jdrumgoole / MongoDB-Atlas-API / atlasapi / test_atlasapi.py View on Github external
def test_atlas_clusters():

    api = AtlasAPI()
    clusters = api.get_clusters("5a141a774e65811a132a8010")
    assert clusters is not None
    assert list(clusters) is not None
    assert len(list(clusters)) >= 0