From 3b9322f60047e394ef1a6d2e7ce24ed9786adae9 Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 12 Jul 2024 11:07:23 +0530 Subject: [PATCH 1/4] feat: add floating client metadata --- cryptlex/lexfloatclient/lexfloatclient.py | 22 +++++++++++++++++++ .../lexfloatclient/lexfloatclient_native.py | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index 13f2e2c..7a60bc8 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -267,6 +267,28 @@ def GetFloatingClientMeterAttributeUses(name): else: raise LexFloatClientException(status) + @staticmethod + def GetFloatingClientMetadata(key): + """Gets the value of the floating client metadata. + + Args: + key (str): metadata key to retrieve the value + + Raises: + LexFloatClientException + + Returns: + str: value of metadata for the key + """ + cstring_key = LexFloatClientNative.get_ctype_string(key) + buffer_size = 256 + buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size) + status = LexFloatClientNative.GetFloatingClientMetadata( + cstring_key, buffer, buffer_size) + if status != LexFloatStatusCodes.LF_OK: + raise LexFloatClientException(status) + return LexFloatClientNative.byte_to_string(buffer.value) + @staticmethod def RequestFloatingLicense(): """Sends the request to lease the license from the LexFloatServer. diff --git a/cryptlex/lexfloatclient/lexfloatclient_native.py b/cryptlex/lexfloatclient/lexfloatclient_native.py index e116d62..5523197 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_native.py +++ b/cryptlex/lexfloatclient/lexfloatclient_native.py @@ -159,6 +159,11 @@ def byte_to_string(input): GetFloatingClientMeterAttributeUses.argtypes = [CSTRTYPE, POINTER(c_uint32)] GetFloatingClientMeterAttributeUses.restype = c_int +GetFloatingClientMetadata = library.GetFloatingClientMetadata +GetFloatingClientMetadata.argtypes = [CSTRTYPE, STRTYPE, c_uint32] +GetFloatingClientMetadata.restype = c_int + + RequestFloatingLicense = library.RequestFloatingLicense RequestFloatingLicense.argtypes = [] RequestFloatingLicense.restype = c_int From ae91277bce2df8ddf749997dc9c293ea3847dbaa Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 13:46:38 +0530 Subject: [PATCH 2/4] refactor: jsdoc --- cryptlex/lexfloatclient/lexfloatclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index 7a60bc8..32677f5 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -278,7 +278,7 @@ def GetFloatingClientMetadata(key): LexFloatClientException Returns: - str: value of metadata for the key + str: value of the floating client metadata """ cstring_key = LexFloatClientNative.get_ctype_string(key) buffer_size = 256 From 4c7b0f4b19cc9815ac17d3e3236f6eac953697ab Mon Sep 17 00:00:00 2001 From: muneebkq Date: Fri, 2 Aug 2024 13:47:27 +0530 Subject: [PATCH 3/4] refactor: remove extra line --- cryptlex/lexfloatclient/lexfloatclient_native.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cryptlex/lexfloatclient/lexfloatclient_native.py b/cryptlex/lexfloatclient/lexfloatclient_native.py index 5523197..53a025d 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_native.py +++ b/cryptlex/lexfloatclient/lexfloatclient_native.py @@ -163,7 +163,6 @@ def byte_to_string(input): GetFloatingClientMetadata.argtypes = [CSTRTYPE, STRTYPE, c_uint32] GetFloatingClientMetadata.restype = c_int - RequestFloatingLicense = library.RequestFloatingLicense RequestFloatingLicense.argtypes = [] RequestFloatingLicense.restype = c_int From 60a6b139d9ba4a07d68d92a8c63d11119749c76c Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 6 Aug 2024 16:00:48 +0530 Subject: [PATCH 4/4] fix: buffer size ->4096 --- cryptlex/lexfloatclient/lexfloatclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index 32677f5..292316d 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -281,7 +281,7 @@ def GetFloatingClientMetadata(key): str: value of the floating client metadata """ cstring_key = LexFloatClientNative.get_ctype_string(key) - buffer_size = 256 + buffer_size = 4096 buffer = LexFloatClientNative.get_ctype_string_buffer(buffer_size) status = LexFloatClientNative.GetFloatingClientMetadata( cstring_key, buffer, buffer_size)