def add_process_monitor(**kwargs): ''' Add a new internal process monitor ''' required = ['agentkey', 'processName'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addProcessMonitor', **req_args)
def edit_internal_ping_monitor(**kwargs): ''' Edit the specified Ping monitor ''' required = ['testId'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='editInternalPingMonitor', **req_args)
def add_notification_rule(**kwargs): ''' Add a notification rule for monitor - contact pair ''' required = ['monitorId', 'monitorType', 'period', 'notifyBackup', 'continuousAlerts', 'failureCount'] optional = ['weekdayFrom', 'weekdayTo', 'timeFrom', 'timeTo', 'contactGroup', 'contactId', 'minFailedLocationCount', 'paramName', 'paramValue', 'comparingMethod'] post_args = validate_kwargs(required, optional, **kwargs) # paramName and paramValue are required when monitorType is custom if post_args.get('monitorType', None) is 'custom': if not (post_args.has_key('paramName') \ and post_args.has_key('paramValue')): raise MonitisError('paramName and paramValue are required') # comparingMethod is required when paramName and paramValue are present if post_args.has_key('paramName') or post_args.has_key('paramValue'): if not post_args.has_key('comparingMethod'): raise MonitisError('comparingMethod is required') # either contact_group or contact_id must be specified if not (post_args.has_key('contactGroup') \ or post_args.has_key('contactId')): raise MonitisError('Either contactName or contactGroup is required') return post(action='addNotificationRule', **post_args)
def edit_internal_http_monitor(**kwargs): ''' Edit the specified http monitor ''' required = ['testId', 'urlParams'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='editInternalHttpMonitor', **req_args)
def add_page_module(**kwargs): ''' Add a module to the specified page. ''' required = ['moduleName', 'pageId', 'column', 'row', 'dataModuleId'] optional = ['height'] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addPageModule', **req_args)
def confirm_contact(**kwargs): ''' Confirm the specified contact ''' required = ['contactId', 'confirmationKey'] optional = [] post_args = validate_kwargs(required, optional, **kwargs) return post(action='confirmContact', **post_args)
def edit_memory_monitor(**kwargs): """ Edit the specified memory monitor """ required = ["testId"] required.extend(common_required) optional = ["freeLimit", "freeSwapLimit", "freeVirtualLimit", "bufferedLimit", "cachedLimit"] req_args = validate_kwargs(required, optional, **kwargs) return post(action="editMemoryMonitor", **req_args)
def add_internal_ping_monitor(**kwargs): ''' Add a new internal ping monitor ''' required = ['userAgentId', 'url'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addInternalPingMonitor', **req_args)
def edit_process_monitor(**kwargs): ''' Edit the specified process monitor ''' required = ['testId'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='editProcessMonitor', **req_args)
def add_load_average_monitor(**kwargs): """ Add a new internal load monitor """ required = ["agentkey"] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action="addLoadAverageMonitor", **req_args)
def add_drive_monitor(**kwargs): ''' Add a new internal drive monitor ''' required = ['agentkey', 'driveLetter'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addDriveMonitor', **req_args)
def edit_load_average_monitor(**kwargs): """ Edit the specified load monitor """ required = ["testId"] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action="editLoadAverageMonitor", **req_args)
def add_load_average_monitor(**kwargs): ''' Add a new internal load monitor ''' required = ['agentkey'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addLoadAverageMonitor', **req_args)
def edit_load_average_monitor(**kwargs): ''' Edit the specified load monitor ''' required = ['testId'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='editLoadAverageMonitor', **req_args)
def delete_contact(**kwargs): ''' Delete a contact Required fields: contactId, or contactType AND account ''' required = [] optional = ['contactId', 'contactType', 'account'] req_args = validate_kwargs(required, optional, **kwargs) valid_args = bool(req_args['contactId'] or (req_args['contactType'] and req_args['account'])) if not valid_args: raise MonitisError('Contact ID or Contact Type and Account required') post(action='deleteContact', **req_args)
def add_memory_monitor(**kwargs): """ Add a new internal memory monitor """ required = ["agentkey"] required.extend(common_required) optional = ["freeLimit", "freeSwapLimit", "freeVirtualLimit", "bufferedLimit", "cachedLimit"] req_args = validate_kwargs(required, optional, **kwargs) return post(action="addMemoryMonitor", **req_args)
def activate_full_page_load_monitor(**kwargs): ''' Activate full page load monitors ''' required = [] optional = ['monitorIds', 'tag'] req_args = validate_kwargs(required, optional, **kwargs) return post(action='activateFullPageLoadMonitor', **req_args)
def delete_agents(**kwargs): ''' Delete agent from user's account ''' required = [] optional = ['agentIds', 'keyRegExp'] req_args = validate_kwargs(required, optional, **kwargs) if not ('agentIds' in req_args or 'keyRegExp' in req_args): raise MonitisError('agent_ids or key_reg_exp is required') return post(action='deleteAgents', **req_args)
def add_internal_http_monitor(**kwargs): ''' Add a new internal http monitor ''' required = ['userAgentId', 'url', 'contentMatchFlag', 'loadFull', 'overSSL', 'redirect'] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addInternalHttpMonitor', **req_args)
def edit_contact(**kwargs): ''' ''' required = ['contactId'] optional = ['firstName', 'lastName', 'account', 'contactType', 'timezone', 'portable', 'code', 'country', 'textType'] post_args = validate_kwargs(required, optional, **kwargs) return post(action='editContact', **post_args)
def activate_transaction_monitor(**kwargs): ''' Activate transaction monitors ''' required = [] optional = ['monitorIds', 'tag'] req_args = validate_kwargs(required, optional, **kwargs) monitor_ids = req_args.get('monitorIds', None) if isinstance(monitor_ids, list): req_args['monitorIds'] = ','.join(map(str,monitor_ids)) return post(action='activateTransactionMonitor', **req_args)
def delete_sub_account_pages(user_id=None, pages=[]): if user_id is None: raise MonitisError("user_id is required") pages_arg = ';'.join(pages) if pages_arg is '': raise MonitisError("One or more pages required") post_args = {'userId': user_id, 'pageNames': pages_arg} return post(action='deletePagesFromSubAccount', **post_args)
def add_sub_account(first_name, last_name, email, password, group): post_args = { 'firstName': first_name, 'lastName': last_name, 'email': email, 'password': password, 'group': group } return post(action='addSubAccount', **post_args)
def download_agent(**kwargs): ''' Download the agent Returns a raw HTTP Response object instead of parsed JSON ''' required = ['platform'] optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='downloadAgent', _raw=True, **req_args)
def add_sub_account_pages(apikey=None, user_id=None, pages=[]): ''' ''' if user_id is None: raise MonitisError("user_id is required") pages_arg = ';'.join(pages) if pages_arg is '': raise MonitisError("One or more pages required") post_args = {'userId': user_id, 'pageNames': pages_arg} return post(action='addPagesToSubAccount', **post_args)
def delete_full_page_load_monitor(**kwargs): ''' Delete an existing full page load monitor ''' required = ['monitorId'] optional = [] req_args = validate_kwargs(required, optional, **kwargs) monitor_id = req_args['monitorId'] if isinstance(monitor_id, list): req_args['monitorId'] = ','.join(monitor_id) return post(action='deleteFullPageLoadMonitor', **req_args)
def add_memory_monitor(**kwargs): ''' Add a new internal memory monitor ''' required = ['agentkey'] required.extend(common_required) optional = [ 'freeLimit', 'freeSwapLimit', 'freeVirtualLimit', 'bufferedLimit', 'cachedLimit' ] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addMemoryMonitor', **req_args)
def edit_memory_monitor(**kwargs): ''' Edit the specified memory monitor ''' required = ['testId'] required.extend(common_required) optional = [ 'freeLimit', 'freeSwapLimit', 'freeVirtualLimit', 'bufferedLimit', 'cachedLimit' ] req_args = validate_kwargs(required, optional, **kwargs) return post(action='editMemoryMonitor', **req_args)
def add_internal_http_monitor(**kwargs): ''' Add a new internal http monitor ''' required = [ 'userAgentId', 'url', 'contentMatchFlag', 'loadFull', 'overSSL', 'redirect' ] required.extend(common_required) optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addInternalHttpMonitor', **req_args)
def delete_external_monitor(**kwargs): ''' Delete one or more external monitors ''' required = ['testIds'] optional = [] req_args = validate_kwargs(required, optional, **kwargs) # if test_ids is a list, make a comma delimited string test_ids = req_args.get('testIds') if type(test_ids) is list: req_args['testIds'] = ','.join(test_ids) return post(action='deleteExternalMonitor', **req_args)
def edit_full_page_load_monitor(**kwargs): ''' Edit an existing full page load monitor ''' required = ['name', 'tag', 'locationIds', 'checkInterval', 'url', 'timeout', 'monitorId'] optional = ['uptimeSLA', 'responseSLA'] req_args = validate_kwargs(required, optional, **kwargs) location_ids = req_args['locationIds'] if isinstance(location_ids, list): req_args['locationIds'] = ','.join(location_ids) return post(action='editFullPageLoadMonitor', **req_args)
def add_full_page_load_monitor(**kwargs): ''' Add a new full page load monitor ''' required = [ 'name', 'tag', 'locationIds', 'checkInterval', 'url', 'timeout' ] optional = ['uptimeSLA', 'responseSLA'] req_args = validate_kwargs(required, optional, **kwargs) location_ids = req_args['locationIds'] if isinstance(location_ids, list): req_args['locationIds'] = ','.join(location_ids) return post(action='addFullPageLoadMonitor', **req_args)
def delete_notification_rule(**kwargs): ''' Delete an existing notification rule for monitor - contact pair ''' required = ['contactIds', 'monitorId', 'monitorType'] optional = [] post_args = validate_kwargs(required, optional, **kwargs) # replace list with comma-separated string contact_ids = post_args['contactIds'] if type(contact_ids) is list: post_args['contact_ids'] = ','.join(contact_ids) return post(action='deleteNotificationRule', **post_args)
def edit_external_monitor(**kwargs): ''' Edit an external monitor ''' required = ['testId', 'name', 'url', 'locationIds', 'timeout', 'tag'] optional = [ 'contentMatchString', 'maxValue', 'uptimeSLA', 'responseSLA' ] 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(str(x) for x in location_ids) return post(action='editExternalMonitor', **req_args)
def add_contact(**kwargs): ''' Add a new contact Required fields: firstName, lastName, account, contactType, timezone. Optional fields: group, sendDailyReport, sendWeeklyReport, sendMonthlyReport, portable, country, textType ''' required = ['firstName', 'lastName', 'account', 'contactType', 'timezone'] optional = ['sendDailyReport', 'sendWeeklyReport','sendMonthlyReport', 'portable', 'country', 'textType'] post_args = validate_kwargs(required, optional, **kwargs) return post(action='addContact', **post_args)
def delete_internal_monitors(**kwargs): """ Delete the specified internal monitors type is the type of the monitors specified in test_ids. Possible values: - 1 for process monitors - 2 for drive monitors - 3 for memory monitors - 4 for internal HTTP monitors - 5 for internal ping monitors - 6 for load average monitors - 7 for CPU monitors """ required = ["testIds", "type"] optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action="deleteInternalMonitors", **req_args)
def activate_external_monitor(**kwargs): ''' Suspend an external monitor ''' required = [] optional = ['monitorIds', 'tag'] req_args = validate_kwargs(required, optional, **kwargs) # only one of monitor_ids and tag is required if not (req_args.has_key('monitorIds') or (req_args.has_key('tag'))): raise MonitisError('monitorIds or tag is required') # monitorIds might be a list monitor_ids = req_args.get('monitorIds') if type(monitor_ids) is list: req_args['monitorIds'] = ','.join(monitor_ids) return post(action='activateExternalMonitor', **req_args)
def delete_internal_monitors(**kwargs): ''' Delete the specified internal monitors type is the type of the monitors specified in test_ids. Possible values: - 1 for process monitors - 2 for drive monitors - 3 for memory monitors - 4 for internal HTTP monitors - 5 for internal ping monitors - 6 for load average monitors - 7 for CPU monitors ''' required = ['testIds', 'type'] optional = [] req_args = validate_kwargs(required, optional, **kwargs) return post(action='deleteInternalMonitors', **req_args)
def add_external_monitor(**kwargs): ''' add a new External monitor ''' required = ['type', 'name', 'url', 'interval', 'locationIds', 'tag'] optional = ['detailedTestType', 'timeout', 'overSSL', 'postData', 'contentMatchFlag', 'contentMatchString', 'params', 'uptimeSLA', 'responseSLA', 'basicAuthUser', 'basicAuthPass'] req_args = validate_kwargs(required, optional, **kwargs) # params required only for DNS and MySQL test_type = req_args.get('type') if test_type is 'mysql' or test_type is 'dns': if not req_args.has_key('params'): raise MonitisError('params is required for DNS and MySQL tests') # locationIds may be a list location_ids = req_args.get('locationIds') if type(location_ids) is list: req_args['locationIds'] = ','.join(str(x) for x in location_ids) return post(action='addExternalMonitor', **req_args)
def add_cpu_monitor(**kwargs): ''' Add a CPU monitor ''' required = ['agentkey', 'kernelMax', 'usedMax', 'name', 'tag'] optional = ['idleMin', 'ioWaitMax', 'niceMax'] req_args = validate_kwargs(required, optional, **kwargs) return post(action='addCPUMonitor', **req_args)
def edit_cpu_monitor(**kwargs): ''' Edit an existing CPU monitor ''' required = ['testId', 'kernelMax', 'usedMax', 'name', 'tag'] optional = ['idleMin', 'ioWaitMax', 'niceMax'] req_args = validate_kwargs(required, optional, **kwargs) return post(action='editCPUMonitor', **req_args)
def _custom_post(**kwargs): ''' HTTP POST with URL for custom API''' return post(_url=_api_url(), **kwargs)