Skip to content

Commit 5374ca3

Browse files
authored
Add GetWebAPILog method (#22)
* Update methods.py * Update setup.py
1 parent 81c9115 commit 5374ca3

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

licensing/methods.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,46 @@ def deactivate(token, product_id, key, machine_code, floating = False):
178178

179179
return (True, "")
180180

181+
@staticmethod
182+
def get_web_api_log(token, product_id = 0, key = "", machine_code="", friendly_name = "",\
183+
limit = 10, starting_after = 0, ending_before=0):
184+
185+
"""
186+
This method will retrieve a list of Web API Logs. All events that get
187+
logged are related to a change of a license key or data object, eg. when
188+
license key gets activated or when a property of data object changes. More details
189+
about the method that was called are specified in the State field.
190+
191+
More docs: https://app.cryptolens.io/docs/api/v3/GetWebAPILog
192+
"""
193+
194+
response = ""
195+
196+
try:
197+
response = HelperMethods.send_request("ai/getwebapilog", {"token":token,\
198+
"ProductId":product_id,\
199+
"Key":key,\
200+
"MachineCode":machine_code,\
201+
"FriendlyName":friendly_name,\
202+
"Limit": limit,\
203+
"StartingAfter": starting_after,\
204+
"EndingBefore": ending_before})
205+
except HTTPError as e:
206+
response = Response.from_string(e.read())
207+
except URLError as e:
208+
return (None, "Could not contact the server. Error message: " + str(e))
209+
except Exception:
210+
return (None, "Could not contact the server.")
211+
212+
jobj = json.loads(response)
213+
214+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
215+
if jobj != None:
216+
return (False, jobj["message"])
217+
else:
218+
return (False, "Could not contact the server.")
219+
220+
return (jobj["logs"], "")
181221

182222

183223
class Helpers:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
setup(
33
name = 'licensing', # How you named your package folder (MyLib)
44
packages = ['licensing'], # Chose the same as "name"
5-
version = '0.18', # Start with a small number and increase it with every change you make
5+
version = '0.19', # Start with a small number and increase it with every change you make
66
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
77
description = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
88
author = 'Cryptolens AB', # Type in your name
99
author_email = '[email protected]', # Type in your E-Mail
1010
url = 'https://cryptolens.io', # Provide either the link to your github or to your website
11-
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_18.tar.gz', # I explain this later on
11+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_19.tar.gz', # I explain this later on
1212
keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
1313
classifiers=[
1414
#'Development Status :: 5 - Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package

0 commit comments

Comments
 (0)