Skip to main content

Permguard Python SDK

The official synchronous Python client for the stateless Permguard PDP interface permguard.api.pdp.native.v1.

The same API supports both server bindings:

  • http:// and https:// use JSON;
  • grpc:// and grpcs:// use permguard.data.v1.PolicyDecisionPoint.

Installation

pip install permguard

Python 3.8 or newer is required.

Evaluate one request

from permguard import Action, Client, Entity, EvaluateRequest

with Client("grpc://localhost:7443") as client:
    response = client.evaluate(
        EvaluateRequest(
            zone="acme",
            ledger="documents",
            subject=Entity(type="user", id="amy@example.com"),
            resource=Entity(type="document", id="quarterly-report"),
            action=Action(name="read"),
        )
    )

print("permitted:", response.decision)

Use http://localhost:7443 to send the same request over HTTP/JSON. A deny is a successful response whose decision is False. Validation, authorization, availability, and server failures raise permguard.Refusal, preserving their stable class and code.

Partition inputs

Runtime data is addressed to the partition name declared by the ledger profile:

from permguard import PartitionInput

request.partition_inputs["authorization"] = PartitionInput(
    type="permguard.cedar.entities.v1",
    data=[
        {
            "uid": {"type": "Team", "id": "engineering"},
            "attrs": {"active": True},
            "parents": [],
        }
    ],
)

The key selects a partition already declared by the profile. The input type is checked against that declaration; it does not select a runtime.

Evaluate a batch

from permguard import (
    Action,
    Entity,
    EvaluateRequest,
    Evaluation,
    EvaluationOptions,
    EvaluationsSemantic,
)

response = client.evaluate_many(
    EvaluateRequest(
        zone="acme",
        ledger="documents",
        subject=Entity(type="user", id="amy@example.com"),
        evaluations=[
            Evaluation(
                resource=Entity(type="document", id="one"),
                action=Action(name="read"),
                request_id="one",
            ),
            Evaluation(
                resource=Entity(type="document", id="two"),
                action=Action(name="read"),
                request_id="two",
            ),
        ],
        options=EvaluationOptions(
            evaluations_semantic=EvaluationsSemantic.EXECUTE_ALL,
        ),
    )
)

Call client.get_configuration() to read the interface discovery document. The client reuses its HTTP connection or gRPC channel; use it as a context manager or call close().

Static HTTP headers and gRPC metadata can be supplied through headers. HTTPS accepts an ssl.SSLContext; gRPCS accepts grpc.ChannelCredentials.

Compatibility

This major version implements permguard.api.pdp.native.v1. Compatibility is tied to that versioned interface rather than to a server minor release.

Development and release

hatch run protoc
hatch run dev
hatch -e lint run all
hatch build

The existing tag-based PyPI workflow remains the release mechanism. The package version is still read from permguard/__about__.py and set from the release tag.

License

Apache License 2.0. See LICENSE and THIRD_PARTY_NOTICES.md.

Metadata

Release files for permguard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for permguard 0.1.0
File Size Uploaded
permguard-0.1.0.tar.gz 32.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for permguard 0.1.0
File Interpreter ABI Platform
permguard-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.5 kB

Release files / permguard-0.1.0.tar.gz

Download URL permguard-0.1.0.tar.gz
Size 32.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ed4311d0be6002f0b74af3449911d5ec236f848cd28fabae853644d7fabf7c1e
BLAKE2b-256 checksum
How to use checksums
d299b66c93b07247e0dd72e2cdbe2aa7a050ce2de2621e16e30497a694c796cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / permguard-0.1.0-py3-none-any.whl

Download URL permguard-0.1.0-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc22165b0ca8513e8723f60ab8133a6150f2b30ef2469180b706e8901ba398f4
BLAKE2b-256 checksum
How to use checksums
379793d9eb1711d65a716a134168394f0a4923acf39c58d464458c22e50d01de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.12

2 release files

0.0.11

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page