[ksql] Do not hardcode connector id in metadata API
@@ -20,6 +20,7 @@ import json
import logging
import sys
+from desktop.api_public import _get_interpreter_from_dialect
from desktop.lib.django_util import JsonResponse
from desktop.lib.i18n import force_unicode
from metadata.manager_client import ManagerApi
@@ -111,15 +112,21 @@ def get_topics(user):
'database': 'topics'
}
+ interpreter = _get_interpreter_from_dialect('ksql', user)
+ api = _get_notebook_api(user, connector_id=interpreter['type'])
+
return [
topic['name']
- for topic in _get_notebook_api(user, connector_id=56).autocomplete(**data)['tables_meta']
+ for topic in api.autocomplete(**data)['tables_meta']
if not topic['name'].startswith('__')
]
def get_topic_data(user, name):
- data = _get_notebook_api(user, connector_id=56).get_sample_data(snippet={})
+ interpreter = _get_interpreter_from_dialect('ksql', user)
+ api = _get_notebook_api(user, connector_id=interpreter['type'])
+
+ data = api.get_sample_data(snippet={})
print(data)
return data
