Skip to content

License

Get information about the license

Code example
import asyncio

from ptsandbox import Sandbox
from ptsandbox.models import SandboxKey


async def main():
    sandbox = Sandbox(SandboxKey(...))

    await sandbox.ui.authorize()

    license = await sandbox.ui.get_license()
    print(license)

asyncio.run(main())

Check if the license has expired or not

import asyncio
from datetime import datetime, timezone

from ptsandbox import Sandbox
from ptsandbox.models import SandboxKey


async def main():
    key = SandboxKey(...)
    sandbox = Sandbox(key)

    await sandbox.ui.authorize()

    response = await sandbox.ui.get_license()
    if datetime.now(tz=timezone.utc) > response.data.license.expiration_time:
        print("License expired")
    else:
        print(f"License ok, expires in: {response.data.license.expiration_time}")


asyncio.run(main())

ptsandbox.sandbox.ui._system.SystemMixin.get_license async

get_license() -> SandboxLicenseResponse

Get the license status and details

Raises:

  • SandboxException

    if not authorized or token refresh fails

  • ClientResponseError

    if the server returns an error status

  • ClientError

    on connection or transport errors

  • ValidationError

    if the response body does not match the expected model

Update the current license

Code example
import asyncio

from ptsandbox import Sandbox
from ptsandbox.models import SandboxKey


async def main():
    sandbox = Sandbox(SandboxKey(...))

    await sandbox.ui.authorize()

    update_result = await sandbox.ui.update_license()
    print(update_result)

asyncio.run(main())

ptsandbox.sandbox.ui._system.SystemMixin.update_license async

update_license() -> SandboxLicenseUpdateResponse

Updating the current license

Raises:

  • SandboxException

    if not authorized or token refresh fails

  • ClientResponseError

    if the server returns an error status

  • ClientError

    on connection or transport errors

  • ValidationError

    if the response body does not match the expected model