From 72a6abcdb8080742ab6025139acae33a861b52b2 Mon Sep 17 00:00:00 2001 From: Amardeep Kahali <147133239+amardeep-kahali-ts@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:58:10 +0530 Subject: [PATCH] Update cookies on successful login and add session/isactive api --- src/thoughtspot_rest_api_v1/tsrestapiv1.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/thoughtspot_rest_api_v1/tsrestapiv1.py b/src/thoughtspot_rest_api_v1/tsrestapiv1.py index 09ccf3e..3e5a425 100644 --- a/src/thoughtspot_rest_api_v1/tsrestapiv1.py +++ b/src/thoughtspot_rest_api_v1/tsrestapiv1.py @@ -11,9 +11,10 @@ # We have chosen to make it as simple to understand as possible. There are comments # and notes written throughout to help the reader understand more. # +import json from collections import OrderedDict from typing import Optional, Dict, List, Union -import json +from copy import copy import requests @@ -1286,6 +1287,18 @@ def security_effectivepermissionbulk(self, ids_by_type: Dict, dependent_share: b # SESSION Methods # + def session_isactive(self): + """ + Check if the login session is active + Returns: + bool: True/False + """ + url = f"{self.non_public_base_url}session/isactive" + headers = copy(self.requests_session.headers) + headers.update({"Accept": "*/*"}) + response = self.requests_session.get(url, headers=headers) + return response.ok + # Home Pinboard Methods def session_homepinboard_post(self, pinboard_guid: str, user_guid: str): endpoint = 'session/homepinboard'