#NEWLINE# @ utils . arg ( 'name' , metavar = '<METRIC_NAME>' , help = 'Name of the metric to list measurements.' ) #NEWLINE# @ utils . arg ( '--dimensions' , metavar = '<KEY1=VALUE1,KEY2=VALUE2...>' , help = 'key value pair used to specify a metric dimension. This can be specified multiple times, or once with parameters separated by a comma. Dimensions need quoting when they contain special chars [&,(,),{,},>,<] that confuse the CLI parser.' , action = 'append' ) #NEWLINE# @ utils . arg ( 'starttime' , metavar = '<UTC_START_TIME>' , help = 'measurements >= UTC time. format: 2014-01-01T00:00:00Z. OR Format: -120 (previous 120 minutes).' ) #NEWLINE# @ utils . arg ( '--endtime' , metavar = '<UTC_END_TIME>' , help = 'measurements <= UTC time. format: 2014-01-01T00:00:00Z.' ) #NEWLINE# @ utils . arg ( '--offset' , metavar = '<OFFSET LOCATION>' , help = 'The offset used to paginate the return data.' ) #NEWLINE# @ utils . arg ( '--limit' , metavar = '<RETURN LIMIT>' , help = 'The amount of data to be returned up to the API maximum limit.' ) #NEWLINE# @ utils . arg ( '--merge_metrics' , action = 'store_const' , const = True , help = 'Merge multiple metrics into a single result.' ) #NEWLINE# def do_measurement_list( mc , args ) : #NEWLINE# #INDENT# 'List measurements for the specified metric.' #NEWLINE# fields = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# fields [ 'name' ] = args . name #NEWLINE# if args . dimensions : #NEWLINE# #INDENT# fields [ 'dimensions' ] = utils . format_dimensions_query ( args . dimensions ) #NEWLINE# #UNINDENT# _translate_starttime ( args ) #NEWLINE# fields [ 'start_time' ] = args . starttime #NEWLINE# if args . endtime : #NEWLINE# #INDENT# fields [ 'end_time' ] = args . endtime #NEWLINE# #UNINDENT# if args . limit : #NEWLINE# #INDENT# fields [ 'limit' ] = args . limit #NEWLINE# #UNINDENT# if args . offset : #NEWLINE# #INDENT# fields [ 'offset' ] = args . offset #NEWLINE# #UNINDENT# if args . merge_metrics : #NEWLINE# #INDENT# fields [ 'merge_metrics' ] = args . merge_metrics #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# metric = mc . metrics . list_measurements ( ** fields ) #NEWLINE# #UNINDENT# except exc . HTTPException as he : #NEWLINE# #INDENT# raise exc . CommandError ( ( 'HTTPException code=%s message=%s' % ( he . code , he . message ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if args . json : #NEWLINE# #INDENT# print ( utils . json_formatter ( metric ) ) #NEWLINE# return #NEWLINE# #UNINDENT# cols = [ 'name' , 'dimensions' , 'timestamp' , 'value' , 'value_meta' ] #NEWLINE# formatters = { #NEWLINE# #INDENT# 'name' : ( lambda x : x [ 'name' ] ) , #NEWLINE# 'dimensions' : ( lambda x : utils . format_dict ( x [ 'dimensions' ] ) ) , #NEWLINE# 'timestamp' : ( lambda x : format_measure_timestamp ( x [ 'measurements' ] ) ) , #NEWLINE# 'value' : ( lambda x : format_measure_value ( x [ 'measurements' ] ) ) , #NEWLINE# 'value_meta' : ( lambda x : format_value_meta ( x [ 'measurements' ] ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# if isinstance ( metric , list ) : #NEWLINE# #INDENT# utils . print_list ( metric , cols , formatters = formatters ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# metric_list = list ( ) #NEWLINE# metric_list . append ( metric ) #NEWLINE# utils . print_list ( metric_list , cols , formatters = formatters )