Skip to main content

Python SDK for Permission Protocol authority receipts

Project description

Permission Protocol Python SDK

permission-protocol is the official Python SDK for requesting and verifying Permission Protocol authority receipts.

Installation

pip install permission-protocol

Quickstart

import permission_protocol as pp

pp.configure(api_key="pp_live_xxx", base_url="https://app.permissionprotocol.com")

receipt = pp.authorize(
    action="deploy",
    resource="billing-service",
    actor="deploy-bot",
    metadata={"pr": 42},
    wait=True,
    timeout=300,
)

print(receipt.id)
print(receipt.status)
print(receipt.json())

You can also skip configure() by setting PP_API_KEY (and optionally PP_BASE_URL) in the environment.

Decorator

from permission_protocol import require_approval

@require_approval(resource="billing-service")
def deploy_service():
    return "deploy complete"

When deploy_service() is called, the SDK creates an approval request, prints an approval URL, and blocks until approved or timed out.

Verify

import permission_protocol as pp

receipt = pp.verify(receipt_id="pp_r_8f91c2")
assert receipt.valid

Exceptions

The SDK raises these exceptions:

  • PermissionProtocolError
  • PermissionDenied
  • PermissionTimeout
  • AuthenticationError
  • APIError

Development

pip install -e .[dev]
pytest
python3 -c "import permission_protocol; print(permission_protocol.__version__)"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

permission_protocol-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

permission_protocol-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file permission_protocol-0.1.0.tar.gz.

File metadata

  • Download URL: permission_protocol-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for permission_protocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b337fe009a8458ff66ccf4de6592dd52cc8b9cd137b1a8554c39e69746e308f
MD5 4328dc81f76fc52e3cc53842e3e6476d
BLAKE2b-256 6779918f8e911b15ec5e57ffd206990e14adbd8863f4fcea503b3b0e7369ea5a

See more details on using hashes here.

File details

Details for the file permission_protocol-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for permission_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b672dcf350bcb8cc0dc3935cd8955f7e70a0e18a993cc50adb21d01a5ecef192
MD5 0dc041ee84e5a20dbc9d9357b530eadc
BLAKE2b-256 597054f6a058c43e8899c3c46975cc99de5c2fe327567b6f4cea6a18da458364

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page