diff --git a/setup.cfg b/setup.cfg index 328981d..52f0350 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = thoughtspot_rest_api_v1 -version = 1.6.1 +version = 1.7.0 description = Library implementing the ThoughtSpot V1 REST API long_description = file: README.md long_description_content_type = text/markdown diff --git a/src/thoughtspot_rest_api_v1/_version.py b/src/thoughtspot_rest_api_v1/_version.py index bb64aa4..0e1a38d 100644 --- a/src/thoughtspot_rest_api_v1/_version.py +++ b/src/thoughtspot_rest_api_v1/_version.py @@ -1 +1 @@ -__version__ = '1.6.1' +__version__ = '1.7.0' diff --git a/src/thoughtspot_rest_api_v1/tsrestapiv1.py b/src/thoughtspot_rest_api_v1/tsrestapiv1.py index 5d9af20..96392f5 100644 --- a/src/thoughtspot_rest_api_v1/tsrestapiv1.py +++ b/src/thoughtspot_rest_api_v1/tsrestapiv1.py @@ -1073,6 +1073,8 @@ def metadata_tml_export_string_with_associations_map(self, guid: str, formattype return response_str, name_guid_map # TML import is distinguished by having an {'Accept': 'text/plain'} header on the POST + # 'JSON' default actually takes a Python object representing JSON output + # Use 'YAML' or 'JSON_STR' as formattype if you have already stringified the input (read from disk etc.) def metadata_tml_import( self, tml: Union[Dict, List[Dict]], @@ -1090,14 +1092,20 @@ def metadata_tml_import( tml_list = [tml] else: tml_list = tml + encoded_tmls = [] + # Assume JSON is Python object if formattype == 'JSON': - json_encoded_tml = json.dumps(tml_list) - elif formattype == 'YAML': - json_encoded_tml = json.dumps(tml_list) + for t in tml_list: + encoded_tmls.append(json.dumps(t)) + # YAML or JSON_STR are already string when sent in + elif formattype in ['YAML', 'JSON_STR']: + for t in tml_list: + encoded_tmls.append(t) # Assume it's just a Python object which will dump to JSON matching the TML format else: - json_encoded_tml = json.dumps(tml_list) + for t in tml_list: + encoded_tmls.append(json.dumps(t)) import_policy = 'ALL_OR_NONE' @@ -1105,7 +1113,7 @@ def metadata_tml_import( import_policy = 'VALIDATE_ONLY' post_data = { - 'import_objects': json_encoded_tml, + 'import_objects': str(encoded_tmls), 'import_policy': import_policy, 'force_create': str(create_new_on_server).lower() }