Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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__)
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]
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)
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)
public_key = os.getenv("ATLAS_PUBLIC_KEY")
if public_key is None:
print("you must specify an ATLAS public key via --publickey arg "
"or the environment variable ATLAS_PUBLIC_KEY")
sys.exit(1)
if args.privatekey:
private_key = args.privatekey
else:
private_key = os.getenv("ATLAS_PRIVATE_KEY")
if private_key is None:
print("you must specify an an ATLAS private key via --privatekey"
"arg or the environment variable ATLAS_PRIVATE_KEY")
sys.exit(1)
atlas = Atlas(public_key, private_key, args.atlasgroup)
if args.list:
if args.resource == AtlasResource.CLUSTER:
list_cmd = ListCommand(args.format)
if args.id:
print("Cluster:")
cluster = atlas.Clusters.get_single_cluster(cluster=args.id)
list_cmd.list_one(cluster)
else:
print("Cluster list:")
clusters = atlas.Clusters.get_all_clusters(iterable=True)
total = list_cmd.list_all(clusters)
print(f"{total} cluster(s)")
def __init__(self, user, password, group):
self.group = group
# Network calls which will handled user/password for auth
self.network = Network(user, password)
# APIs
self.DatabaseUsers = Atlas._DatabaseUsers(self)
self.Clusters = Atlas._Clusters(self)
self.Hosts = Atlas._Hosts(self)
self.Events = Atlas._Events(self)
self.logger = logging.getLogger(name='Atlas')
self.Alerts = Atlas._Alerts(self)
self.Whitelist = Atlas._Whitelist(self)
self.MaintenanceWindows = Atlas._MaintenanceWindows(self)
def __init__(self, user, password, group):
self.group = group
# Network calls which will handled user/password for auth
self.network = Network(user, password)
# APIs
self.DatabaseUsers = Atlas._DatabaseUsers(self)
self.Clusters = Atlas._Clusters(self)
self.Hosts = Atlas._Hosts(self)
self.Events = Atlas._Events(self)
self.logger = logging.getLogger(name='Atlas')
self.Alerts = Atlas._Alerts(self)
self.Whitelist = Atlas._Whitelist(self)
self.MaintenanceWindows = Atlas._MaintenanceWindows(self)
def __init__(self, user, password, group):
self.group = group
# Network calls which will handled user/password for auth
self.network = Network(user, password)
# APIs
self.DatabaseUsers = Atlas._DatabaseUsers(self)
self.Clusters = Atlas._Clusters(self)
self.Hosts = Atlas._Hosts(self)
self.Events = Atlas._Events(self)
self.logger = logging.getLogger(name='Atlas')
self.Alerts = Atlas._Alerts(self)
self.Whitelist = Atlas._Whitelist(self)
self.MaintenanceWindows = Atlas._MaintenanceWindows(self)
def __init__(self, user, password, group):
self.group = group
# Network calls which will handled user/password for auth
self.network = Network(user, password)
# APIs
self.DatabaseUsers = Atlas._DatabaseUsers(self)
self.Clusters = Atlas._Clusters(self)
self.Hosts = Atlas._Hosts(self)
self.Events = Atlas._Events(self)
self.logger = logging.getLogger(name='Atlas')
self.Alerts = Atlas._Alerts(self)
self.Whitelist = Atlas._Whitelist(self)
self.MaintenanceWindows = Atlas._MaintenanceWindows(self)
def __init__(self, user, password, group):
self.group = group
# Network calls which will handled user/password for auth
self.network = Network(user, password)
# APIs
self.DatabaseUsers = Atlas._DatabaseUsers(self)
self.Clusters = Atlas._Clusters(self)
self.Hosts = Atlas._Hosts(self)
self.Events = Atlas._Events(self)
self.logger = logging.getLogger(name='Atlas')
self.Alerts = Atlas._Alerts(self)
self.Whitelist = Atlas._Whitelist(self)
self.MaintenanceWindows = Atlas._MaintenanceWindows(self)