Skip to content

PySafeguard 8.0 — Complete Pythonic redesign of the SDK#24

Merged
petrsnd merged 36 commits intomainfrom
feature/petrsnd/major-revision
Apr 28, 2026
Merged

PySafeguard 8.0 — Complete Pythonic redesign of the SDK#24
petrsnd merged 36 commits intomainfrom
feature/petrsnd/major-revision

Conversation

@petrsnd
Copy link
Copy Markdown
Member

@petrsnd petrsnd commented Apr 28, 2026

PySafeguard 8.0 — Complete Pythonic redesign of the SDK

Summary

This is a complete refactor of PySafeguard with a modern, Pythonic API. The version has been bumped to 8.0.0 to reflect the breaking changes. The README has been updated with a guide to upgrade existing code.

What changed

New SDK API

  • SafeguardClient / AsyncSafeguardClient replace PySafeguardConnection / Connection / AsyncConnection
  • Auth strategy objects (PasswordAuth, CertificateAuth, PkceAuth, TokenAuth) replace factory functions (connect_password, connect_certificate, etc.)
  • Typed HTTP verb methods (get, post, put, delete) replace the generic invoke() method
  • A2AContext / AsyncA2AContext replace the a2a_get_credential() class method
  • SafeguardEventListener / PersistentSafeguardEventListener replace register_signalr_*() with a fluent .on() API and context manager support
  • Structured error hierarchy (SafeguardErrorApiErrorAuthenticationError / AuthorizationError / NotFoundError) replaces flat exceptions
  • HiddenString for credential protection throughout
  • Streaming support: stream(), download(), upload()
  • Full type annotations passing mypy --strict

PKCE as recommended auth

  • PkceAuth is now the recommended authentication method — Resource Owner Grant (ROG) is disabled by default on recent Safeguard appliances
  • README updated to lead with PKCE examples and document the ROG change

Updated samples

  • All 10 sample scripts rewritten for the 8.0 API
  • Added new PkceExample.py

Modernized CI/CD pipeline

  • Restructured azure-pipelines.yml to match SafeguardDotNet patterns: template-based with separate PR validation and build/publish jobs
  • Added pipeline-templates/ with shared build steps (install, version, lint, type check, test, build)
  • Added versionnumber.ps1 that reads version from pyproject.toml (single source of truth) and applies .devN suffix for prerelease builds
  • CI now runs ruff check, ruff format --check, mypy, and pytest on every PR and merge
  • PyPI publish remains tag-gated

Tests

  • 257 unit tests covering client lifecycle, request logic, auth strategies, error hierarchy, A2A, events, PKCE, utilities, and public API surface
  • 154 integration tests for live appliance validation (client CRUD, A2A, events, streaming)

Migration

A full migration guide from 7.x to 8.0 is included at the bottom of README.md.

petrsnd added 30 commits April 27, 2026 17:15
petrsnd and others added 6 commits April 28, 2026 15:12
Azure Pipelines macro-expands variables as plain strings, so passing
$(isPrerelease) with $$ escaping to produce a PowerShell $True
literal doesn't work reliably (330771$(isPrerelease) becomes $$True).

Fix by:
- Passing variables as-is (no $$ escaping) in build-steps.yml
- Changing versionnumber.ps1 parameters from [bool]/implicit to [string]
- Converting to booleans inside the script with string comparison

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@petrsnd petrsnd merged commit 582bae4 into main Apr 28, 2026
2 checks passed
@petrsnd petrsnd deleted the feature/petrsnd/major-revision branch April 28, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant