Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/thoughtspot_rest_api_v1/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.1'
__version__ = '1.7.0'
18 changes: 13 additions & 5 deletions src/thoughtspot_rest_api_v1/tsrestapiv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand All @@ -1090,22 +1092,28 @@ 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'

if validate_only is True:
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()
}
Expand Down