1010TODO: Allow changing instance's tenant?
1111TODO: Authentication when it's done..
1212TODO: Remove HawkularMetricsConnectionError and use HawkularMetricsError only?
13- TODO: 0.3.3 will before release move the tenantId to headers..
1413"""
1514
1615class MetricType :
@@ -88,7 +87,7 @@ def _get_base_url(self):
8887 return "http://{0}:{1}/{2}/" .format (self .host , str (self .port ), self .path )
8988
9089 def _get_url (self , metric_type ):
91- return self ._get_base_url () + '{0}/{1} ' .format (self . tenant_id , metric_type )
90+ return self ._get_base_url () + '{0}' .format (metric_type )
9291
9392 def _get_metrics_single_url (self , metric_type , metric_id ):
9493 return self ._get_url (metric_type ) + '/{0}' .format (self ._clean_metric_id (metric_id ))
@@ -108,6 +107,7 @@ def _http(self, url, method, data=None):
108107 try :
109108 req = urllib2 .Request (url = url )
110109 req .add_header ('Content-Type' , 'application/json' )
110+ req .add_header ('tenantId' , self .tenant_id )
111111
112112 if not isinstance (data , str ):
113113 data = json .dumps (data , indent = 2 )
@@ -246,10 +246,7 @@ def query_definitions(self, query_type):
246246 """
247247 Query available metric definitions.
248248 """
249- # if isinstance(query_type, MetricType):
250- # query_type = MetricType.short(query_type)
251-
252- definition_url = self ._get_url ('metrics' ) + '?type=' + query_type
249+ definition_url = self ._get_url ('metrics' ) + '?type=' + MetricType .short (query_type )
253250 return self ._get (definition_url )
254251
255252 def create_metric_definition (self , metric_type , metric_id , ** tags ):
0 commit comments