Skip to content

Commit 63ffda1

Browse files
committed
Move tenantId to headers
1 parent 18edce4 commit 63ffda1

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

hawkular/metrics.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
TODO: Allow changing instance's tenant?
1111
TODO: Authentication when it's done..
1212
TODO: Remove HawkularMetricsConnectionError and use HawkularMetricsError only?
13-
TODO: 0.3.3 will before release move the tenantId to headers..
1413
"""
1514

1615
class 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):

hawkular/metrics_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class TestMetricFunctionsBase(unittest.TestCase):
66

77
def setUp(self):
88
self.test_tenant = str(uuid.uuid4())
9-
self.client = HawkularMetricsClient(tenant_id=self.test_tenant, port=8081)
9+
self.client = HawkularMetricsClient(tenant_id=self.test_tenant, port=8080)
1010

1111
class TenantTestCase(TestMetricFunctionsBase):
1212
"""

0 commit comments

Comments
 (0)