Skip to content

Issue 23: Python SDK Core Client #23

Description

@laraibg786

Goal

Build a Python SDK package (permit-sdk) providing a typed API wrapper for the permit backend, with built-in retries, timeout handling, and error mapping. Customers import permit_sdk and call activate() and get_status() without managing HTTP details.

Requirements

Functional

  • PermitClient(api_key, api_url) initialization.
  • client.activate(license_key, device_fingerprint) → returns session token and policy snapshot.
  • client.get_status(session_token) → returns status enum (ACTIVE, GRACE, EXPIRED, REVOKED).
  • Retry on HTTP 5xx or timeout: up to 3 retries with exponential backoff (100ms, 200ms, 400ms).
  • Map API error codes to typed exceptions: ActivationError, SessionExpiredError, LicenseRevokedError.

Technical

  • Python: 3.11+.
  • Dependencies: httpx, pydantic.
  • Auth: API key in header Authorization: ApiKey {api_key}.
  • Timeout: 30 seconds per request.
  • Async: httpx.AsyncClient for async variant (activate_async()).
  • Package: PyPI-ready structure under sdk/.

Acceptance Criteria

  • activate() returns session token on success.
  • activate() raises ActivationError on 4xx.
  • Retries 3 times on 5xx before raising.
  • Async variant works with await client.activate_async(...).

Dependencies

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions