licensing 0.55__tar.gz → 0.56__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {licensing-0.55/licensing.egg-info → licensing-0.56}/PKG-INFO +2 -2
- {licensing-0.55 → licensing-0.56}/README.md +5 -0
- {licensing-0.55 → licensing-0.56}/licensing/methods.py +35 -12
- {licensing-0.55 → licensing-0.56/licensing.egg-info}/PKG-INFO +2 -2
- {licensing-0.55 → licensing-0.56}/setup.py +2 -2
- {licensing-0.55 → licensing-0.56}/tests/test_ai_usage_analytics.py +48 -0
- {licensing-0.55 → licensing-0.56}/LICENSE.txt +0 -0
- {licensing-0.55 → licensing-0.56}/LicenseFile.skm +0 -0
- {licensing-0.55 → licensing-0.56}/licensing/__init__.py +0 -0
- {licensing-0.55 → licensing-0.56}/licensing/internal.py +0 -0
- {licensing-0.55 → licensing-0.56}/licensing/models.py +0 -0
- {licensing-0.55 → licensing-0.56}/licensing.egg-info/SOURCES.txt +0 -0
- {licensing-0.55 → licensing-0.56}/licensing.egg-info/dependency_links.txt +0 -0
- {licensing-0.55 → licensing-0.56}/licensing.egg-info/top_level.txt +0 -0
- {licensing-0.55 → licensing-0.56}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: licensing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.56
|
|
4
4
|
Home-page: https://devolens.com
|
|
5
|
-
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/
|
|
5
|
+
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_56.tar.gz
|
|
6
6
|
Author: Cryptolens AB
|
|
7
7
|
Author-email: help@devolens.com
|
|
8
8
|
License: MIT
|
|
@@ -230,6 +230,11 @@ Available usage analytics methods:
|
|
|
230
230
|
* `AI.get_key_devices`
|
|
231
231
|
* `AI.get_license_activity_buckets`
|
|
232
232
|
|
|
233
|
+
The following license reports return `(report, message)`, with the license rows and pagination details in the `report` dictionary.
|
|
234
|
+
|
|
235
|
+
* `AI.get_floating_capacity_licenses(token, product_id, interval_start_utc, min_utilization_percent=90)` finds licenses using at least 90% of their floating seats. Supply the start of a 30-minute UTC interval in Unix seconds. Omit `capacity_mode` to include licenses below, at, and above their seat limit.
|
|
236
|
+
* `AI.get_expiring_licenses(token, window="90d", last_seen_days=30)` finds licenses expiring in the next 90 days whose last recorded API activity was more than 30 days ago. Follow `report["pageActivity"]["nextPage"]` until it is `None`, even if a page has no matches.
|
|
237
|
+
|
|
233
238
|
### License server or custom endpoint
|
|
234
239
|
|
|
235
240
|
To forward requests to a local license server or a different API, you can set it using the `server_address` in HelperMethods, i.e.,
|
|
@@ -794,18 +794,23 @@ class AI:
|
|
|
794
794
|
|
|
795
795
|
@staticmethod
|
|
796
796
|
def get_floating_capacity_licenses(token, product_id, interval_start_utc,
|
|
797
|
-
capacity_mode=
|
|
798
|
-
|
|
797
|
+
capacity_mode=None, page=1, limit=100,
|
|
798
|
+
min_utilization_percent=None):
|
|
799
799
|
"""
|
|
800
|
-
Retrieve licenses
|
|
800
|
+
Retrieve licenses by floating-seat utilization in a 30-minute UTC interval.
|
|
801
801
|
Requires Usage Analytics permission. Returning customer names, company
|
|
802
802
|
names, and email addresses also requires Get Customers permission.
|
|
803
803
|
|
|
804
804
|
product_id is required. interval_start_utc is a non-future Unix timestamp
|
|
805
805
|
in seconds, aligned to a 30-minute UTC boundary. It can be taken from a
|
|
806
|
-
Get Floating Capacity period's worstIntervalStartUtc.
|
|
807
|
-
|
|
808
|
-
|
|
806
|
+
Get Floating Capacity period's worstIntervalStartUtc. page starts at 1;
|
|
807
|
+
limit defaults to 100 and is capped at 1000 by the API.
|
|
808
|
+
|
|
809
|
+
min_utilization_percent is an inclusive minimum percentage of floating
|
|
810
|
+
seats used. Zero includes tracked licenses with a positive limit even
|
|
811
|
+
when no seats are in use. Values above 100 select overuse. Supply
|
|
812
|
+
capacity_mode ("exceeded" or "below") to apply both filters. Omitting
|
|
813
|
+
both filters defaults to "exceeded".
|
|
809
814
|
|
|
810
815
|
Returns (report, message), or (None, message) on failure. report is the
|
|
811
816
|
full dictionary with camelCase fields, including licenses, hasData,
|
|
@@ -815,12 +820,21 @@ class AI:
|
|
|
815
820
|
More docs: https://app.cryptolens.io/docs/api/v3/GetFloatingCapacityLicenses
|
|
816
821
|
"""
|
|
817
822
|
|
|
818
|
-
|
|
823
|
+
params = {
|
|
819
824
|
"ProductId": product_id,
|
|
820
825
|
"IntervalStartUtc": interval_start_utc,
|
|
821
|
-
"CapacityMode": capacity_mode,
|
|
822
826
|
"Page": page,
|
|
823
|
-
"Limit": limit}
|
|
827
|
+
"Limit": limit}
|
|
828
|
+
|
|
829
|
+
if capacity_mode is not None:
|
|
830
|
+
params["CapacityMode"] = capacity_mode
|
|
831
|
+
elif min_utilization_percent is None:
|
|
832
|
+
params["CapacityMode"] = "exceeded"
|
|
833
|
+
|
|
834
|
+
if min_utilization_percent is not None:
|
|
835
|
+
params["MinUtilizationPercent"] = min_utilization_percent
|
|
836
|
+
|
|
837
|
+
return AI.__get_usage_analytics("ai/GetFloatingCapacityLicenses", None, token, params)
|
|
824
838
|
|
|
825
839
|
@staticmethod
|
|
826
840
|
def get_floating_capacity_history(token, product_id, key_id=0, key="",
|
|
@@ -857,7 +871,8 @@ class AI:
|
|
|
857
871
|
|
|
858
872
|
@staticmethod
|
|
859
873
|
def get_expiring_licenses(token, product_id=0, window="7d", customer_id=None,
|
|
860
|
-
include_blocked_licenses=False, page=1, limit=100
|
|
874
|
+
include_blocked_licenses=False, page=1, limit=100,
|
|
875
|
+
last_seen_days=None):
|
|
861
876
|
"""
|
|
862
877
|
Retrieve upcoming license expirations and a 7/14/30-day summary.
|
|
863
878
|
Requires Usage Analytics permission. Returning customer names, company
|
|
@@ -869,12 +884,18 @@ class AI:
|
|
|
869
884
|
customer_id=None omits the customer filter; otherwise supply a positive
|
|
870
885
|
customer ID. Blocked licenses are excluded unless
|
|
871
886
|
include_blocked_licenses=True. page starts at 1; limit defaults to 100
|
|
872
|
-
and is capped at 1000 by the API.
|
|
887
|
+
and is capped at 1000 by the API. Set last_seen_days (1 to 36500) to
|
|
888
|
+
return licenses whose last recorded API activity was more than that
|
|
889
|
+
many days ago.
|
|
873
890
|
|
|
874
891
|
Returns (report, message), or (None, message) on failure. report is the
|
|
875
892
|
full dictionary with camelCase fields, including licenses, summary,
|
|
876
893
|
expiresBeforeUtc, page, limit, total, returned, and generatedUtc.
|
|
877
|
-
The summary
|
|
894
|
+
The summary is independent of window, page, limit and last_seen_days.
|
|
895
|
+
With last_seen_days, total counts candidates before activity filtering.
|
|
896
|
+
pageActivity.noRecordedActivity counts licenses with no recorded activity.
|
|
897
|
+
Follow report["pageActivity"]["nextPage"] until it is None, even when
|
|
898
|
+
a page has no matching licenses.
|
|
878
899
|
|
|
879
900
|
More docs: https://app.cryptolens.io/docs/api/v3/GetExpiringLicenses
|
|
880
901
|
"""
|
|
@@ -888,6 +909,8 @@ class AI:
|
|
|
888
909
|
|
|
889
910
|
if customer_id is not None:
|
|
890
911
|
params["CustomerId"] = customer_id
|
|
912
|
+
if last_seen_days is not None:
|
|
913
|
+
params["LastSeenDays"] = last_seen_days
|
|
891
914
|
|
|
892
915
|
return AI.__get_usage_analytics("ai/GetExpiringLicenses", None, token, params)
|
|
893
916
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: licensing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.56
|
|
4
4
|
Home-page: https://devolens.com
|
|
5
|
-
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/
|
|
5
|
+
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_56.tar.gz
|
|
6
6
|
Author: Cryptolens AB
|
|
7
7
|
Author-email: help@devolens.com
|
|
8
8
|
License: MIT
|
|
@@ -3,7 +3,7 @@ from setuptools import setup
|
|
|
3
3
|
setup(
|
|
4
4
|
name = 'licensing', # How you named your package folder (MyLib)
|
|
5
5
|
packages = ['licensing'], # Chose the same as "name"
|
|
6
|
-
version = '0.
|
|
6
|
+
version = '0.56', # Start with a small number and increase it with every change you make
|
|
7
7
|
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
|
|
8
8
|
#description_file = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
|
|
9
9
|
long_description = 'Client library for Devolens (formerly Cryptolens) Web API (software licensing).',
|
|
@@ -11,7 +11,7 @@ setup(
|
|
|
11
11
|
author = 'Cryptolens AB', # Type in your name
|
|
12
12
|
author_email = 'help@devolens.com', # Type in your E-Mail
|
|
13
13
|
url = 'https://devolens.com', # Provide either the link to your github or to your website
|
|
14
|
-
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/
|
|
14
|
+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_56.tar.gz',
|
|
15
15
|
project_urls={ # optional, shows on PyPI
|
|
16
16
|
"Source": "https://github.com/Cryptolens/cryptolens-python",
|
|
17
17
|
"Tracker": "https://github.com/Cryptolens/cryptolens-python/issues",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import unittest
|
|
3
|
+
from unittest.mock import patch
|
|
3
4
|
|
|
4
5
|
from licensing.internal import HelperMethods
|
|
5
6
|
from licensing.methods import AI
|
|
@@ -123,6 +124,53 @@ class AIUsageAnalyticsTests(unittest.TestCase):
|
|
|
123
124
|
"MachineCode": "MACHINE-1"
|
|
124
125
|
})
|
|
125
126
|
|
|
127
|
+
@patch.object(HelperMethods, "send_request", return_value='{"result": 0}')
|
|
128
|
+
def test_floating_capacity_minimum_without_mode(self, send_request):
|
|
129
|
+
for minimum in (0, 90, 110):
|
|
130
|
+
with self.subTest(minimum=minimum):
|
|
131
|
+
AI.get_floating_capacity_licenses(
|
|
132
|
+
"token", 123, 1800, min_utilization_percent=minimum)
|
|
133
|
+
|
|
134
|
+
send_request.assert_called_with("ai/GetFloatingCapacityLicenses", {
|
|
135
|
+
"token": "token", "ProductId": 123, "IntervalStartUtc": 1800,
|
|
136
|
+
"MinUtilizationPercent": minimum, "Page": 1, "Limit": 100})
|
|
137
|
+
|
|
138
|
+
@patch.object(HelperMethods, "send_request", return_value='{"result": 0}')
|
|
139
|
+
def test_floating_capacity_minimum_with_explicit_mode(self, send_request):
|
|
140
|
+
for mode in ("below", "exceeded"):
|
|
141
|
+
with self.subTest(mode=mode):
|
|
142
|
+
AI.get_floating_capacity_licenses(
|
|
143
|
+
"token", 123, 1800, mode, 2, 10, min_utilization_percent=90)
|
|
144
|
+
|
|
145
|
+
send_request.assert_called_with("ai/GetFloatingCapacityLicenses", {
|
|
146
|
+
"token": "token", "ProductId": 123, "IntervalStartUtc": 1800,
|
|
147
|
+
"CapacityMode": mode, "MinUtilizationPercent": 90, "Page": 2, "Limit": 10})
|
|
148
|
+
|
|
149
|
+
@patch.object(HelperMethods, "send_request", return_value='{"result": 0}')
|
|
150
|
+
def test_reports_without_new_filters_keep_existing_requests(self, send_request):
|
|
151
|
+
AI.get_floating_capacity_licenses("token", 123, 1800)
|
|
152
|
+
send_request.assert_called_with("ai/GetFloatingCapacityLicenses", {
|
|
153
|
+
"token": "token", "ProductId": 123, "IntervalStartUtc": 1800,
|
|
154
|
+
"CapacityMode": "exceeded", "Page": 1, "Limit": 100})
|
|
155
|
+
|
|
156
|
+
AI.get_expiring_licenses("token", 123, "90d", 456, True, 2, 10)
|
|
157
|
+
send_request.assert_called_with("ai/GetExpiringLicenses", {
|
|
158
|
+
"token": "token", "ProductId": 123, "Window": "90d", "CustomerId": 456,
|
|
159
|
+
"IncludeBlockedLicenses": True, "Page": 2, "Limit": 10})
|
|
160
|
+
|
|
161
|
+
@patch.object(HelperMethods, "send_request")
|
|
162
|
+
def test_expiring_licenses_last_seen_filter_preserves_page_activity(self, send_request):
|
|
163
|
+
report = {"result": 0, "licenses": [], "pageActivity": {"nextPage": 3, "noRecordedActivity": 1}}
|
|
164
|
+
send_request.return_value = json.dumps(report)
|
|
165
|
+
|
|
166
|
+
result = AI.get_expiring_licenses(
|
|
167
|
+
"token", window="90d", page=2, limit=10, last_seen_days=30)
|
|
168
|
+
|
|
169
|
+
send_request.assert_called_once_with("ai/GetExpiringLicenses", {
|
|
170
|
+
"token": "token", "ProductId": 0, "Window": "90d", "IncludeBlockedLicenses": False,
|
|
171
|
+
"LastSeenDays": 30, "Page": 2, "Limit": 10})
|
|
172
|
+
self.assertEqual(result, (report, ""))
|
|
173
|
+
|
|
126
174
|
|
|
127
175
|
if __name__ == "__main__":
|
|
128
176
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|