示例#1
0
 def test_MonitisError(self):
     '''Test calls to the API that raise a MonitisError'''
     try:
         get(action='secretkey',apikey='bad_api_key')
     except MonitisError, error:
         assert_equal(str(error), 
             'MonitisError(API Error: {"error":"Authentication failure"})')
示例#2
0
 def test_MonitisError(self):
     '''Test calls to the API that raise a MonitisError'''
     try:
         get(action='secretkey', apikey='bad_api_key')
     except MonitisError, error:
         assert_equal(
             str(error),
             'MonitisError(API Error: {"error":"Authentication failure"})')
示例#3
0
def sub_accounts(**kwargs):
    ''' The subaccounts associated with the given API key

    Results resturned as a JSON structure
    '''

    return get(action='subAccounts', **kwargs)
def get_notification_rules(**kwargs):
    ''' Get list of existing notification rules for the specified monitor '''
    required = ['monitorId', 'monitorType']
    optional = []

    get_args = validate_kwargs(required, optional, **kwargs)
    return get(action='getNotificationRules', **get_args)
示例#5
0
文件: user.py 项目: SeanYa/Python-SDK
def sub_accounts(**kwargs):
    ''' The subaccounts associated with the given API key

    Results resturned as a JSON structure
    '''

    return get(action='subAccounts', **kwargs)
示例#6
0
def secretkey(apikey=None):
    ''' The secret key associated with the given API key '''

    if apikey is None:
        apikey = resolve_apikey()

    return get(action='secretkey', apikey=apikey)['secretkey']
示例#7
0
文件: user.py 项目: SeanYa/Python-SDK
def secretkey(apikey=None):
    ''' The secret key associated with the given API key '''

    if apikey is None:
        apikey = resolve_apikey()

    return get(action='secretkey', apikey=apikey)['secretkey']
示例#8
0
def get_recent_alerts(**kwargs):
    ''' Get recent alerts history

    Start date and end date are in miliseconds since the Epoch'''
    required = []
    optional = ['timezone', 'startDate', 'endDate']
    post_args = validate_kwargs(required, optional, **kwargs)
    return get(action='recentAlerts', **post_args)
示例#9
0
def transaction_test_result(**kwargs):
    ''' Get results for the specified Transaction or
    Full Page Load monitor
    '''
    required = ['monitorId', 'year', 'month', 'day']
    optional = ['locationIds', 'timezone']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='transactionTestResult', **req_args)
示例#10
0
def apikey(username, password):
    ''' The API key associated with the given username and password '''

    password_hash = md5()
    password_hash.update(password)
    password_digest = password_hash.hexdigest()

    result = get(action='apikey', userName=username, password=password_digest)
    return result['apikey']
示例#11
0
def transaction_snapshot(**kwargs):
    ''' Get last results of user's Transaction monitors '''
    required = []
    optional = ['locationIds']
    req_args = validate_kwargs(required, optional, **kwargs)
    location_ids = req_args.get('locationIds', None)
    if isinstance(location_ids, list):
        req_args['locationIds'] = ','.join(map(str,location_ids))
    return get(action='transactionSnapshot', **req_args)
示例#12
0
文件: user.py 项目: SeanYa/Python-SDK
def apikey(username, password):
    ''' The API key associated with the given username and password '''

    password_hash = md5()
    password_hash.update(password)
    password_digest = password_hash.hexdigest()

    result = get(action='apikey', userName=username, password=password_digest)
    return result['apikey']
示例#13
0
def cloud_instances(**kwargs):
    ''' Get a user's cloud instances

    Parameters:
        timezoneoffset - offset relative to GMT, in minutes
    '''
    required = []
    optional = ['timezoneoffset']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='cloudInstances', **req_args)
示例#14
0
def internal_result(**kwargs):
    ''' Helper function to get results for internal monitors

    This function does not directly map to any specific action in the
    Monitis API.  Rather, it is a helper, and requires that the calling
    function supply the action, in addition to the agent ID.
    '''
    required = ['monitorId', 'day', 'month', 'year', 'action']
    optional = ['timezone']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(**req_args)
示例#15
0
def internal_result(**kwargs):
    """ Helper function to get results for internal monitors

    This function does not directly map to any specific action in the
    Monitis API.  Rather, it is a helper, and requires that the calling
    function supply the action, in addition to the agent ID.
    """
    required = ["monitorId", "day", "month", "year", "action"]
    optional = ["timezone"]
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(**req_args)
示例#16
0
def agent_monitors(**kwargs):
    """ Helper function to get agent monitors

    This function does not directly map to any specific action in the
    Monitis API.  Rather, it is a helper, and requires that the calling
    function supply the action, in addition to the agent ID.
    """
    required = ["agentId", "action"]
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(**req_args)
示例#17
0
def visitor_tracking_info(**kwargs):
    ''' get information about the specified Visitor Tracker 

    Results are a list, but the order may differ from the docs
    [siteId, url, name, monitorId], though it isn't
    entirely clear.
    '''
    required = ['siteId']
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='visitorTrackingInfo', **req_args)
示例#18
0
def full_page_load_test_result(**kwargs):
    ''' Get results for the specified Full Page Load monitor '''
    required = ['monitorId', 'year', 'month', 'day']
    optional = ['locationIds', 'timezone']

    req_args = validate_kwargs(required, optional, **kwargs)
    location_ids = req_args.get('locationIds', None)
    if isinstance(location_ids, list):
        req_args['locationIds'] = ','.join(location_ids)

    return get(action='fullPageLoadTestResult', **req_args)
示例#19
0
def agent_monitors(**kwargs):
    ''' Helper function to get agent monitors

    This function does not directly map to any specific action in the
    Monitis API.  Rather, it is a helper, and requires that the calling
    function supply the action, in addition to the agent ID.
    '''
    required = ['agentId', 'action']
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(**req_args)
示例#20
0
def full_page_load_test_result(**kwargs):
    ''' Get results for the specified Full Page Load monitor '''
    required = ['monitorId', 'year', 'month', 'day']
    optional = ['locationIds', 'timezone']

    req_args = validate_kwargs(required, optional, **kwargs)
    location_ids = req_args.get('locationIds', None)
    if isinstance(location_ids, list):
        req_args['locationIds'] = ','.join(location_ids)

    return get(action='fullPageLoadTestResult', **req_args)
示例#21
0
def tests_last_values(**kwargs):
    ''' Get the last results of a user's external monitors '''
    required = []
    optional = ['locationIds']
    req_args = validate_kwargs(required, optional, **kwargs)

    # locationIds may be a list
    location_ids = req_args.get('locationIds')
    if type(location_ids) is list:
        req_args['locationIds'] = ','.join(location_ids)

    return get(action='testsLastValues', **req_args)
示例#22
0
def testresult(**kwargs):
    ''' Get results of the specified External monitor '''
    required = ['testId', 'day', 'month', 'year']
    optional = ['locationIds', 'timezone']
    req_args = validate_kwargs(required, optional, **kwargs)

    # locationIds may be a list
    location_ids = req_args.get('locationIds')
    if type(location_ids) is list:
        req_args['locationIds'] = ','.join(location_ids)

    return get(action='testresult', **req_args)
示例#23
0
def auth_token(apikey=None, secretkey=None):
    ''' Generate an auth token

    If the apikey and/or secretkey are not specified as parameters,
    then they will be resolved, if possible.
    '''

    if apikey is None:
        apikey = resolve_apikey()

    if secretkey is None:
        secretkey = resolve_secretkey()

    return get(action='authToken', apikey=apikey,
               secretkey=secretkey)['authToken']
示例#24
0
文件: user.py 项目: SeanYa/Python-SDK
def auth_token(apikey=None, secretkey=None):
    ''' Generate an auth token

    If the apikey and/or secretkey are not specified as parameters,
    then they will be resolved, if possible.
    '''

    if apikey is None:
        apikey = resolve_apikey()

    if secretkey is None:
        secretkey = resolve_secretkey()

    return get(action='authToken', apikey=apikey,
               secretkey=secretkey)['authToken']
示例#25
0
def internal_monitors(**kwargs):
    """ Get a user's internal monitors

    Monitors returned can be filtered by type, such as:
        - memory
        - load
        - drive
        - process
        - cpu
        - agentHttpTest
        - agentPingTest

    """
    required = []
    optional = ["types", "tag", "tagRegExp"]

    req_args = validate_kwargs(required, optional, **kwargs)
    types = req_args.get("types", None)
    if isinstance(types, list):
        req_args["types"] = ",".join(types)
    return get(action="internalMonitors", **req_args)
示例#26
0
def internal_monitors(**kwargs):
    ''' Get a user's internal monitors

    Monitors returned can be filtered by type, such as:
        - memory
        - load
        - drive
        - process
        - cpu
        - agentHttpTest
        - agentPingTest

    '''
    required = []
    optional = ['types', 'tag', 'tagRegExp']

    req_args = validate_kwargs(required, optional, **kwargs)
    types = req_args.get('types', None)
    if isinstance(types, list):
        req_args['types'] = ','.join(types)
    return get(action='internalMonitors', **req_args)
示例#27
0
    def setUp(self):
        # Monitis.sandbox = True
        Monitis.debug = True

        [monitis.user.delete_sub_account(x['id'])
            for x in monitis.user.sub_accounts()
            if x['account'].endswith('@test.com')]

        first_name = 'Test'
        last_name = 'Account'
        email = '*****@*****.**'
        password = '******'
        group = 'testgroup'

        ret = monitis.user.add_sub_account(first_name, last_name, email,
                                           password, group)

        self.test_account_id = ret['data']['userId']

        page_title = get(action='pages')[0]['title']
        res = monitis.user.add_sub_account_pages(user_id=self.test_account_id,
                                                 pages=[page_title])
示例#28
0
def tagtests(**kwargs):
    ''' Get external monitors for the specified tag '''
    required = ['tag']
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='tagtests', **req_args)
示例#29
0
def locations(**kwargs):
    ''' Get all of the locations for the user's external monitors '''
    required = []
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='locations', **req_args)
示例#30
0
def testinfo(**kwargs):
    ''' Get information for the specified external monitor '''
    required = ['testId']
    optional = ['timezone']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='testinfo', **req_args)
示例#31
0
def tests(**kwargs):
    ''' Get all external monitors for the user '''
    required = []
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='tests', **req_args)
示例#32
0
 def test_delete_sub_account_pages(self):
     page_title = get(action='pages')[0]['title']
     res = monitis.user.delete_sub_account_pages(user_id=self.test_account_id,
                                              pages=[page_title])
     assert_equal(res['status'], 'ok')
示例#33
0
def agent_snapshot(**kwargs):
    ''' Get last results for all monitors of the specified agent '''
    required = ['agentKey']
    optional = ['timezone']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='agentSnapshot', **req_args)
示例#34
0
def all_agents_snapshot(**kwargs):
    ''' Get last results for user's internal monitors '''
    required = ['platform']
    optional = ['timezone', 'tag']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='allAgentsSnapshot', **req_args)
示例#35
0
def agent_info(**kwargs):
    ''' Get information regarding the specified agent '''
    required = ['agentId']
    optional = ['loadTests']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='agentInfo', **req_args)
示例#36
0
def agents(**kwargs):
    ''' Get a user's agents '''
    required = []
    optional = ['keyRegExp']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='agents', **req_args)
示例#37
0
def _custom_get(**kwargs):
    '''HTTP GET using URL for customMonitor API'''
    return get(_url=_api_url(), **kwargs)
示例#38
0
def visitor_tracking_tests(**kwargs):
    ''' Get a user's visitor trackers '''
    required = []
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='visitorTrackingTests', **req_args)
示例#39
0
def full_page_load_locations(**kwargs):
    ''' Get all locations for full page load monitors '''
    required = []
    optional = []
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='fullPageLoadLocations', **req_args)
示例#40
0
def visitor_tracking_results(**kwargs):
    ''' Get results of the specified Visitor Tracker '''
    required = ['siteId', 'year', 'month', 'day']
    optional = ['timezoneoffset']
    req_args = validate_kwargs(required, optional, **kwargs)
    return get(action='visitorTrackingResults', **req_args)
示例#41
0
def get_contact_groups():
    ''' Get all contact groups for the user '''
    return get(action='contactGroupList')