thoughtspot / thoughtspot_rest_api_v1_python

Python implementations of ThoughtSpot REST APIs V1 and V2
Other
3 stars 6 forks source link

Export Method Wrong Endpoint #9

Closed onevelo closed 1 year ago

onevelo commented 1 year ago

The endpoint defined in the export method is incorrectly pointed at the import endpoint.

https://github.com/thoughtspot/thoughtspot_rest_api_v1_python/blob/3a8cc1e3dc8d171dac4324b2512c20112e8de346/src/thoughtspot_rest_api_v1/tsrestapiv2.py#L448

Also, the export metadata object requires a "type" attribute. If we opt to use the metadata_ids parameter, that "type" attribute will be left out and an error will occur due to the required attribute "type" not being defined.

onevelo commented 1 year ago

My gut says the delete will have the same issue in regards to metadata_ids based on the playground listing the "type" attribute in the metadata object as required.

Also, here's a change I made locally which works. Obviously I am not aware of any coding standards your team may have in place but I figured I would include it anyway. I removed the metadata_ids option, moved the metadata_request to the first parameter and removed the Optional piece for that request dict.:

def metadata_tml_export(self, metadata_request: List[Dict], export_associated: bool = False, export_fqn: bool = False):
    endpoint = 'metadata/tml/export'
    request = {
        'metadata': metadata_request,
        'export_associated': export_associated,
        'export_fqn': export_fqn
    }

    return self.post_request(endpoint=endpoint, request=request)
bryanthowell-ts commented 1 year ago

The export endpoint has been corrected in the 1.4.1 release that is now available.

The other issue around "type" is a discrepancy between the documentation and the behavior of the API. It has been reported to the engineering team responsible for the REST API itself, but the requirement for 'type' is not supposed to be present except when using a name not a GUID, so I'm leaving the library as is since it is the documented expected behavior