def get_alert_config(deployment_id, metric_name=None, api_key=None, profile='telemetry'):
 auth = _auth(profile=profile)
 alert = False
 key = 'telemetry.{0}.alerts'.format(deployment_id)
 if (key not in __context__):
  try:
   get_url = (_get_telemetry_base(profile) + '/alerts?deployment={0}'.format(deployment_id))
   response = requests.get(get_url, headers=auth)
  except requests.exceptions.RequestException as e:
   log.error(str(e))
   return False
  http_result = {}
  if (response.status_code == 200):
   for alert in response.json():
    http_result[alert.get('condition', {}).get('metric')] = alert
    __context__[key] = http_result
 if (not __context__.get(key)):
  return []
 alerts = __context__[key].values()
 if metric_name:
  return __context__[key].get(metric_name)
 return [alert['_id'] for alert in alerts if ('_id' in alert)]

def get_alert_config ( deployment_id , metric_name = None , api_key = None , profile = 'telemetry' ) : auth = _auth ( profile = profile ) alert = False key = 'telemetry.{0}.alerts' . format ( deployment_id ) if ( key not in __context__ ) : try : get_url = ( _get_telemetry_base ( profile ) + '/alerts?deployment={0}' . format ( deployment_id ) ) response = requests . get ( get_url , headers = auth ) except requests . exceptions . RequestException as e : log . error ( str ( e ) ) return False http_result = { } if ( response . status_code == 200 ) : for alert in response . json ( ) : http_result [ alert . get ( 'condition' , { } ) . get ( 'metric' ) ] = alert __context__ [ key ] = http_result if ( not __context__ . get ( key ) ) : return [ ] alerts = __context__ [ key ] . values ( ) if metric_name : return __context__ [ key ] . get ( metric_name ) return [ alert [ '_id' ] for alert in alerts if ( '_id' in alert ) ]
get all alert definitions associated with a given deployment or if metric_name is specified .