12
12
from chkp_harmony_endpoint_management_sdk .classes .internal import SessionOperations
13
13
from chkp_harmony_endpoint_management_sdk .core .logger import logger , error_logger
14
14
from chkp_harmony_endpoint_management_sdk .core .sdk_platform import KEEP_ALIVE_INTERVAL , KEEP_ALIVE_PERFORM_GRACE , MSSP_KEEP_ALIVE_EXPIRATION
15
- from chkp_harmony_endpoint_management_sdk .generated .cloud .api_client import ApiClient as CloudApiClient , Configuration as CloudConfiguration
15
+ from chkp_harmony_endpoint_management_sdk .generated .cloud .api_client import ApiClient as CloudApiClient , Configuration as CloudConfiguration
16
16
# from chkp_harmony_endpoint_management_sdk.generated.premise.api_client import ApiClient as PremiseApiClient , Configuration as PremiseConfiguration
17
- from chkp_harmony_endpoint_management_sdk .generated .saas .api_client import ApiClient as SAASApiClient , Configuration as SAASConfiguration
17
+ from chkp_harmony_endpoint_management_sdk .generated .saas .api_client import ApiClient as SAASApiClient , Configuration as SAASConfiguration
18
18
import uuid
19
19
from enum import Enum
20
20
from urllib .parse import urlparse
21
21
import jwt
22
22
import requests
23
23
24
+
24
25
class WorkMode (Enum ):
25
26
CLOUD = "cloud"
26
27
SAAS = "saas"
@@ -35,6 +36,7 @@ class WorkMode(Enum):
35
36
36
37
VERIFY_CONTENT = False
37
38
39
+
38
40
class SessionManager :
39
41
def __init__ (self ):
40
42
self .__session_operations : SessionOperations = None
@@ -44,7 +46,7 @@ def __init__(self):
44
46
self .__session_id : str = str (uuid .uuid4 ())
45
47
self .__work_mode : WorkMode = None
46
48
self .__url : str = ''
47
-
49
+
48
50
self .__harmony_endpoint_saas_options : harmony_endpoint_saas_options = None
49
51
"""
50
52
The CI token expiration
@@ -54,12 +56,12 @@ def __init__(self):
54
56
"""
55
57
The CI token expiration
56
58
"""
57
-
59
+
58
60
self .__next_ci_expiration : Duration = None
59
61
"""
60
62
The CI token expiration
61
63
"""
62
-
64
+
63
65
self .__next_endpoint_session_expiration : Duration = None
64
66
"""
65
67
The endpoint service token expiration
@@ -84,21 +86,21 @@ def __get_url(self) -> str:
84
86
return f'{ self .__url } { EXTERNAL_API_BASE_PATH } '
85
87
if self .__work_mode == WorkMode .SAAS :
86
88
return f'{ self .__url } { CI_APPLICATION_PATH } '
87
-
89
+
88
90
return f'{ self .__url } { CI_APPLICATION_PATH } { EXTERNAL_API_BASE_PATH } '
89
91
90
92
@property
91
93
def client (self ) -> Any :
92
94
93
95
if self .__sdk_connection_state == SDKConnectionState .DISCONNECTED :
94
- error_logger (f 'Unable to process operation call, no session configured, connect first' )
96
+ error_logger ('Unable to process operation call, no session configured, connect first' )
95
97
raise HarmonyApiException (error_scope = HarmonyErrorScope .SESSION , message = 'No session configured, connect first' )
96
98
97
- configuration = None
98
-
99
+ configuration = None
100
+
99
101
if self .__work_mode == WorkMode .CLOUD :
100
102
configuration = CloudConfiguration ()
101
- # TODO: Open when on-premise will be release to public
103
+ # TODO: Open when on-premise will be release to public
102
104
# if self.__work_mode == WorkMode.PREMISE:
103
105
# configuration = PremiseConfiguration()
104
106
if self .__work_mode == WorkMode .SAAS :
0 commit comments