11import ctypes
2+ import json
23from cryptlex .lexfloatclient import lexfloatclient_native as LexFloatClientNative
34from cryptlex .lexfloatclient .lexfloatstatus_codes import LexFloatStatusCodes
45from cryptlex .lexfloatclient .lexfloatclient_exception import LexFloatClientException
@@ -22,6 +23,11 @@ def __init__(self, name, enabled, data):
2223 self .enabled = enabled
2324 self .data = data
2425
26+ class HostConfig (object ):
27+ def __init__ (self , max_offline_lease_duration ):
28+ self .max_offline_lease_duration = max_offline_lease_duration
29+
30+
2531class LexFloatClient :
2632 @staticmethod
2733 def SetHostProductId (product_id ):
@@ -120,7 +126,30 @@ def GetFloatingClientLibraryVersion():
120126 status = LexFloatClientNative .GetFloatingClientLibraryVersion (buffer ,buffer_size )
121127 if status != LexFloatStatusCodes .LF_OK :
122128 raise LexFloatClientException (status )
123- return LexFloatClientNative .byte_to_string (buffer .value )
129+ return LexFloatClientNative .byte_to_string (buffer .value )
130+
131+ @staticmethod
132+ def GetHostConfig ():
133+ """This function sends a network request to LexFloatServer to get the configuration details.
134+
135+ Raises:
136+ LexFloatClientException
137+
138+ Returns:
139+ HostConfig: host configuration.
140+ """
141+ buffer_size = 1024
142+ buffer = LexFloatClientNative .get_ctype_string_buffer (buffer_size )
143+ status = LexFloatClientNative .GetHostConfig (buffer , buffer_size )
144+ if status == LexFloatStatusCodes .LF_OK :
145+ host_config_json = LexFloatClientNative .byte_to_string (buffer .value )
146+ if not host_config_json .strip ():
147+ return None
148+ else :
149+ host_config = json .loads (host_config_json )
150+ return HostConfig (host_config ["maxOfflineLeaseDuration" ])
151+ else :
152+ raise LexFloatClientException (status )
124153
125154 @staticmethod
126155 def GetHostProductVersionName ():
0 commit comments