Skip to content

Commit 99e7367

Browse files
committed
Add unblock key method
1 parent a58c403 commit 99e7367

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

licensing/methods.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,44 @@ def extend_license(token, product_id, key, no_of_days):
285285
return (True, jobj["message"])
286286

287287
@staticmethod
288+
def unblock_key(token, product_id, key):
289+
"""
290+
This method will unblock a specific license key to ensure that it can
291+
be accessed by the Key.Activate method.
292+
To do the reverse, you can use the BlockKey method.
293+
294+
More docs: https://app.cryptolens.io/docs/api/v3/UnblockKey
295+
"""
296+
297+
response = ""
298+
299+
try:
300+
response = HelperMethods.send_request("/key/UnblockKey", {"token":token,\
301+
"ProductId":product_id,\
302+
"Key" : key})
303+
except HTTPError as e:
304+
response = e.read()
305+
except URLError as e:
306+
return (None, "Could not contact the server. Error message: " + str(e))
307+
except Exception:
308+
return (None, "Could not contact the server.")
309+
310+
jobj = json.loads(response)
311+
312+
if jobj == None or not("result" in jobj) or jobj["result"] == 1:
313+
if jobj != None:
314+
return (False, jobj["message"])
315+
else:
316+
return (False, "Could not contact the server.")
317+
318+
return (True, jobj["message"])
319+
288320
def block_key(token, product_id, key):
289321
"""
290-
This method will block a specific license key to ensure that the key
291-
cannot be accessible by most of the methods in the Web API
292-
(activation, validation, optional field, and deactivation). Note,
293-
blocking the key will still allow you to access the key in Web API 3,
294-
unless otherwise stated for a given Web API 3 method.
295-
To do the reverse, please see Unblock Key.
322+
This method will block a specific license key to ensure that it will
323+
no longer be possible to activate it. Note, it will still be possible
324+
to access the license key using the GetKey method.
325+
To do the reverse, you can use the Unblock Key method.
296326
297327
More docs: https://app.cryptolens.io/docs/api/v3/BlockKey
298328
"""

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.28', # Start with a small number and increase it with every change you make
5+
version = '0.29', # 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_28.tar.gz', # I explain this later on
11+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_29.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)