API Reference¶
This part of the documentation covers the classes and interfaces of the 10Duke Scale SDk.
The main functionality of the library is access via the various API clients.
There are helpers for configuring the SDK to access the API, authorization of API calls, and authentication of users via OAuth/Open ID Connect flows.
Configuration¶
The TendukeConfig
class can be used to set configuration
values.
It can additionally read configuration items from a file or environment variables.
Authorization¶
Authorization for the 10Duke Scale API is achieved using ID Tokens, Scale JWT tokens, or using license keys in the API requests.
Classes are provided to implement ID token or Scale JWT Authorization.
Additionally, helpers are provided for OAuth and Open ID Connect flows:
Other flows are left for the application to implement. Sample code is
included for reference. These can be used with or without deriving from
OAuthClient
Authentication and Authorization.
ScaleJwtAuth
¶
Bases: AuthBase
Scale JWT Auth hook - for use in confidential applications.
Source code in tenduke_scale/auth/scale_jwt_auth_provider.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
__call__(r)
¶
Mutate outgoing request (adding authorization header).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r
|
PreparedRequest
|
Outgoing request. |
required |
Source code in tenduke_scale/auth/scale_jwt_auth_provider.py
112 113 114 115 116 117 118 119 120 121 122 123 |
|
__eq__(other)
¶
Return True if instances are equal; otherwise False.
Equality is tested by comparing the JWTs.
Source code in tenduke_scale/auth/scale_jwt_auth_provider.py
125 126 127 128 129 130 |
|
__init__(key_id, private_key, claims, config)
¶
Construct a ScaleJwtAuth provider (hook).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_id
|
str
|
The id of the key pair to use to sign the JWT. |
required |
private_key
|
str
|
The private half of of the key pair to use to sign the JWT. |
required |
claims
|
ScaleJwtClaims
|
The authorization claims to be included in the JWT. |
required |
config
|
TendukeConfig
|
Configuration object specifying token_refresh_leeway_seconds. |
required |
Source code in tenduke_scale/auth/scale_jwt_auth_provider.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
__ne__(other)
¶
Return True if instances are not equal; otherwise False.
Equality is tested by comparing the JWTs.
Source code in tenduke_scale/auth/scale_jwt_auth_provider.py
132 133 134 135 136 137 |
|
ScaleJwtClaims
dataclass
¶
Claims for Scale JWT.
https://docs.scale.10duke.com/api/api-authorization/#confidential-applications-10duke-jwts
Attributes:
Name | Type | Description |
---|---|---|
sub |
str
|
Subject, used to identify calling identity. The value is matched to connectedIdentityId field in LicenseConsumer objects. |
iss |
str
|
Issuer of the token. |
valid_for |
timedelta
|
Number of seconds the token should be considered valid for. |
permissions |
Sequence[str]
|
Array, value syntax: [Resource.permission,...]. |
license_consumer_id |
Optional[UUID]
|
The id of the consumer of the license. |
Source code in tenduke_scale/auth/scale_jwt_auth_provider.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
Checking out licenses¶
The 10Duke Scale License Checkout API is accessed using the subclasses of [tenduke_scale.license_checkout.LicenseCheckoutClientABC].
License checkout, release, heartbeat related types.
ClientDetails
dataclass
¶
Bases: Model
Model for providing client details to checkout operations.
Attributes:
Name | Type | Description |
---|---|---|
country |
Optional[str]
|
Country code of OS environment that the client app runs on. |
host_name |
Optional[str]
|
Hostname of device that the client app runs on. |
hardware_architecture |
Optional[str]
|
Architecture of of device / platform that the client app runs on. |
hardware_id |
Optional[str]
|
Hardware id of device that the client app runs on. This claim is required to implement concurrency rules over a user's devices. |
hardware_label |
Optional[str]
|
Hardware label of device that the client app runs on. |
installation_id |
Optional[str]
|
Installation id the client app. |
language |
Optional[str]
|
Language code of the OS environment that the client app runs on. |
process_id |
Optional[str]
|
Process id of client app process in OS environment that the client app runs on. This claim is required to implement concurrency rules over a user's application instances (processes). |
version |
Optional[str]
|
Client app version. This claim is required to implement rules about allowed versions and enforcing that a license is usable only for certain client application versions. The specified version is compared lexicographically to lower and upper bounds in available licenses. If a license id is used in checkout then the client version must be within the allowed version range in that specific license. Version is enforced only if the license requires it. |
Source code in tenduke_scale/license_checkout/client_details.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
DefaultTokenStore
¶
Bases: TokenStoreABC
Default (non-persistent) implementation of TokenStore.
Source code in tenduke_scale/license_checkout/token_store.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
__init__()
¶
Construct instance of the DefaultTokenStore.
Source code in tenduke_scale/license_checkout/token_store.py
99 100 101 |
|
load()
¶
Load any currently stored LicenseTokens.
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
The sequence of LicenseTokens currently stored or persisted in the token store. |
Source code in tenduke_scale/license_checkout/token_store.py
112 113 114 115 116 117 118 |
|
remove_all()
¶
Clear the contents of the store.
Source code in tenduke_scale/license_checkout/token_store.py
120 121 122 |
|
save(tokens)
¶
Save LicenseTokens to the store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tokens
|
Sequence[LicenseToken]
|
List of tokens to save. This should be interpretted as replacing the current contents of the store. |
required |
Source code in tenduke_scale/license_checkout/token_store.py
103 104 105 106 107 108 109 110 |
|
EnforcedLicenseCheckoutClient
¶
Bases: LicenseCheckoutClientABC
Client for checking out licenses using an enforced model.
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
checkout(to_checkout, license_key=None, license_consumer_id=None, client_details=None)
¶
Checkout a license.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_checkout
|
Sequence[LicenseCheckoutArguments]
|
List of arguments objects describing the options when checking out each license. |
required |
license_key
|
Optional[str]
|
Scale License Key identifying licence(s) to checkout. |
None
|
license_consumer_id
|
Optional[UUID]
|
Sets a header identifying the license consumer. |
None
|
client_details
|
Optional[ClientDetails]
|
Client claims object for checkout. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of license tokens representing successful and failed license checkouts. |
Raises:
Type | Description |
---|---|
ApiError
|
Checkout request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
checkout_multiple_by_license_key(license_key, to_checkout, client_details=None)
¶
Checkout multiple licenses using a license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to checkout. |
required |
to_checkout
|
Sequence[LicenseCheckoutArguments]
|
A list of objects describing the options for checking out the licenses. |
required |
client_details
|
Optional[ClientDetails]
|
Client claims object for checkout. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of license tokens representing successful and failed license checkouts. |
Raises:
Type | Description |
---|---|
ApiError
|
Checkout request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
checkout_single_by_license_key(license_key, to_checkout, client_details=None)
¶
Checkout a license by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to checkout. |
required |
to_checkout
|
LicenseCheckoutArguments
|
An object describing the options for checking out the license. |
required |
client_details
|
Optional[ClientDetails]
|
Client claims object for checkout. |
None
|
Returns:
Type | Description |
---|---|
LicenseToken
|
A license token describing the success or failure of the checkout. |
Raises:
Type | Description |
---|---|
ApiError
|
Checkout request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
heartbeat(to_heartbeat, license_key=None, license_consumer_id=None)
¶
Verify one or more license checkout is still valid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_heartbeat
|
Sequence[LicenseHeartbeatArguments]
|
List of arguments objects describing the licenses to heartbeat. |
required |
license_key
|
Optional[str]
|
Scale License Key identifying licence(s) to heartbeat. |
None
|
license_consumer_id
|
Optional[UUID]
|
Sets a header identifying the license consumer. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of LicenseToken objects for the successful and failed heartbeats. |
Raises:
Type | Description |
---|---|
ApiError
|
Heartbeat request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
heartbeat_multiple_by_license_key(license_key, to_heartbeat)
¶
Heartbeat multiple licenses by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to heartbeat. |
required |
to_heartbeat
|
Sequence[LicenseHeartbeatArguments]
|
List of arguments objects describing the licenses to heartbeat. |
required |
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of LicenseToken objects for the successful and failed heartbeats. |
Raises:
Type | Description |
---|---|
ApiError
|
Heartbeat request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
heartbeat_single_by_license_key(license_key, to_heartbeat)
¶
Heartbeat a license by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to heartbeat. |
required |
to_heartbeat
|
LicenseHeartbeatArguments
|
An arguments object describing the license to heartbeat. |
required |
Returns:
Type | Description |
---|---|
LicenseToken
|
LicenseToken object describing the successful or failed heartbeat attempt. |
Raises:
Type | Description |
---|---|
ApiError
|
Heartbeat request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
release(to_release, license_key=None, license_consumer_id=None)
¶
Release a license.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_release
|
Sequence[LicenseReleaseArguments]
|
List of arguments objects describing the licenses to release. |
required |
license_key
|
Optional[str]
|
Scale License Key identifying licence(s) to release. |
None
|
license_consumer_id
|
Optional[UUID]
|
Sets a header identifying the license consumer. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseReleaseResult]
|
List of LicenseReleaseResult objects representing the licenses successfully released. |
Raises:
Type | Description |
---|---|
ApiError
|
Release request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
release_multiple_by_license_key(license_key, to_release)
¶
Release multiple licenses by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to release. |
required |
to_release
|
Sequence[LicenseReleaseArguments]
|
List of arguments objects describing the licenses to release. |
required |
Returns:
Type | Description |
---|---|
Sequence[LicenseReleaseResult]
|
List of LicenseReleaseResult objects representing the licenses successfully released. |
Raises:
Type | Description |
---|---|
ApiError
|
Release request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
release_single_by_license_key(license_key, args)
¶
Release a license by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to release. |
required |
args
|
LicenseReleaseArguments
|
An arguments object describing the license to release. |
required |
Returns:
Type | Description |
---|---|
LicenseReleaseResult
|
LicenseReleaseResult object representing the license released. |
Raises:
Type | Description |
---|---|
ApiError
|
Release request failed. |
Source code in tenduke_scale/license_checkout/enforced_license_checkout_client.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
FeatureFlagsResponse
dataclass
¶
Bases: Model
Feature flags for a product.
Attributes:
Name | Type | Description |
---|---|---|
product_name |
str
|
Name of the product. |
features |
Sequence[str]
|
List of feature names. |
Source code in tenduke_scale/license_checkout/feature_flags_response.py
8 9 10 11 12 13 14 15 16 17 18 |
|
LicenseCheckoutArguments
dataclass
¶
Bases: Model
Model for checking out enforced licenses or starting metered licenses.
Attributes:
Name | Type | Description |
---|---|---|
product_name |
str
|
Product name for which license checkout is requested. |
quantity_dimension |
QD
|
Enum: "SEATS" "USE_COUNT" "USE_TIME" Quantity dimension, related units of measurement: seats and use count = unitless, use time = seconds. |
quantity |
int
|
Quantity defines how much to consume. NOTE: does not apply for seat based licensing. When using seats quantity is always equals to 1 (maximum qty = 1 when requesting to consume a seat, qtyDimension = SEATS). |
client_version |
Optional[str]
|
Client application version. NOTE: required when consuming licenses that have an allowed version range specified. Recommendation: client applications are encouraged to always send their version. |
license_id |
Optional[UUID]
|
Optional id of a specific license to consume. No license selection fallback logic kicks in if this value is defined. This means consumption either succeeds based on the specific license or fails with no further reason. Using this field is redunant if a license key is used. |
Source code in tenduke_scale/license_checkout/license_checkout_arguments.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
LicenseCheckoutClientABC
¶
Bases: ABC
Base class for license checkout clients.
Source code in tenduke_scale/license_checkout/license_checkout_client.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|
__init__(api_url, session, token_store=None)
¶
Construct the LicenseCheckoutClientABC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_url
|
str
|
Base API URL of the Scale tenant being accessed. |
required |
session
|
Session
|
requests.Session object configured for use by client. |
required |
token_store
|
Optional[TokenStoreABC]
|
Used to store and manage tokens. |
None
|
Source code in tenduke_scale/license_checkout/license_checkout_client.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
describe_license_key(license_key, with_metadata=False, paging=None)
¶
Retrieve the licenses that a license key grants usage rights to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
The license key to get license information for. |
required |
with_metadata
|
bool
|
Flag to control including verbose information about the licenses and client bindings. Setting this option to true will fetch contract, order, subscription and external reference information at time of original license grant, the license container, a possible license key and related product information. For client bindings the additional information is related to license consumption objects and license consumers. Defaults to false. |
False
|
paging
|
Optional[PagingOptions]
|
Sets limit, offset, and sorting for the result. |
None
|
Source code in tenduke_scale/license_checkout/license_checkout_client.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
describe_license_key_client_bindings(license_key, license_id, describe_license_options=None, paging=None)
¶
Retrieve license use for a license checked out using a license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
The license key to get information for. |
required |
license_id
|
UUID
|
The license id to get checkout information for. |
required |
describe_license_options
|
Optional[DescribeLicenseOptions]
|
Options setting what information to return. |
None
|
paging
|
Optional[PagingOptions]
|
Sets limit, offset, and sorting for the result. |
None
|
Source code in tenduke_scale/license_checkout/license_checkout_client.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
|
describe_license_usage(licensee_id, license_id, license_consumer_id=None, describe_license_options=None, paging=None)
¶
Retrieve the current usage for a license.
Get the client bindings (existing checkouts or consumptions) of a specific license within a licensee. This provides information about what devices a license is currently checked out on and which license consumers (users) are using the license.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
licensee_id
|
UUID
|
The licensee to describe licenses for (only client bindings for licenses scoped to this licensee will be included in the result). |
required |
license_id
|
UUID
|
Identifier of the license that the information is scoped to. |
required |
license_consumer_id
|
Optional[UUID]
|
Optional identifier of the license consumer the the information is scoped to. Use only with Scale JWT authorization. |
None
|
describe_license_options
|
Optional[DescribeLicenseOptions]
|
Options setting what information to return. |
None
|
paging
|
Optional[PagingOptions]
|
Sets limit, offset, and sorting for the result. |
None
|
Returns:
Type | Description |
---|---|
LicenseConsumerClientBindingStatus
|
LicenseConsumerClientBindingStatus listing the current client bindings for the |
LicenseConsumerClientBindingStatus
|
specified license. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
describe_licensees(license_consumer_id=None, paging_args=None)
¶
Retrieve the set of licensees that the consumer is connected to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_consumer_id
|
Optional[UUID]
|
The license consumer to describe licensees for. |
None
|
paging_args
|
Optional[PagingOptions]
|
Sets limit, offset, and sorting for the result. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseConsumer]
|
List of license consumer objects describing the licensees that the consumer can access |
Sequence[LicenseConsumer]
|
licenses from. |
Raises:
Type | Description |
---|---|
ApiError
|
The request failed. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
describe_licenses(licensee_id, license_consumer_id=None, describe_license_options=None, paging=None)
¶
Retrieve the licenses the license consumer currently has access to from the licensee.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
licensee_id
|
UUID
|
The licensee to describe licenses for. |
required |
license_consumer_id
|
Optional[UUID]
|
The license consumer to describe licenses for. |
None
|
describe_license_options
|
Optional[DescribeLicenseOptions]
|
Options setting what information to return. |
None
|
paging
|
Optional[PagingOptions]
|
Sets limit, offset, and sorting for the result. |
None
|
Returns:
Type | Description |
---|---|
LicenseConsumerLicensesStatus
|
LicenseConsumerLicensesStatus listing the licenses that the consumer has access to. |
Raises:
Type | Description |
---|---|
ApiError
|
The request failed. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
describe_licenses_in_use(licensee_id, license_consumer_id=None, describe_license_options=None, paging=None)
¶
Retrieve the currently checked out licenses.
Get the list of licenses that are known to be in use by a specific license consumer (user). These are then returned to the client application as a list of client bindings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
licensee_id
|
UUID
|
The licensee to describe licenses for (only client bindings for licenses scoped to this licensee will be included in the result). |
required |
license_consumer_id
|
Optional[UUID]
|
The license consumer to describe licenses for. If omitted, client bindings for the currently logged in user are returned. Must be provided if using 10Duke ScaleJWT Authorization. |
None
|
describe_license_options
|
Optional[DescribeLicenseOptions]
|
Options setting what information to return. |
None
|
paging
|
Optional[PagingOptions]
|
Sets limit, offset, and sorting for the result. |
None
|
Returns:
Type | Description |
---|---|
LicenseConsumerClientBindingStatus
|
LicenseConsumerClientBindingStatus listing the current client bindings for the |
LicenseConsumerClientBindingStatus
|
specified license consumer. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
feature_flags(licensee_id, license_consumer_id=None, filter_value=None)
¶
Retrieve licensed features that a license consumer (user) has access to.
The list of features returned is scoped to the licensee and license consumer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
licensee_id
|
UUID
|
The licensee to describe licenses for (only licenses scoped to this licensee will be used to produce the result). |
required |
license_consumer_id
|
Optional[UUID]
|
The license consumer to describe licenses for. If omitted, licenses for the currently logged in user are returned. Must be provided if using 10Duke ScaleJWT Authorization. |
None
|
filter_value
|
Optional[str]
|
Product name to match in result. Defaults to null (no filtering). The match is full name, case insensitive. |
None
|
Source code in tenduke_scale/license_checkout/license_checkout_client.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
feature_flags_as_jwt(licensee_id, license_consumer_id=None, filter_value=None)
¶
Retrieve licensed features that a license consumer (user) has access to as JWT.
The list of features returned is scoped to the licensee and license consumer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
licensee_id
|
UUID
|
The licensee to describe licenses for (only licenses scoped to this licensee will be used to produce the result). |
required |
license_consumer_id
|
Optional[UUID]
|
The license consumer to describe licenses for. If omitted, licenses for the currently logged in user are returned. Must be provided if using 10Duke ScaleJWT Authorization. |
None
|
filter_value
|
Optional[str]
|
Product name to match in result. Defaults to null (no filtering). The match is full name, case insensitive. |
None
|
Source code in tenduke_scale/license_checkout/license_checkout_client.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
find_client_binding(licensee_id, client_binding_id, with_metadata=False)
¶
Retrieve a specific client binding.
Get the details of a client binding, within a licensee, by its unique identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
licensee_id
|
UUID
|
The licensee to describe licenses for (only client bindings for licenses scoped to this licensee will be included in the result). |
required |
client_binding_id
|
UUID
|
Identifier of the client binding requested. |
required |
with_metadata
|
bool
|
Flag to control including verbose information about the licenses and client bindings. Setting this option to true will fetch contract, order, subscription and external reference information at time of original license grant, the license container, a possible license key and related product information. For client bindings the additional information is related to license consumption objects and license consumers. Defaults to false. |
False
|
Returns:
Type | Description |
---|---|
LicenseConsumerClientBindingStatus
|
LicenseConsumerClientBindingStatus listing the requested client binding if found. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
parse_jwt(jwt)
¶
Parse JWT using public key for Scale API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
jwt
|
str
|
Raw jwt to parse. |
required |
Returns:
Type | Description |
---|---|
LicenseToken
|
LicenseToken containing the details from the JWT. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
460 461 462 463 464 465 466 467 468 469 470 |
|
raise_if_consumer_unknown(license_consumer_id=None)
¶
Raise an error is the license consumer is not provided and cannot be inferred.
Return if the license_consumer_id is set, or auth is using ID Token; otherwise raise error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_consumer_id
|
Optional[UUID]
|
license consumer id provided to client method. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
The license consumer id is not set and there is no id token. |
Source code in tenduke_scale/license_checkout/license_checkout_client.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
LicenseConsumerClientBindingStatus
dataclass
¶
Bases: Model
Model for describe consumer client bindings response.
Attributes:
Name | Type | Description |
---|---|---|
all_client_bindings_included |
Optional[bool]
|
Indicates whether the analysis of a users license consumption found more than the maximum response size worth of client bindings. A value equal to false means the response size was capped and true means all current client bindings have been included in the response. The maximum client binding count included in the response is 5 per license. |
client_bindings |
Optional[Sequence[LicenseConsumptionClientBinding]]
|
Licenses that are currently known to be associated with a license consuming user using a specific application on a specific device. Note: this list size is limited to a predefined size and provides only a view into a small set of the most recent client bindings. Capping can be inspected by checking the flag: allClientBindingsIncluded. |
Source code in tenduke_scale/license_checkout/license_consumer_client_binding_status.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
LicenseConsumerLicensesStatus
dataclass
¶
Bases: Model
Model for describe consumer licenses response.
Attributes:
Name | Type | Description |
---|---|---|
licenses |
Optional[Sequence[License]]
|
Licenses that are accessible by the license consumer. |
Source code in tenduke_scale/license_checkout/license_consumer_licenses_status.py
16 17 18 19 20 21 22 23 24 25 26 |
|
LicenseConsumptionClientBinding
dataclass
¶
Bases: Model
Model for license consumption client binding object.
Attributes:
Name | Type | Description |
---|---|---|
client_api_key |
Optional[str]
|
API key specified in client claims at checkout. |
client_country |
Optional[str]
|
Country code of OS environment that the client app runs on. |
client_host_name |
Optional[str]
|
Hostname of device that the client app runs on. |
client_hardware_architecture |
Optional[str]
|
Architecture of of device / platform that the client app runs on. |
client_hardware_id |
Optional[str]
|
Hardware id of device that the client app runs on. This claim is required to implement concurrency rules over a user's devices. |
client_hardware_label |
Optional[str]
|
Hardware label of device that the client app runs on. |
client_installation_id |
Optional[str]
|
Installation id the client app. |
client_language |
Optional[str]
|
Language code of the OS environment that the client app runs on. |
client_network_ip_address |
Optional[str]
|
|
client_os_user_name |
Optional[str]
|
User name from OS environment session client app is running in. |
client_os |
Optional[str]
|
Name of OS environment that the client app runs on. |
client_process_id |
Optional[str]
|
Process id of client app process in OS environment that the client app runs on. This claim is required to implement concurrency rules over a user's application instances (processes). |
client_version |
Optional[str]
|
Client app version. This claim is required to implement rules about allowed versions and enforcing that a license is usable only for certain client application versions. The specified version is compared lexicographically to lower and upper bounds in available licenses. If a license id is used in checkout then the client version must be within the allowed version range in that specific license. Version is enforced only if the license requires it. |
consume_duration_ended_at |
Optional[datetime]
|
When the consumption ended. |
consume_duration_granted_at |
Optional[datetime]
|
When the consumption was granted. |
created |
Optional[datetime]
|
When the client binding was created. |
id |
Optional[int]
|
Unique identifier for the client binding. |
last_heartbeat |
Optional[datetime]
|
When the last successful heartbeat was received. |
lease_id |
Optional[str]
|
Lease id of the lease associated with this binding. |
license |
Optional[License]
|
The license that this binding is associated with. |
license_consumer |
Optional[LicenseConsumer]
|
The consumer of the license binding. |
locked |
Optional[bool]
|
Indicates whether the consumption is locked to this hardware. |
modified |
Optional[datetime]
|
When the client binding was last modified. |
quantity_pre_allocated |
Optional[int]
|
Consumption amount allocated at checkout. Pre-allocating a quantity amount applies to quantity types that pure deductible nature, e.g. use count and use time. Its an indicative amount of e.g. use count or use time that a client estimates it needs to complete a task (may be end user driven). Client applications may use pre-allocation to ensure a certain amount of quantity is still available when starting a task. The pre-allocation is deducted from the available quantity and the final outcome is computed at time of release. The verified quantity is set at time of release and if the factual used quantity is less than what pass pre-allocated then the difference is refunded. NOTE: does not apply when consuming seats. |
request_ip_address |
Optional[str]
|
Address requesting the client binding. |
triggered_seat_use |
Optional[bool]
|
Indicates if this client binding used a new seat. |
valid_from |
Optional[datetime]
|
Start of binding validity period. |
valid_until |
Optional[datetime]
|
End of binding validity period. |
verified_quantity |
Optional[int]
|
Verified quantity is determined by the consuming client informing the licensing API of factual use. This can happen at time of heartbeat and release. The verified quantity is applies to quantity types that pure deductible nature, e.g. use count and use time. NOTE: does not apply when consuming seats. |
Source code in tenduke_scale/license_checkout/license_consumption_client_binding.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
LicenseHeartbeatArguments
dataclass
¶
Bases: Model
Arguments for license heartbeat API operation.
Attributes:
Name | Type | Description |
---|---|---|
lease_id |
str
|
Lease id value as it was returned in last heartbeat response or initial license checkout if no heartbeat has been done before this heartbeat request. |
treat_as_incremental_quantity |
bool
|
Default: False. Flag that tells if the usedQty value is absolute or should be treated as an increment. NOTE: does NOT APPLY when using SEAT based licensing. |
used_quantity |
int
|
The amount used since initial license checkout / previous heartbeat. The usage quantity is an absolute value by default. Set field treatAsIncrementalQty = true to use an incremental tracking algorithm instead. NOTE: does NOT APPLY when using SEAT based licensing. |
Source code in tenduke_scale/license_checkout/license_heartbeat_arguments.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
LicenseReleaseArguments
dataclass
¶
Bases: Model
Model for releasing enforced licenses or ending use of metered licenses.
Attributes:
Name | Type | Description |
---|---|---|
lease_id |
str
|
Lease id value as it was returned in last heartbeat response or initial license checkout if no heartbeat has been done before release. |
final_quantity_used |
Optional[int]
|
The final amount used since initial license checkout. NOTE: does not apply when using seat based licensing. |
Source code in tenduke_scale/license_checkout/license_release_arguments.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
LicenseReleaseResult
dataclass
¶
Bases: Model
Model for LicenseReleaseResult object.
Attributes:
Name | Type | Description |
---|---|---|
error_code |
Optional[str]
|
Short identifier for error condition. |
error_description |
Optional[str]
|
Textual description of error condition. |
final_used_quantity |
Optional[int]
|
The final amount used since initial license checkout. |
license_consumer_id |
Optional[UUID]
|
The consumer of the license/ |
product_name |
Optional[str]
|
Product name for which license checkout was for. |
quantity_dimension |
Optional[QD]
|
Enum: "SEATS" "USE_COUNT" "USE_TIME" Quantity dimension, related units of measurement: seats and use count = unitless, use time = seconds. |
released |
Optional[bool]
|
Was the license released? |
released_lease_id |
Optional[str]
|
Lease id that has been released. |
released_license_id |
Optional[UUID]
|
License id of the release checkout. |
remaining_quantity |
Optional[int]
|
Remaining amount available for the license. |
Source code in tenduke_scale/license_checkout/license_release_result.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
LicenseToken
¶
License token model.
Source code in tenduke_scale/license_checkout/license_token.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
claims: Dict[str, Any]
property
¶
Raw claims from JWT.
error_code: Optional[str]
property
¶
Error code for a failed consumtpion.
error_description: Optional[str]
property
¶
Error description for a failed consumtpion.
features: str
property
¶
Features, lists sub features granted in this license.
heartbeat_not_before: datetime
property
¶
Heartbeat not before (hbnbf) claim.
jwt_id: str
property
¶
JWT Id (jti) claim.
lease_id: Optional[str]
property
¶
Lease id, used to refresh or release license.
old_lease_id: Optional[str]
property
¶
Old lease id (if this is a continuation of a previous lease).
product_name: str
property
¶
Product name, identifies what permission is granted.
quantity: int
property
¶
Number of seats, uses, or time granted.
quantity_dimension: QD
property
¶
Describes whether this is seats, uses, or use time.
status: Optional[str]
property
¶
Status of checkout.
__init__(raw_jwt, public_key)
¶
Construct an instance of a LicenseToken from a JWT and public key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_jwt
|
str
|
The base64 encoded string containing the token. |
required |
public_key
|
str
|
The public part of the key pair used to sign the token. |
required |
Source code in tenduke_scale/license_checkout/license_token.py
26 27 28 29 30 31 32 33 34 35 |
|
make_release_arguments(tokens)
classmethod
¶
Return LicenseReleaseArguments for successful checkouts.
Any license tokens representing failed or unsuccessful checkouts are dropped from the returned sequence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tokens
|
Sequence[T]
|
List of license tokens that may include one or more successful checkouts. |
required |
Returns:
Type | Description |
---|---|
Sequence[LicenseReleaseArguments]
|
Sequence of LicenseReleaseArguments that can be used to release the license tokens that |
Sequence[LicenseReleaseArguments]
|
represent successful checkouts. |
Source code in tenduke_scale/license_checkout/license_token.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
to_release_argument(final_quantity_used=None)
¶
Construct a LicenseReleaseArgument, if this was a successful checkout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
final_quantity_used
|
Optional[int]
|
Specifies the quantity to send in the release call. |
None
|
Returns:
Type | Description |
---|---|
Optional[LicenseReleaseArguments]
|
LicenseReleaseArguments object to release the lease represented by this license token. |
Optional[LicenseReleaseArguments]
|
If this license token is for a failed or unsuccessful checkout, then the method returns |
Optional[LicenseReleaseArguments]
|
None. |
Source code in tenduke_scale/license_checkout/license_token.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
MeteredLicenseCheckoutClient
¶
Bases: LicenseCheckoutClientABC
Client for consuming licenses using a metered use model.
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
end(to_release, license_key=None, license_consumer_id=None)
¶
End metered license use.
Ending metered use must send the final used quantity, which is recorded by the API as part of ending the metered usage session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_release
|
Sequence[LicenseReleaseArguments]
|
List of arguments objects describing the options when releasing each license. |
required |
license_key
|
Optional[str]
|
Scale License Key identifying licence(s) to release. |
None
|
license_consumer_id
|
Optional[UUID]
|
Sets a header identifying the license consumer. Mandatory if using Scale JWT API authorization; otherwise optional. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseReleaseResult]
|
List of LicenseReleaseResult objects representing the licenses successfully released. |
Raises:
Type | Description |
---|---|
ApiError
|
Release request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
end_multiple_by_license_key(license_key, to_end)
¶
End metered use of a multiple licenses using a license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to release. |
required |
to_end
|
Sequence[LicenseReleaseArguments]
|
List of arguments objects describing the licenses to release. |
required |
Returns:
Type | Description |
---|---|
Sequence[LicenseReleaseResult]
|
List of LicenseReleaseResult objects representing the licenses successfully released. |
Raises:
Type | Description |
---|---|
ApiError
|
Release request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
end_single_by_license_key(license_key, to_end)
¶
End metered use of a single license using a license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to release. |
required |
to_end
|
LicenseReleaseArguments
|
An arguments object describing the license to release. |
required |
Returns:
Type | Description |
---|---|
LicenseReleaseResult
|
LicenseReleaseResult object representing the license released. |
Raises:
Type | Description |
---|---|
ApiError
|
Release request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
heartbeat(to_heartbeat, license_key=None, license_consumer_id=None)
¶
Update the consumed quantity for a license.
The heartbeat operation also re-authorizes the use of a license.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_heartbeat
|
Sequence[LicenseHeartbeatArguments]
|
List of arguments objects describing the licenses to heartbeat. |
required |
license_key
|
Optional[str]
|
Scale License Key identifying licence(s) to heartbeat. |
None
|
license_consumer_id
|
Optional[UUID]
|
Sets a header identifying the license consumer. Mandatory if using Scale JWT API authorization; otherwise optional. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of LicenseToken objects for the successful and failed heartbeats. |
Raises:
Type | Description |
---|---|
ApiError
|
Heartbeat request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
heartbeat_multiple_by_license_key(license_key, to_heartbeat)
¶
Heartbeat multiple licenses by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to heartbeat. |
required |
to_heartbeat
|
Sequence[LicenseHeartbeatArguments]
|
List of arguments objects describing the licenses to heartbeat. |
required |
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of LicenseToken objects for the successful and failed heartbeats. |
Raises:
Type | Description |
---|---|
ApiError
|
Heartbeat request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
heartbeat_single_by_license_key(license_key, to_heartbeat)
¶
Heartbeat a license by license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to heartbeat. |
required |
to_heartbeat
|
LicenseHeartbeatArguments
|
An arguments object describing the license to heartbeat. |
required |
Returns:
Type | Description |
---|---|
LicenseToken
|
LicenseToken object describing the successful or failed heartbeat attempt. |
Raises:
Type | Description |
---|---|
ApiError
|
Heartbeat request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
start(to_checkout, license_key=None, license_consumer_id=None, client_details=None)
¶
Start metered license use.
Metered use of a license is based on the product name and a signal that use of the license has started (calling this method). A license ID can optionally be specified to record usage of a specific license.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_checkout
|
Sequence[LicenseCheckoutArguments]
|
List of arguments objects describing the options when checking out each license. |
required |
license_key
|
Optional[str]
|
Scale License Key identifying licence(s) to checkout. |
None
|
license_consumer_id
|
Optional[UUID]
|
Sets a header identifying the license consumer. Mandatory if using Scale JWT API authorization; otherwise optional. |
None
|
client_details
|
Optional[ClientDetails]
|
Client claims object for checkout. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of license tokens representing successful and failed license checkouts. |
Raises:
Type | Description |
---|---|
ApiError
|
Checkout request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
start_multiple_by_license_key(license_key, to_checkout, client_details=None)
¶
Start use of a multiple licenses using a license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to checkout. |
required |
to_checkout
|
Sequence[LicenseCheckoutArguments]
|
A list of objects describing the options for checking out the licenses. |
required |
client_details
|
Optional[ClientDetails]
|
Client claims object for checkout. |
None
|
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
List of license tokens representing successful and failed license checkouts. |
Raises:
Type | Description |
---|---|
ApiError
|
Checkout request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
start_single_by_license_key(license_key, to_checkout, client_details=None)
¶
Start use of a single license using a license key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
license_key
|
str
|
Scale License Key identifying licence(s) to checkout. |
required |
to_checkout
|
LicenseCheckoutArguments
|
An object describing the options for checking out the license. |
required |
client_details
|
Optional[ClientDetails]
|
Client claims object for checkout. |
None
|
Returns:
Type | Description |
---|---|
LicenseToken
|
A license token describing the success or failure of the checkout. |
Raises:
Type | Description |
---|---|
ApiError
|
Checkout request failed. |
Source code in tenduke_scale/license_checkout/metered_license_checkout_client.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
TokenStoreABC
¶
Bases: ABC
License token store base class.
This type defines the methods that will be used to read, persist, and delete license tokens.
These methods are called by :class:tenduke_scale.license_checkout.LicenseCheckoutClientABC
and its subclasses to load, store, and delete
:class:tenduke_scale.license_checkout.LicenseToken
instances based on the operations called on
the client.
Source code in tenduke_scale/license_checkout/token_store.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
load()
abstractmethod
¶
Load any currently stored LicenseTokens.
Returns:
Type | Description |
---|---|
Sequence[LicenseToken]
|
The sequence of LicenseTokens currently stored or persisted in the token store. |
Source code in tenduke_scale/license_checkout/token_store.py
45 46 47 48 49 50 51 |
|
remove(to_remove)
¶
Remove the specified LicenseTokens, by lease id or by token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_remove
|
Union[Sequence[str], Sequence[LicenseToken]]
|
List of lease ids or tokens to remove from the store. |
required |
Source code in tenduke_scale/license_checkout/token_store.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
remove_all()
abstractmethod
¶
Clear the contents of the store.
Source code in tenduke_scale/license_checkout/token_store.py
53 54 55 |
|
save(tokens)
abstractmethod
¶
Save LicenseTokens to the store.
This operation should be additive.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tokens
|
Sequence[LicenseToken]
|
List of tokens to save. This should be interpretted as replacing the current contents of the store. |
required |
Source code in tenduke_scale/license_checkout/token_store.py
34 35 36 37 38 39 40 41 42 43 |
|
update(tokens)
¶
Store the new tokens and remove old tokens that there are new checkouts for.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tokens
|
Sequence[LicenseToken]
|
List of new tokens to add to the store, replacing any previously held tokens that are superseded. |
required |
Source code in tenduke_scale/license_checkout/token_store.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
Licensing model types¶
Common models used in the License Checkout API client and other API clients can be found in the [tenduke_scale.licensing] module.
Licensing types common to checkout and license management.
ConsumerType
¶
Bases: Enum
Consumer type enumeration.
Used to indicate if this is an individual or not. All types except PERSON behave in the same way in the API.
Source code in tenduke_scale/licensing/consumer_type.py
6 7 8 9 10 11 12 13 14 15 16 |
|
EffectiveProductConfigInfo
dataclass
¶
Bases: Model
Model for product configuration information.
Attributes:
Name | Type | Description |
---|---|---|
features |
Sequence[str]
|
Formal names of the enabled features in the configuration. |
license_model_id |
UUID
|
Unique id of the license model. |
license_model_name |
str
|
Formal name of the license model. |
product_config_display_name |
str
|
Display name of the product configuration. |
product_config_id |
UUID
|
Unique id of the product configuration. |
product_config_name |
str
|
Formal name of the product configuration. |
product_display_name |
str
|
Display name of the product. |
product_id |
UUID
|
Unique id of the product. |
product_name |
str
|
Formal name of the product. |
quantity_dimension |
QD
|
Enum: "SEATS" "USE_COUNT" "USE_TIME". Dimension of the quantity that licenses granted based on the product configuration have. Units of measurement: seats and use count = unitless, use time = seconds. |
created |
Optional[datetime]
|
When the product configuration was created. |
id |
Optional[UUID]
|
Unique id of the product configuration. |
modified |
Optional[datetime]
|
When the product configuration was last modified. |
Source code in tenduke_scale/licensing/effective_product_config_info.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
License
dataclass
¶
Bases: Model
Model for license object.
Attributes:
Name | Type | Description |
---|---|---|
product_name |
str
|
|
quantity_dimension |
QD
|
|
quantity_enforcement_type |
QET
|
|
allowed_version_lower_bound |
Optional[str]
|
Lower bound of allowed client application version. A null and empty value is interpreted as version = undefined (any version allowed). Note: version identifiers are compared by their natural sort order to determine if one version is more or less than another being compared to. |
allowed_version_upper_bound |
Optional[str]
|
Upper bound of allowed client application version. A null and empty value is interpreted as version = undefined (any version allowed). |
concurrent_user_app_instances_per_seat |
Optional[int]
|
Defines maximum concurrent application instances per user per seat. Becomes effective if value is > 0. Application instance maps usually to an operating system process. NOTE: requires cliProcessId claim to be sent by client application checking out a license. |
created |
Optional[datetime]
|
When the license was created. |
display_name |
Optional[str]
|
License name in the format that can be used for presentation purposes. |
feature_names |
Optional[str]
|
List of feature names the license enables. |
features |
Optional[Sequence[LicenseFeature]]
|
List of features this license enables. Note that the feature list may be empty and a minimum viable license works on basis of a product name |
id |
Optional[UUID]
|
Unique id of the license. |
license_key |
Optional[LicenseKey]
|
List of features this license enables. Note that the feature list may be empty and a minimum viable license works on basis of a product name. |
license_metadata |
Optional[LicenseMetadata]
|
Information about the license and associations it has. This object is not present by default. To include metadata in a license read or list response the caller must ask for it. |
modified |
Optional[datetime]
|
When the license was last modified. |
quantity |
Optional[int]
|
The pure numerical part of quantity assigned to a license. Maximum qty = 1000 when qtyDimension = SEATS. Note: qty = -1 denotes metered use license and is not applicable for licenses that function in enforcing mode. |
valid_from |
Optional[datetime]
|
Defines date-time when license(s) validity starts. |
valid_until |
Optional[datetime]
|
Defines date-time when license(s) expires. |
Source code in tenduke_scale/licensing/license.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
LicenseConsumer
dataclass
¶
Bases: Model
Represents an entity that consumes and/or owns licenses.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Technical name which carries significance for finding and matching data. |
type |
CT
|
Enum: "DEVICE" "LICENSE_KEY" "PERSON". |
connected_identity_id |
Optional[str]
|
Optional identifier of an identity domain entity that this object maps to. The most common example is a user id, meaning the OIDC subject value in Id Tokens. The sub claim is used to match license consumer entities in licensing when using Id Token to authorize API calls. This id field may also denote a computer component or device (technical actor generally). In this case the license consumer type would also indicate a non human type. |
contact_info |
Optional[str]
|
Optional contact information data to store with identity type objects. |
created |
Optional[datetime]
|
When the consumer object was created. |
description |
Optional[str]
|
Optional description. |
display_label |
Optional[str]
|
Optional label intended to be used for presentation purposes. |
display_name |
Optional[str]
|
Optional name intended to be used for presentation purposes. |
email |
Optional[str]
|
Optional email address, value must be unique when specified. |
external_reference |
Optional[str]
|
Optional reference field that helps associate licensing data with data in other systems. NOTE: value must be unique per object (null allowed). |
id |
Optional[UUID]
|
Unique id for license consumer. |
modified |
Optional[datetime]
|
When the license consumer was last modified. |
natural_id |
Optional[str]
|
A unique natural id for the licensee. The value may be e.g. a customer account id, company VAT id, a user identifier or any unique value that makes sense in the system that owns customer master data records. If value is not provided it will be generated. |
Source code in tenduke_scale/licensing/license_consumer.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
LicenseContainer
dataclass
¶
Bases: Model
License container model.
Attributes:
Name | Type | Description |
---|---|---|
created |
Optional[datetime]
|
When the license container was created. |
id |
Optional[UUID]
|
Unique id of the license container. |
modified |
Optional[datetime]
|
When the license container was last modified. |
name |
Optional[str]
|
Name to identify license container. |
used_as_default |
Optional[bool]
|
Indicates if this is the default container for the licensee. |
Source code in tenduke_scale/licensing/license_container.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
LicenseFeature
dataclass
¶
Bases: Model
License feature model.
Attributes:
Name | Type | Description |
---|---|---|
created |
Optional[datetime]
|
When was the feature created. |
feature |
Optional[str]
|
Name of the feature. |
id |
Optional[UUID]
|
Unique id of the feature. |
modified |
Optional[datetime]
|
When was the feature last modified. |
Source code in tenduke_scale/licensing/license_feature.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
LicenseKey
dataclass
¶
Bases: Model
License key model.
Attributes:
Name | Type | Description |
---|---|---|
license_key |
str
|
License key string representation for use in API calls. |
allowed_activations |
Optional[int]
|
Number of activation codes allowed for the license key. |
created |
Optional[datetime]
|
When the license key was created. |
id |
Optional[UUID]
|
Unique id for the license key. |
modified |
Optional[datetime]
|
When the license key was last modified. |
Source code in tenduke_scale/licensing/license_key.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
LicenseMetadata
dataclass
¶
Bases: Model
License metadata model.
Attributes:
Name | Type | Description |
---|---|---|
contract_reference |
Optional[str]
|
Optional reference field that associates a license with an external contract id. This field is present and has a value if it was included in the request when issuing the license. |
license_container |
Optional[LicenseContainer]
|
The license container that the license(s) are contained by. |
license_model |
Optional[LicenseModel]
|
The license model that was assigned to the license(s) on creation. |
order_reference |
Optional[str]
|
Optional reference field that associates a license with an external order id. This field is present and has a value if it was included in the request when issuing the license. |
product_config_info |
Optional[EffectiveProductConfigInfo]
|
Optional product configuration information that was used as specification to issue the new licenses. This object is null or missing if issuing licenses was done by dynamic product name and features. |
product_reference |
Optional[str]
|
Optional reference field that associates a license with an external product id. This field is present and has a value if it was included in the request when issuing the license. |
subscription_reference |
Optional[str]
|
Optional reference field that associates a license with an external subscription id. This field is present and has a value if it was included in the request when issuing the license. |
Source code in tenduke_scale/licensing/license_metadata.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
LicenseModel
dataclass
¶
Bases: Model
Model for License model object.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the license model. |
concurrent_user_app_instances_per_seat |
Optional[int]
|
Defines maximum concurrent application instances per user per seat. Becomes effective if value is > 0. Application instance maps usually to an operating system process. NOTE: requires cliProcessId claim to be sent by client application checking out a license. |
concurrent_user_devices_per_seat |
Optional[int]
|
Defines maximum concurrent devices per user per seat. Becomes effective if value is > 0 . Device instance maps usually to a work station, laptop, mobile device or similar. NOTE: requires cliHwId claim to be sent by client application when checking out a license. |
created |
Optional[datetime]
|
When the license model was created. |
id |
Optional[UUID]
|
Unique id of the license model. |
max_assignments_per_user |
Optional[int]
|
Defines maximum number of license consumptions (assignments) that a user can have per license. |
modified |
Optional[datetime]
|
When the license model was last modified. |
Source code in tenduke_scale/licensing/license_model.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
QuantityDimension
¶
Bases: Enum
Quantity dimension enumeration.
Source code in tenduke_scale/licensing/quantity_dimension.py
6 7 8 9 10 11 |
|
QuantityEnforcementType
¶
Bases: Enum
Quantity enforcement type enumeration.
Source code in tenduke_scale/licensing/quantity_enforcement_type.py
6 7 8 9 10 |
|
Utilities¶
Some utility classes are provided to help build the arguments for API calls.
Options for describing licenses and client bindings¶
Various describe API methods (for listing licenses and client bindings) accept optional query parameters controlling the data included in the response.
This type is used to set those options as required.
Bases: Model
Model for arguments to describe license operations.
Attributes:
Name | Type | Description |
---|---|---|
filter_field |
Optional[str]
|
Name of field to apply filter value on. Valid fields depend on object tyoe returned by call. |
filter_value |
Optional[str]
|
Filter value to apply on licenses. |
with_metadata |
Optional[bool]
|
Flag to control including verbose information about the licenses and client bindings. Setting this option to true will fetch contract, order, subscription and external reference information at time of original license grant, the license container, a possible license key and related product information. For client bindings the additional information is related to license consumption objects and license consumers. Defaults to false. |
Source code in tenduke_scale/describe_license_options.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
to_query_string()
¶
Convert object to query string fragment.
Returns:
Type | Description |
---|---|
str
|
Attributes of object formatted for inclusion in the query string of an HTTP request to |
str
|
the API. |
Source code in tenduke_scale/describe_license_options.py
38 39 40 41 42 43 44 45 46 47 |
|
Paging and ordering response data¶
When calling describe API methods to list licensees, licenses, or client bindings the matching data can include many records.
tenduke_scale.PagingOptions is provided to allow the caller to control the order and the paging of the response data.
Bases: Model
Paging args for API calls.
Any fields that are not None
are added as headers to the API call.
Attributes:
Name | Type | Description |
---|---|---|
offset |
Optional[int]
|
Offset for paging results. Defaults to 0. Applies to licenses, not the additional information included when parameter withMetadata == true. |
limit |
Optional[int]
|
Limit for controlling result size. Defaults to 5. Applies to licenses, not the additional information included when parameter withMetadata == true. |
order_by |
Optional[str]
|
Field name to order results by. Valid fields depend on object tyoe returned by call. |
order_asc |
Optional[bool]
|
Flag that controls ordering in ascending vs. descending order. Defaults to false, meaning descending order. |
Source code in tenduke_scale/paging.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
Filter and order by fields¶
See note below for the valid values for the filter_field
and order_by
attributes.
Note
The fields that can be used to order the results depend on type of objects returned.
Client bindings can be filtered or ordered by one of:
- cliCountry
- cliHwArch
- cliLang
- cliHostName
- cliHwId
- cliInstallationId
- cliNetworkIpAddress
- cliOs
- cliOSUserName
- cliProcessId
- cliVersion
- requestIpAddress
- validFrom (default)
- validUntil
Licensees can be filtered or ordered by one of:
- displayName
- name
- naturalId (default)
- externalReference
Licenses can be filtered or ordered by one of:
- productName
- displayName
- allowedVersionLowerBound
- allowedVersionUpperBound
- allowedVersionsDisplayName
- qty
- validFrom (default)
- validUntil
Core API¶
The following types are defined in 10Duke core library for Python:
Authentication and Authorization.
Includes helpers for authenticating with Open ID Connect and OAuth and authorization providers for 10Duke API calls.
BearerTokenAuth
¶
Bases: AuthBase
Bearer Token Auth hook - used with OAuth client to connect applications.
Source code in tenduke_core/auth/auth_provider.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
__call__(r)
¶
Mutate outgoing request (adding authorization header).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r
|
PreparedRequest
|
Outgoing request. |
required |
Source code in tenduke_core/auth/auth_provider.py
27 28 29 30 31 32 33 34 |
|
__eq__(other)
¶
Return True if instances are equal; otherwise False.
Equality is tested by retrieving the bearer token for each instance and comparing them.
Source code in tenduke_core/auth/auth_provider.py
36 37 38 39 40 41 42 43 44 |
|
__init__(token_callable)
¶
Construct an IdTokenAuth provider (hook).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token_callable
|
Callable[[], str]
|
A callable that returns the latest id_token. |
required |
Source code in tenduke_core/auth/auth_provider.py
17 18 19 20 21 22 23 24 25 |
|
__ne__(other)
¶
Return True if instances are not equal; otherwise False.
Equality is tested by retrieving the id_token for each instance and comparing them.
Source code in tenduke_core/auth/auth_provider.py
46 47 48 49 50 51 |
|
DeviceAuthorizationResponse
dataclass
¶
Data from Device Authorization Response.
Callers should use this data to initiate the user interaction phase of the Device Authorization Grant flow, before or simultaneously with starting polling for the token.
See https://www.rfc-editor.org/rfc/rfc8628#section-3.2.
Attributes:
Name | Type | Description |
---|---|---|
user_code |
str
|
The end-user verification code. |
uri |
str
|
The end-user verification URI on the authorization server. The URI should be short and easy to remember as end users will be asked to manually type it into their user agent. |
uri_complete |
Optional[str]
|
A verification URI that includes the "user_code" (or other information with the same function as the "user_code"), which is designed for non-textual transmission. |
Source code in tenduke_core/auth/device_auth_response.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
DeviceFlowClient
¶
Bases: OAuthClient
Helper class to perform OAuth device flow.
Source code in tenduke_core/auth/device_flow_client.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
VerificationUri
¶
Verification URI/URL handling.
As some implementations of device flow use URI and some use URL in the parameter name, we need to check for both. The logic in making the requests is that we should use the '_complete' variant of the URI if it is present/populated and use the incomplete version if it is not.
Source code in tenduke_core/auth/device_flow_client.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
__init__()
¶
Construct a VerificationUri instance.
Source code in tenduke_core/auth/device_flow_client.py
54 55 56 57 58 59 |
|
read_from_dict(data)
¶
Read the verification uri details from a dictionary.
RFC8628 specifies verification_uri. At least one identity provider in the wild sends verification_url. Outside of this class, we don't need to worry about verification_url, this class will read whichever is present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Dict[str, str]
|
The contents of the Device Authorization Response. |
required |
Source code in tenduke_core/auth/device_flow_client.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
uri()
¶
Return the token poll uri.
Source code in tenduke_core/auth/device_flow_client.py
77 78 79 |
|
uri_complete()
¶
Return the token poll complete uri.
Source code in tenduke_core/auth/device_flow_client.py
81 82 83 84 85 86 87 88 |
|
__init__(config, session_factory)
¶
Construct an instance of the DeviceFlowClient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
TendukeConfig
|
Configuration parameters for interacting with the OAuth / Open ID Authorization Server. |
required |
session_factory
|
SessionFactory
|
Used to create requests Session configured with the settings from config and with the configured User-Agent header value. |
required |
Source code in tenduke_core/auth/device_flow_client.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
authorize()
¶
Make the authorization request and return the details to display to the user.
Returns:
Type | Description |
---|---|
DeviceAuthorizationResponse
|
A DeviceAuthorizationResponse object containing the code and uri needed to fetch a |
DeviceAuthorizationResponse
|
token. |
Raises:
Type | Description |
---|---|
ValueError
|
Required configuration item idp_oauth_device_code_url was missing. |
OAuth2Error
|
Device Authorization Request was unsuccessful. |
Source code in tenduke_core/auth/device_flow_client.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
poll_for_token()
¶
Poll for an OAuth device flow token.
The method waits for the specified interval between attempts. This method is synchronous (blocking).
Raises:
Type | Description |
---|---|
OAuth2Error
|
Device Access Token Request was unsuccessful. |
Source code in tenduke_core/auth/device_flow_client.py
168 169 170 171 172 173 174 175 176 177 |
|
poll_for_token_async()
async
¶
Poll for an OAuth device flow token.
The method waits for the specified interval between attempts. This method is asynchronous (non-blocking).
Raises:
Type | Description |
---|---|
OAuth2Error
|
Device Access Token Request was unsuccessful. |
Source code in tenduke_core/auth/device_flow_client.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
IdTokenAuth
¶
Bases: AuthBase
ID Token Auth hook - used with Open ID Connect in public applications.
Source code in tenduke_core/auth/auth_provider.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
__call__(r)
¶
Mutate outgoing request (adding authorization header).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r
|
PreparedRequest
|
Outgoing request. |
required |
Source code in tenduke_core/auth/auth_provider.py
67 68 69 70 71 72 73 74 |
|
__eq__(other)
¶
Return True if instances are equal; otherwise False.
Equality is tested by retrieving the id_token for each instance and comparing them.
Source code in tenduke_core/auth/auth_provider.py
76 77 78 79 80 81 82 83 84 |
|
__init__(id_token_callable)
¶
Construct an IdTokenAuth provider (hook).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_token_callable
|
Callable[[], str]
|
A callable that returns the latest id_token. |
required |
Source code in tenduke_core/auth/auth_provider.py
57 58 59 60 61 62 63 64 65 |
|
__ne__(other)
¶
Return True if instances are not equal; otherwise False.
Equality is tested by retrieving the id_token for each instance and comparing them.
Source code in tenduke_core/auth/auth_provider.py
86 87 88 89 90 91 |
|
OAuthClient
¶
OAuth / Open ID Connect client.
Source code in tenduke_core/auth/oauth_client.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
id_token: Optional[str]
property
¶
The current identity token (if any).
token: Optional[TokenResponse]
property
writable
¶
The current token response.
__init__(config, session_factory)
¶
Construct an instance of the OAuth Client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
TendukeConfig
|
Configuration parameters for interacting with the OAuth / Open ID Authorization Server. |
required |
session_factory
|
SessionFactory
|
Used to create requests Session configured with the settings from config and with the configured User-Agent header value. |
required |
Source code in tenduke_core/auth/oauth_client.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
auth()
¶
Get an authorization implementation based on the current identity.
Returns:
Type | Description |
---|---|
IdTokenAuth
|
An authorization provider hook that sets the authorization header of HTTP requests |
IdTokenAuth
|
using the current id_token. |
Source code in tenduke_core/auth/oauth_client.py
156 157 158 159 160 161 162 163 164 165 166 |
|
get_user_info()
¶
Retrieve the details of the user from the userinfo endpoint.
Returns:
Type | Description |
---|---|
UserInfo
|
The information for the authenticated user. |
Raises:
Type | Description |
---|---|
ValueError
|
User info URL missing from configuration. |
OAuth2Error
|
The user info request was unsuccessful. |
Source code in tenduke_core/auth/oauth_client.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
PkceFlowClient
¶
Bases: OAuthClient
Client for Proof Key for Code Exchange (PKCE) flow.
Source code in tenduke_core/auth/pkce_flow_client.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
RedirectHandler
¶
Bases: BaseHTTPRequestHandler
Handler class for redirect with code.
Source code in tenduke_core/auth/pkce_flow_client.py
66 67 68 69 70 71 72 73 |
|
do_GET()
¶
Handle OAuth redirect.
Source code in tenduke_core/auth/pkce_flow_client.py
69 70 71 72 73 |
|
RedirectHttpServer
¶
Bases: HTTPServer
HTTP Server to handle redirect with code.
Source code in tenduke_core/auth/pkce_flow_client.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
__init__(*args, success_http=AUTH_SUCCESS_MESSAGE, **kwargs)
¶
Construct an instance of the HTTP Server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
success_http
|
Optional[str]
|
HTTP message to send once redirect request is received. |
AUTH_SUCCESS_MESSAGE
|
Source code in tenduke_core/auth/pkce_flow_client.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
__init__(config, session_factory, *args, **kwargs)
¶
Construct an instance of the PkceFlowClient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
TendukeConfig
|
Configuration parameters for interacting with the OAuth / Open ID Authorization Server. |
required |
session_factory
|
SessionFactory
|
Used to create requests Session configured with the settings from config and with the configured User-Agent header value. |
required |
Source code in tenduke_core/auth/pkce_flow_client.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
create_authorization_url(port=None)
¶
Generate and return authorization url.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
Optional[int]
|
The port number to use in the redirect URI |
None
|
Returns:
Type | Description |
---|---|
str
|
URL for authorization request. |
Source code in tenduke_core/auth/pkce_flow_client.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
fetch_token(authorization_response, port=None)
¶
Fetch token based on authorization response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
authorization_response
|
Optional[str]
|
Redirect URL request with authorization code to exchange for token. |
required |
Returns:
Type | Description |
---|---|
TokenResponse
|
TokenResponse object for the authorization code in the authorization_reponse parameter. |
Source code in tenduke_core/auth/pkce_flow_client.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
login_with_default_browser()
¶
Launch system default browser for user to log in.
Returns:
Type | Description |
---|---|
TokenResponse
|
TokenResponse object with token for the authenticated user. |
Raises:
Type | Description |
---|---|
OAuth2Error
|
Authentication failed. |
Source code in tenduke_core/auth/pkce_flow_client.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
TokenResponse
dataclass
¶
Bases: Model
Token response data model.
https://www.rfc-editor.org/rfc/rfc6749#section-4.2.2
Attributes:
Name | Type | Description |
---|---|---|
access_token |
str
|
The access token issued by the authorization server. |
token_type |
str
|
The type of the token issued. |
expires_in |
int
|
The lifetime in seconds of the access token. |
expires_at |
datetime
|
The datetime when the token will expire Derived from expires_in and the current system time when the token was received. |
refresh_token |
Optional[str]
|
The refresh token, which can be used to obtain new access tokens. |
id_token |
Optional[str]
|
ID Token value associated with the authenticated session. |
Source code in tenduke_core/auth/token_response.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
__post_init__()
¶
Initialize expires_at based on expires_in and current time.
Source code in tenduke_core/auth/token_response.py
39 40 41 42 43 |
|
UserInfo
dataclass
¶
Bases: Model
User info response data model.
Attributes:
Name | Type | Description |
---|---|---|
sub |
str
|
Subject identitfier. A locally unique and never reassigned identifier within the issuer for the End-User. |
name |
Optional[str]
|
End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences. |
given_name |
Optional[str]
|
Given name(s) or first name(s) of the End-User. Note that in some cultures, people can have multiple given names; all can be present, with the names being separated by space characters. |
family_name |
Optional[str]
|
Surname(s) or last name(s) of the End-User. Note that in some cultures, people can have multiple family names or no family name; all can be present, with the names being separated by space characters. |
email |
Optional[str]
|
End-User's preferred e-mail address. |
formatted_name |
Optional[str]
|
Combination of names for display purposes. Shall contain a value if any identifier is populated. |
Source code in tenduke_core/auth/user_info.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
__post_init__()
¶
Initialize formatted name based on other values.
Source code in tenduke_core/auth/user_info.py
41 42 43 44 45 46 |
|
Configuration data for 10Duke API and OAuth interactions.
TendukeConfig
dataclass
¶
Configuration properties for interacting with licensing and oauth / open ID connect.
Attributes:
Name | Type | Description |
---|---|---|
token_path |
str
|
Location on disk to save license tokens. |
public_key_path |
str
|
Location on disk to save public keys. |
licensing_api_url |
str
|
Protocol and host name for API tenant. |
token_refresh_leeway_seconds |
float
|
The number of seconds before expiry time that an ID Token or JWT will be automatically refreshed. |
http_timeout_seconds |
float
|
Timeout for HTTP requests. |
licensing_api_authorization_model |
Optional[str]
|
Method of authorization used for API calls. |
idp_oidc_discovery_url |
Optional[str]
|
Used to retrieve the details of the Open ID Connect endpoints for the identity provider. |
idp_oauth_authorization_url |
Optional[str]
|
Endpoint for Authorization Request in Authorization Code or Implicit Grant flows. |
idp_oauth_device_code_url |
Optional[str]
|
Endpoint for Device Authorization Request in Device Authorization Grant flow. |
idp_oauth_token_url |
Optional[str]
|
Endpoint for Access Token Request or Device Access Token Request. |
idp_oauth_client_id |
Optional[str]
|
Application credentials for OAuth/Open ID Connect. |
idp_userinfo_url |
Optional[str]
|
Endpoint handling the UserInfo Request. |
idp_oauth_client_secret |
Optional[str]
|
Application credentials for OAuth/Open ID Connect. Required for some OAuth flows or for some Identity Providers. |
idp_oauth_scope |
Optional[str]
|
Scopes to include in the Access and ID tokens requested via Open ID Connect. |
idp_jwks_uri |
Optional[str]
|
URL path to read public key used to verify JWTs received from Authorization Server authenticating Open ID Connect session. |
auth_redirect_uri |
Optional[str]
|
Fully specified URL for OAuth redirect_uri to listen for redirect during PKCE Flow. |
auth_redirect_path |
str
|
Redirect path fragment to listen for redirect during PKCE Flow. For desktop clients, this path will be appended to http://localhost (either on the specified port or a random ephemeral port). This fragment is ignored if auth_redirect_uri is specified. |
auth_redirect_port |
int
|
Local redirect port to listen on for PKCE Flow Client. |
auth_success_message |
Optional[str]
|
File containing response for successful login (see PKCE Flow Client). |
https_proxy |
Optional[str]
|
Proxy to use for HTTPS requests. |
Source code in tenduke_core/config/tenduke_config.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
load(prefix=None, file_name=None, **kwargs)
classmethod
¶
Load the configuration.
Priority order for configuration values: - environment variables - configuration file - kwargs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix
|
Optional[str]
|
Optionally override default prefix for environment variables. |
None
|
file_name
|
Optional[str]
|
Configuration file to load. |
None
|
Source code in tenduke_core/config/tenduke_config.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|