Official Python SDK for Plystra.
Project description
plystra
Official Python SDK for Plystra Core v1.0.
PyPI package name: plystra
Repository name: plystra/python-sdk
Requires Python 3.10 or newer.
Install
pip install plystra
Synchronous Usage
For production backend code, prefer passing a server-side access token or API key that was issued outside the request path. Keep password login available for admin tools and bootstrap flows, not for routine service-to-service checks.
Using an API key:
from plystra import Plystra
with Plystra("https://plystra.internal", api_key="ply_ak_...") as plystra:
decision = plystra.authz.check(
actor={
"user_id": "user_alice",
"space_id": "space_acme",
"member_id": "member_finance_reviewer",
"user_member_id": "um_alice_finance_reviewer",
},
resource_type="invoice",
resource_id="invoice_001",
action="approve",
)
Using an access token received from your frontend or gateway session:
from plystra import Plystra
with Plystra("https://plystra.internal", access_token=session["plystra_access_token"]) as plystra:
print(plystra.authz.check(action="approve", resource_type="invoice", resource_id="invoice_001"))
Access-token calls may omit actor; Core uses the token's active actor. API key calls must pass the nested actor explicitly.
Attach an application request id to a group of calls with with_request_id:
from plystra import Plystra
with Plystra("https://plystra.internal", access_token=session["plystra_access_token"]) as plystra:
scoped = plystra.with_request_id("req_01HY...")
decision = scoped.authz.check(
resource_type="invoice",
resource_id="invoice_001",
action="approve",
)
Password login is still supported:
from plystra import Plystra
with Plystra("http://localhost:8080") as plystra:
plystra.auth.login("alice@example.com", "plystra-demo")
# Core rotates refresh tokens. Omitting the argument uses the stored one.
plystra.auth.refresh()
decision = plystra.authz.check(
actor={
"user_id": "user_alice",
"space_id": "space_acme",
"member_id": "member_finance_reviewer",
"user_member_id": "um_alice_finance_reviewer",
},
resource_type="invoice",
resource_id="invoice_001",
action="approve",
)
print(decision["decision"])
Registration is disabled by default in Core. When an operator enables it and gives you a registration token:
with Plystra("https://plystra.internal") as plystra:
plystra.auth.register(
email="founder@example.com",
password="long-enough-password",
space_name="Founder Space",
registration_token=registration_token,
)
Asynchronous Usage
import asyncio
from plystra import AsyncPlystra
async def main() -> None:
async with AsyncPlystra("https://plystra.internal", api_key="ply_ak_...") as plystra:
decision = await plystra.authz.check(
actor={
"user_id": "user_alice",
"space_id": "space_acme",
"member_id": "member_finance_reviewer",
"user_member_id": "um_alice_finance_reviewer",
},
resource_type="invoice",
resource_id="invoice_001",
action="approve",
)
print(decision["decision"])
asyncio.run(main())
Modules
The SDK exposes v1.0 Core modules as attributes:
systemauthactoradminapi_keysusersspacesgroupsmembersuser_membersrolesmember_rolespermissionsrole_permissionsresource_typesresourcesauthzauditdatapluginstemplates
Non-public endpoints require either a Bearer session whose user has an active admin grant or a scoped API key with matching permission keys.
Keep SDK tokens in a server-side encrypted session store. login() and refresh() update access_token and refresh_token on the client; call plystra.tokens() when you need to persist the rotated token pair.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plystra-1.0.0rc6.tar.gz.
File metadata
- Download URL: plystra-1.0.0rc6.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ab332905f114365cb0c0b92bf7d44e69fc5e285b39152f9848ab44de896e16e
|
|
| MD5 |
80f5eb1e4fe41f1def61d07b2f88efaf
|
|
| BLAKE2b-256 |
1b3f7439b5fdbd656ce30e8e3d85a200a48f030bfd0ecda29f9696fea8571465
|
Provenance
The following attestation bundles were made for plystra-1.0.0rc6.tar.gz:
Publisher:
publish.yml on plystra/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plystra-1.0.0rc6.tar.gz -
Subject digest:
1ab332905f114365cb0c0b92bf7d44e69fc5e285b39152f9848ab44de896e16e - Sigstore transparency entry: 1519475068
- Sigstore integration time:
-
Permalink:
plystra/python-sdk@d5ef91442f68bf70b58f1f0b4d230d0b15929d81 -
Branch / Tag:
refs/tags/v1.0.0-rc6 - Owner: https://github.com/plystra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5ef91442f68bf70b58f1f0b4d230d0b15929d81 -
Trigger Event:
push
-
Statement type:
File details
Details for the file plystra-1.0.0rc6-py3-none-any.whl.
File metadata
- Download URL: plystra-1.0.0rc6-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afca2e6cb68ad2ef578ce004eb5e4dc84f1d1aa4b997613f7934f753e9eb960b
|
|
| MD5 |
b5e4672310bdf66c29b9894fbfe6bf93
|
|
| BLAKE2b-256 |
f3c74bceb112971b93d5453b4670941117a073afde4707cd9edb084b60717993
|
Provenance
The following attestation bundles were made for plystra-1.0.0rc6-py3-none-any.whl:
Publisher:
publish.yml on plystra/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plystra-1.0.0rc6-py3-none-any.whl -
Subject digest:
afca2e6cb68ad2ef578ce004eb5e4dc84f1d1aa4b997613f7934f753e9eb960b - Sigstore transparency entry: 1519475097
- Sigstore integration time:
-
Permalink:
plystra/python-sdk@d5ef91442f68bf70b58f1f0b4d230d0b15929d81 -
Branch / Tag:
refs/tags/v1.0.0-rc6 - Owner: https://github.com/plystra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5ef91442f68bf70b58f1f0b4d230d0b15929d81 -
Trigger Event:
push
-
Statement type: