def get_all_alert_violations(api_key, start_date, end_date, only_open): params = { 'start_date': start_date, 'end_date': end_date, 'only_open': only_open } return utils.get_paginated_entities(api_key, ALERT_VIOLATIONS_URL, VIOLATIONS, params)
def get_dashboard_definition(api_key, name): params = {'filter[title]': name} result = {'entityFound': False, 'status': 404} results = utils.get_paginated_entities(api_key, GET_DASHBOARDS_URL, DASHBOARDS, params) if results['response_count'] <= 0: return result for dashboard in results[DASHBOARDS]: if dashboard['title'] == name: result['status'] = 200 result['entityFound'] = True result['entity'] = dashboard break return result
def get_nrql_conditions(api_key, policy_id): params = {'policy_id': policy_id} return utils.get_paginated_entities(api_key, NRQL_CONDITIONS_URL, NRQL_CONDITIONS, params)
def get_location_failure_conditions(api_key, policy_id): get_url = LOC_FAILURE_CONDITIONS_URL + str(policy_id) + '.json' return utils.get_paginated_entities(api_key, get_url, LOCATION_FAILURE_CONDITIONS)
def get_synthetic_conditions(api_key, alert_id): params = {'policy_id': alert_id} return utils.get_paginated_entities(api_key, GET_SYNTH_CONDITIONS_URL, SYNTH_CONDITIONS, params)
def get_channels(api_key): return utils.get_paginated_entities(api_key, ALERTS_CHANNEL_URL, CHANNELS)
def get_all_alert_policies(api_key): return utils.get_paginated_entities(api_key, ALERT_POLICIES_URL, POLICIES)
def get_extsvc_conditions(api_key, policy_id): params = {'policy_id': policy_id} return utils.get_paginated_entities(api_key, EXTSVC_CONDITIONS_URL, EXTSVC_CONDITIONS, params)
def get_app_conditions(api_key, alert_id): params = {'policy_id': alert_id} return utils.get_paginated_entities(api_key, GET_APP_CONDITIONS_URL, CONDITIONS, params)
def delete_all_dashboards(api_key): result = utils.get_paginated_entities(api_key, GET_DASHBOARDS_URL, 'dashboards') for dashboard in result['dashboards']: logger.info('Deleting ' + dashboard['title']) delete_dashboard(api_key, dashboard['id'])