Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add GetFloatingClientMetadata method #10

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 the floating client metadata
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muneebkq Update the docs, it does not return the value of metadata for the key, instead it simply returns value of the floating client metadata

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

cstring_key = LexFloatClientNative.get_ctype_string(key)
buffer_size = 4096
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.
Expand Down
4 changes: 4 additions & 0 deletions cryptlex/lexfloatclient/lexfloatclient_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muneebkq Why this extra line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

RequestFloatingLicense.argtypes = []
RequestFloatingLicense.restype = c_int
Expand Down