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
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
*A simple and pythonic Python implementation of ThoughtSpot's REST APIs (both V1 and V2).*
# LAST RELEASE NOTICE
The 1.8.8 release will be the last under the `thoughtspot_rest_api_v1 / thoughtspot-rest-api-v1` package name.
*A simple and pythonic Python implementation of ThoughtSpot's REST APIs (both V1 and V2.0).*
# PACKAGE RENAME NOTICE
The 2.N.N releases of `thoughtspot_rest_api` are a renamed continuation of the older `thoughtspot_rest_api_v1 / thoughtspot-rest-api-v1` packages.

The package will transition to just `thoughtspot_rest_api / thoughtspot-rest-api` to reflect that V2.0 API is the primary API for ThoughtSpot. All code will remain the same other than the package name changing.

The repository itself will switch to a public / private mirror system at this time as well, which will break existing watching / forks.
If you are using the `thoughtspot_rest_api_v1` package, please install `thoughtspot_rest_api` and update your import statements and everything should work. All new releases will be under this package name.

# README

`thoughtspot_rest_api_v1` library implements the ThoughtSpot public REST APIs as directly as possible. It is not a "full SDK" with representation of each request and response type, but rather uses Python's Lists and Dicts for input and output.
`thoughtspot_rest_api` library implements the ThoughtSpot public REST APIs as directly as possible. It is not a "full SDK" with representation of each request and response type, but rather uses Python's Lists and Dicts for input and output.

When using ThoughtSpot Cloud, always chose the V2.0 REST API via the `TSRestApiV2` class.

Expand All @@ -28,9 +26,9 @@ Method and argument names closely match to the documented API endpoints, with a
---

## Learning from the source code for V1
At this point, if you have a need to use the V1 REST API, please use the TSRestApiV1 class. If you have some need for using the V1 REST API outside of Pyython, the library can be used a reference for how a V1 REST API endpoint is called correctly, look at the `/src/thoughtspot_rest_api_v1/tsrestapiv1.py` file. It contains the definition of all the ENUMs and the `TSRestApiV1` class.
At this point, if you have a need to use the V1 REST API, please use the TSRestApiV1 class. If you have some need for using the V1 REST API outside of Pyython, the library can be used a reference for how a V1 REST API endpoint is called correctly, look at the `/src/thoughtspot_rest_api/tsrestapiv1.py` file. It contains the definition of all the ENUMs and the `TSRestApiV1` class.

Similarly, the `TSRestApiV2` class is defined in the `/src/thoughtspot_rest_api_v1/tsrestapiv2.py` file.
Similarly, the `TSRestApiV2` class is defined in the `/src/thoughtspot_rest_api/tsrestapiv2.py` file.

The `TSRestApiV1` class uses the *requests* library to create an internal requests.Session object when the REST API sign-in command is run. This fulfils the ThoughtSpot REST API V1 requirement for session cookie details to be passed in every request.

Expand All @@ -42,29 +40,29 @@ The library is designed to work with the latest version of ThoughtSpot Cloud. It

## Getting Started

To install thoughtspot_rest_api_v1, simply run this simple command in your terminal of choice:
To install thoughtspot_rest_api, simply run this simple command in your terminal of choice:

```
$ python3 -m pip install thoughtspot_rest_api_v1
$ python3 -m pip install thoughtspot_rest_api
```

### Getting the source code

```
$ git clone https://github.com/thoughtspot/thoughtspot_rest_api_v1_python.git
$ git clone https://github.com/thoughtspot/thoughtspot_rest_api_python.git
```

Once you have a copy of the source, you can embed it in your own Python package, or install it into your site-packages easily:

```
$ cd thoughtspot_rest_api_v1_python
$ cd thoughtspot_rest_api_python
$ python3 -m pip install --upgrade
```

---

## Importing the library
from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

This will bring the `TSRestApiV1` and `TSRestApiV2` classes, as well as the following enumerations: `TSTypes`, `MetadataNames`, `MetadataSorts`, `MetadataSubtypes`, `MetadataCategories`, `ShareModes`, `Privileges`.

Expand Down Expand Up @@ -94,7 +92,7 @@ REST API V2 allows for Bearer Token authentication, which is the preferred metho
Next request a Full Access token using `auth_token_full()`. Get the `token` value from the response, then set the `bearer_token` property of the TSRestApiV2 object with the token. The object will keep the bearer token and use it in the headers of any subsequent call.


from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

username = os.getenv('username') # or type in yourself
password = os.getenv('password') # or type in yourself
Expand All @@ -110,7 +108,7 @@ Next request a Full Access token using `auth_token_full()`. Get the `token` valu

If you have requested an auth token from the REST API Playground, you can simply set the `bearer_token` property directly

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

full_auth_token = '{token_from_playground}'

Expand Down
2 changes: 1 addition & 1 deletion examples/audit_object_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests.exceptions
import csv

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

# You are probably better of looking at https://github.com/thoughtspot/cs_tools for more complete versions of this
# functionality, but this shows how to use the REST APIs directly to put together various information in ways
Expand Down
2 changes: 1 addition & 1 deletion examples/create_or_update_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Short script to show how to use the connection_create and connection_update commands
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import requests

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

# Script to show using the /admin/ endpoints around Custom Actions
# Specific use-case shown is making an Action available on Context Menu of every viz on a Liveboard
Expand Down
2 changes: 1 addition & 1 deletion examples/data_exports.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


username = os.getenv('username') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples/delete_object.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

# This script uses the internal metadata/delete API endpoint, which will be unnecessary once the V2 API introduces
# a public form of delete. But it may be of use now
Expand Down
2 changes: 1 addition & 1 deletion examples/import_tables_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


#
Expand Down
2 changes: 1 addition & 1 deletion examples/liveboard_pdf_export.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


username = os.getenv('username') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples/objects_info_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


# Details about objects within ThoughtSpot all are accessed through 'metadata/' endpoints, which can be used
Expand Down
2 changes: 1 addition & 1 deletion examples/share_objects_access_control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


# You are probably better off looking at https://github.com/thoughtspot/cs_tools for more complete versions of this
Expand Down
2 changes: 1 addition & 1 deletion examples/tag_objects.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

# This script uses the internal metadata/delete API endpoint, which will be unnecessary once the V2 API introduces
# a public form of delete. But it may be of use now
Expand Down
2 changes: 1 addition & 1 deletion examples/transfer_object_ownership.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import requests.exceptions
from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# This script is an example of a workflow useful in a Git-based SDLC process
Expand Down
4 changes: 2 additions & 2 deletions examples/trusted_authentication_with_authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from dotenv import load_dotenv
load_dotenv()

#from thoughtspot_rest_api_v1 import *
from src.thoughtspot_rest_api_v1.tsrestapiv1 import *
#from thoughtspot_rest_api import *
from src.thoughtspot_rest_api.tsrestapiv1 import *

#
# Simple JSON format for defining user details including groups. You will need to determine how to get these details
Expand Down
4 changes: 2 additions & 2 deletions examples/users_groups_create_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# from dotenv import load_dotenv
# load_dotenv()

from thoughtspot_rest_api_v1 import *
#from src.thoughtspot_rest_api_v1.tsrestapiv1 import *
from thoughtspot_rest_api import *
#from src.thoughtspot_rest_api.tsrestapiv1 import *

thoughtspot_server = os.getenv('server') # or type in yourself
service_acct_username = os.getenv('username') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/abac_token_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Script for implementing the upcoming ABAC / JWT capabilities of the V2.0 Full Access Token REST API
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/add_timeout_to_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import requests.exceptions
import functools

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


# Details about objects within ThoughtSpot all are accessed through 'metadata/' endpoints, which can be used
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/create_connection_on_orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Example of creating a Connection on each Org in the dev->test->pre_prod->prod_per_customer deployment model
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/create_groups_for_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

from examples.share_objects_access_control import read_only_guids
from src.thoughtspot_rest_api_v1 import *
from src.thoughtspot_rest_api import *

#
# Script showing creating Groups on the fly for auth purposes and assigning
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/create_orgs_with_linked_git_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Example of creating the setups of Orgs linked to Git branches in GitHub for dev->test->pre_prod->prod_per_customer
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/data_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


username = os.getenv('username') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/git_deploy_commits_to_prod_single_tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import json

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Example of deploying from a pre_prod or release branch out to individual customer "prod Orgs"
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/objects_info_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


# Details about objects within ThoughtSpot all are accessed through 'metadata/' endpoints, which can be used
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/org_migration_data_content.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Example order of actions to "move" data and content objects
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/org_migration_users_groups.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Example order of actions to "move" users and groups from primary (org_id=0) to
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/publish_tml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from src.thoughtspot_rest_api_v1 import *
from src.thoughtspot_rest_api import *

username = os.getenv('username') # or type in yourself
password = os.getenv('password') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/report_exports.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


username = os.getenv('username') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/set_obj_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import re
from collections import Counter

from src.thoughtspot_rest_api_v1 import TSRestApiV2, TSTypesV2, ReportTypes, TSRestApiV1
from src.thoughtspot_rest_api import TSRestApiV2, TSTypesV2, ReportTypes, TSRestApiV1

username = os.getenv('username') # or type in yourself
password = os.getenv('password') # or type in yourself
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/share_objects_access_control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

# You are probably better off looking at https://github.com/thoughtspot/cs_tools for more complete versions of this
# functionality, but this shows how to use the REST APIs directly to put together various information in ways
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/spotter_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from requests.exceptions import HTTPError
import tomllib

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# Basic pattern for using Spotter / AI REST APIs:
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/tag_objects.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests.exceptions

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

# This script uses the internal metadata/delete API endpoint, which will be unnecessary once the V2 API introduces
# a public form of delete. But it may be of use now
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/transfer_object_ownership.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import requests.exceptions
from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *

#
# This script is an example of a workflow useful in a Git-based SDLC process
Expand Down
2 changes: 1 addition & 1 deletion examples_v2/users_groups_orgs_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests.exceptions
import csv

from thoughtspot_rest_api_v1 import *
from thoughtspot_rest_api import *


# Example functions for reporting of various counts of objects
Expand Down
12 changes: 6 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[metadata]
name = thoughtspot_rest_api_v1
version = 1.8.8
description = Library implementing the ThoughtSpot V1 REST API
name = thoughtspot_rest_api
version = 2.0.1
description = Library implementing ThoughtSpot REST API V2.0 and V1
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/thoughtspot/thoughtspot_rest_api_v1_python
url = https://github.com/thoughtspot/thoughtspot_rest_api
author = Bryant Howell
author_email = bryant.howell@thoughtspot.com
license = MIT
Expand All @@ -15,8 +15,8 @@ classifiers =
Operating System :: OS Independent

project_urls =
Documentation = https://github.com/thoughtspot/thoughtspot_rest_api_v1_python#readme
Bug Tracker = https://github.com/thoughtspot/thoughtspot_rest_api_v1_python/issues
Documentation = https://github.com/thoughtspot/thoughtspot_rest_api#readme
Bug Tracker = https://github.com/thoughtspot/thoughtspot_rest_api/issues


[options]
Expand Down
1 change: 1 addition & 0 deletions src/thoughtspot_rest_api/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '2.0.1'
1 change: 0 additions & 1 deletion src/thoughtspot_rest_api_v1/_version.py

This file was deleted.

Loading