77r"""`lls` exposes an API to allow modifications to Local License Server parameters in
88the Kepware Administration through the Kepware Configuration API
99"""
10+ from .. import connection
1011from typing import Union
1112from ..error import KepHTTPError , KepError
13+ import inspect
1214
1315
1416LLS_ROOT = '/admin'
17+ FORCE_CHECK_URL = '/project/services/ForceLicenseCheck'
1518LICENSING_SERVER_PORT = "libadminsettings.LICENSING_SERVER_PORT"
1619LICENSING_SERVER_NAME = "libadminsettings.LICENSING_SERVER_NAME"
1720LICENSING_SERVER_ENABLE = "libadminsettings.LICENSING_SERVER_ENABLE"
@@ -59,7 +62,7 @@ def _get_dict(self):
5962 def __str__ (self ) -> str :
6063 return "{}" .format (self ._get_dict ())
6164
62- def get_lls_config (server ) -> lls_config :
65+ def get_lls_config (server : connection . server ) -> lls_config :
6366 '''Returns the properties of the Local License server properties. Returned object is lls_config class object.
6467
6568 INPUTS:
@@ -76,7 +79,7 @@ def get_lls_config(server) -> lls_config:
7679 r = server ._config_get (server .url + LLS_ROOT )
7780 return lls_config (r .payload )
7881
79- def update_lls_config (server , config : lls_config ) -> bool :
82+ def update_lls_config (server : connection . server , config : lls_config ) -> bool :
8083 '''Updates the Local License Server admin properties for Kepware.
8184
8285 INPUTS:
@@ -96,7 +99,7 @@ def update_lls_config(server, config: lls_config) -> bool:
9699 if r .code == 200 : return True
97100 else : raise KepHTTPError (r .url , r .code , r .msg , r .hdrs , r .payload )
98101
99- def enable_lls (server ) -> bool :
102+ def enable_lls (server : connection . server ) -> bool :
100103 '''Enables the Local License Server connection for Kepware.
101104
102105 INPUTS:
@@ -114,7 +117,7 @@ def enable_lls(server) -> bool:
114117 if r .code == 200 : return True
115118 else : raise KepHTTPError (r .url , r .code , r .msg , r .hdrs , r .payload )
116119
117- def disable_lls (server ) -> bool :
120+ def disable_lls (server : connection . server ) -> bool :
118121 '''Disables the Local License Server connection for Kepware.
119122
120123 INPUTS:
@@ -131,3 +134,25 @@ def disable_lls(server) -> bool:
131134 r = server ._config_update (server .url + LLS_ROOT , {LICENSING_SERVER_ENABLE : False })
132135 if r .code == 200 : return True
133136 else : raise KepHTTPError (r .url , r .code , r .msg , r .hdrs , r .payload )
137+
138+ def force_license_check (server : connection .server , job_ttl : int = None ):
139+ '''Executes a ForceLicenseCheck call to the Kepware instance. This triggers the server to verify the
140+ license state of the license received from the Local License Server.
141+
142+ INPUTS:
143+ "server" - instance of the "server" class
144+
145+ "job_ttl" (optional) - Determines the number of seconds a job instance will exist following completion.
146+
147+ RETURNS:
148+ KepServiceResponse instance with job information
149+
150+ EXCEPTIONS (If not HTTP 200 or 429 returned):
151+
152+ KepHTTPError - If urllib provides an HTTPError
153+ KepURLError - If urllib provides an URLError
154+ '''
155+
156+ url = f'{ server .url } { FORCE_CHECK_URL } '
157+ job = server ._kep_service_execute (url , None , job_ttl )
158+ return job
0 commit comments