diff --git a/README.md b/README.md index 64066ec..c823758 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. @@ -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`. @@ -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 @@ -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}' diff --git a/examples/audit_object_access.py b/examples/audit_object_access.py index d19ae26..83fc101 100644 --- a/examples/audit_object_access.py +++ b/examples/audit_object_access.py @@ -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 diff --git a/examples/create_or_update_connection.py b/examples/create_or_update_connection.py index 0fc7569..ab64e9e 100644 --- a/examples/create_or_update_connection.py +++ b/examples/create_or_update_connection.py @@ -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 diff --git a/examples/custom_actions.py b/examples/custom_actions.py index 76d677e..757d4ec 100644 --- a/examples/custom_actions.py +++ b/examples/custom_actions.py @@ -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 diff --git a/examples/data_exports.py b/examples/data_exports.py index beb5f7c..7547a98 100644 --- a/examples/data_exports.py +++ b/examples/data_exports.py @@ -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 diff --git a/examples/delete_object.py b/examples/delete_object.py index c6edb24..4cab0ff 100644 --- a/examples/delete_object.py +++ b/examples/delete_object.py @@ -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 diff --git a/examples/import_tables_rest_api.py b/examples/import_tables_rest_api.py index b4b4601..13bb462 100644 --- a/examples/import_tables_rest_api.py +++ b/examples/import_tables_rest_api.py @@ -2,7 +2,7 @@ import requests.exceptions import json -from thoughtspot_rest_api_v1 import * +from thoughtspot_rest_api import * # diff --git a/examples/liveboard_pdf_export.py b/examples/liveboard_pdf_export.py index a1d7189..6333f8f 100644 --- a/examples/liveboard_pdf_export.py +++ b/examples/liveboard_pdf_export.py @@ -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 diff --git a/examples/objects_info_metadata.py b/examples/objects_info_metadata.py index 4ea7412..97b17eb 100644 --- a/examples/objects_info_metadata.py +++ b/examples/objects_info_metadata.py @@ -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 diff --git a/examples/share_objects_access_control.py b/examples/share_objects_access_control.py index e7c2b2b..669015f 100644 --- a/examples/share_objects_access_control.py +++ b/examples/share_objects_access_control.py @@ -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 diff --git a/examples/tag_objects.py b/examples/tag_objects.py index c686c15..8f3c4e2 100644 --- a/examples/tag_objects.py +++ b/examples/tag_objects.py @@ -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 diff --git a/examples/transfer_object_ownership.py b/examples/transfer_object_ownership.py index edd2191..6814208 100644 --- a/examples/transfer_object_ownership.py +++ b/examples/transfer_object_ownership.py @@ -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 diff --git a/examples/trusted_authentication_with_authorization.py b/examples/trusted_authentication_with_authorization.py index f523d8b..b32649e 100644 --- a/examples/trusted_authentication_with_authorization.py +++ b/examples/trusted_authentication_with_authorization.py @@ -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 diff --git a/examples/users_groups_create_update.py b/examples/users_groups_create_update.py index dca052a..e17c16c 100644 --- a/examples/users_groups_create_update.py +++ b/examples/users_groups_create_update.py @@ -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 diff --git a/examples_v2/abac_token_parameters.py b/examples_v2/abac_token_parameters.py index 6942397..5bbac92 100644 --- a/examples_v2/abac_token_parameters.py +++ b/examples_v2/abac_token_parameters.py @@ -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 diff --git a/examples_v2/add_timeout_to_requests.py b/examples_v2/add_timeout_to_requests.py index 5c84119..5a0eae4 100644 --- a/examples_v2/add_timeout_to_requests.py +++ b/examples_v2/add_timeout_to_requests.py @@ -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 diff --git a/examples_v2/create_connection_on_orgs.py b/examples_v2/create_connection_on_orgs.py index 77d49f8..53ef3dd 100644 --- a/examples_v2/create_connection_on_orgs.py +++ b/examples_v2/create_connection_on_orgs.py @@ -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 diff --git a/examples_v2/create_groups_for_auth.py b/examples_v2/create_groups_for_auth.py index d776bf2..23a453a 100644 --- a/examples_v2/create_groups_for_auth.py +++ b/examples_v2/create_groups_for_auth.py @@ -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 diff --git a/examples_v2/create_orgs_with_linked_git_branch.py b/examples_v2/create_orgs_with_linked_git_branch.py index 99bf73f..00f29b2 100644 --- a/examples_v2/create_orgs_with_linked_git_branch.py +++ b/examples_v2/create_orgs_with_linked_git_branch.py @@ -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 diff --git a/examples_v2/data_exports.py b/examples_v2/data_exports.py index 2abeee8..e61f35a 100644 --- a/examples_v2/data_exports.py +++ b/examples_v2/data_exports.py @@ -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 diff --git a/examples_v2/git_deploy_commits_to_prod_single_tenants.py b/examples_v2/git_deploy_commits_to_prod_single_tenants.py index e3ab022..23630da 100644 --- a/examples_v2/git_deploy_commits_to_prod_single_tenants.py +++ b/examples_v2/git_deploy_commits_to_prod_single_tenants.py @@ -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" diff --git a/examples_v2/objects_info_metadata.py b/examples_v2/objects_info_metadata.py index 5b08410..cf46469 100644 --- a/examples_v2/objects_info_metadata.py +++ b/examples_v2/objects_info_metadata.py @@ -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 diff --git a/examples_v2/org_migration_data_content.py b/examples_v2/org_migration_data_content.py index c30e60f..d73b94b 100644 --- a/examples_v2/org_migration_data_content.py +++ b/examples_v2/org_migration_data_content.py @@ -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 diff --git a/examples_v2/org_migration_users_groups.py b/examples_v2/org_migration_users_groups.py index 9149ba0..3de0741 100644 --- a/examples_v2/org_migration_users_groups.py +++ b/examples_v2/org_migration_users_groups.py @@ -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 diff --git a/examples_v2/publish_tml.py b/examples_v2/publish_tml.py index eeeea1e..f73007f 100644 --- a/examples_v2/publish_tml.py +++ b/examples_v2/publish_tml.py @@ -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 diff --git a/examples_v2/report_exports.py b/examples_v2/report_exports.py index a207e41..67f029d 100644 --- a/examples_v2/report_exports.py +++ b/examples_v2/report_exports.py @@ -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 diff --git a/examples_v2/set_obj_id.py b/examples_v2/set_obj_id.py index 5afaf8b..432a588 100644 --- a/examples_v2/set_obj_id.py +++ b/examples_v2/set_obj_id.py @@ -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 diff --git a/examples_v2/share_objects_access_control.py b/examples_v2/share_objects_access_control.py index ade3e08..aa40c50 100644 --- a/examples_v2/share_objects_access_control.py +++ b/examples_v2/share_objects_access_control.py @@ -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 diff --git a/examples_v2/spotter_apis.py b/examples_v2/spotter_apis.py index f39ee74..b3befb6 100644 --- a/examples_v2/spotter_apis.py +++ b/examples_v2/spotter_apis.py @@ -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: diff --git a/examples_v2/tag_objects.py b/examples_v2/tag_objects.py index 63e17cf..c9106e0 100644 --- a/examples_v2/tag_objects.py +++ b/examples_v2/tag_objects.py @@ -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 diff --git a/examples_v2/transfer_object_ownership.py b/examples_v2/transfer_object_ownership.py index 81361c9..61c866a 100644 --- a/examples_v2/transfer_object_ownership.py +++ b/examples_v2/transfer_object_ownership.py @@ -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 diff --git a/examples_v2/users_groups_orgs_reporting.py b/examples_v2/users_groups_orgs_reporting.py index 9516e26..0d24e97 100644 --- a/examples_v2/users_groups_orgs_reporting.py +++ b/examples_v2/users_groups_orgs_reporting.py @@ -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 diff --git a/setup.cfg b/setup.cfg index cd9fb6f..9db6ea2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 @@ -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] diff --git a/src/thoughtspot_rest_api_v1/__init__.py b/src/thoughtspot_rest_api/__init__.py similarity index 100% rename from src/thoughtspot_rest_api_v1/__init__.py rename to src/thoughtspot_rest_api/__init__.py diff --git a/src/thoughtspot_rest_api/_version.py b/src/thoughtspot_rest_api/_version.py new file mode 100644 index 0000000..3f39079 --- /dev/null +++ b/src/thoughtspot_rest_api/_version.py @@ -0,0 +1 @@ +__version__ = '2.0.1' diff --git a/src/thoughtspot_rest_api_v1/details_objects.py b/src/thoughtspot_rest_api/details_objects.py similarity index 100% rename from src/thoughtspot_rest_api_v1/details_objects.py rename to src/thoughtspot_rest_api/details_objects.py diff --git a/src/thoughtspot_rest_api_v1/tsrestapiv1.py b/src/thoughtspot_rest_api/tsrestapiv1.py similarity index 100% rename from src/thoughtspot_rest_api_v1/tsrestapiv1.py rename to src/thoughtspot_rest_api/tsrestapiv1.py diff --git a/src/thoughtspot_rest_api_v1/tsrestapiv2.py b/src/thoughtspot_rest_api/tsrestapiv2.py similarity index 100% rename from src/thoughtspot_rest_api_v1/tsrestapiv2.py rename to src/thoughtspot_rest_api/tsrestapiv2.py diff --git a/src/thoughtspot_rest_api_v1/_version.py b/src/thoughtspot_rest_api_v1/_version.py deleted file mode 100644 index 3eabb0b..0000000 --- a/src/thoughtspot_rest_api_v1/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '1.8.8'