<s> import requests <EOL> from st2actions . runners . pythonrunner import Action <EOL> class GetMetricDataAction ( Action ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( GetMetricDataAction , self ) . __init__ ( * args , ** kwargs ) <EOL> self . base_url = '<STR_LIT>' <EOL> self . metrics_url = '<STR_LIT>' <EOL> self . url = None <EOL> self . headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . headers [ '<STR_LIT>' ] = self . config [ '<STR_LIT>' ] <EOL> def run ( self , app_id , metric_base_name , <EOL> actual_metrics , time_from , time_to ) : <EOL> body = self . _get_body ( metric_base_name , actual_metrics , time_from , time_to ) <EOL> self . url = self . base_url + app_id + self . metrics_url <EOL> resp = requests . get ( self . url , headers = self . headers , data = body ) . json ( ) <EOL> return resp <EOL> def _get_body ( self , metric_base_name , actual_metrics , time_from , time_to ) : <EOL> params = '<STR_LIT>' + metric_base_name <EOL> params = params + '<STR_LIT:&>' + '<STR_LIT:&>' . join ( [ '<STR_LIT>' + metric for metric in actual_metrics ] ) <EOL> params = params + '<STR_LIT:&>' + '<STR_LIT>' + time_from <EOL> params = params + '<STR_LIT:&>' + '<STR_LIT>' + time_to <EOL> params = params + '<STR_LIT:&>' + '<STR_LIT>' + '<STR_LIT:true>' <EOL> return params </s>
