Skip to content

Commit

Permalink
Add GetWebAPILog method (#22)
Browse files Browse the repository at this point in the history
* Update methods.py

* Update setup.py
  • Loading branch information
artemlos authored Jun 7, 2020
1 parent 81c9115 commit 5374ca3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
40 changes: 40 additions & 0 deletions licensing/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,46 @@ def deactivate(token, product_id, key, machine_code, floating = False):

return (True, "")

@staticmethod
def get_web_api_log(token, product_id = 0, key = "", machine_code="", friendly_name = "",\
limit = 10, starting_after = 0, ending_before=0):

"""
This method will retrieve a list of Web API Logs. All events that get
logged are related to a change of a license key or data object, eg. when
license key gets activated or when a property of data object changes. More details
about the method that was called are specified in the State field.
More docs: https://app.cryptolens.io/docs/api/v3/GetWebAPILog
"""

response = ""

try:
response = HelperMethods.send_request("ai/getwebapilog", {"token":token,\
"ProductId":product_id,\
"Key":key,\
"MachineCode":machine_code,\
"FriendlyName":friendly_name,\
"Limit": limit,\
"StartingAfter": starting_after,\
"EndingBefore": ending_before})
except HTTPError as e:
response = Response.from_string(e.read())
except URLError as e:
return (None, "Could not contact the server. Error message: " + str(e))
except Exception:
return (None, "Could not contact the server.")

jobj = json.loads(response)

if jobj == None or not("result" in jobj) or jobj["result"] == 1:
if jobj != None:
return (False, jobj["message"])
else:
return (False, "Could not contact the server.")

return (jobj["logs"], "")


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

0 comments on commit 5374ca3

Please sign in to comment.