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",
actor_member_id="member_finance_reviewer",
actor_user_member_id="um_alice_finance_reviewer",
space_id="space_acme",
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"))
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"])
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",
actor_member_id="member_finance_reviewer",
actor_user_member_id="um_alice_finance_reviewer",
space_id="space_acme",
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.0.dev10.tar.gz.
File metadata
- Download URL: plystra-1.0.0.dev10.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
989836f1c2d56440b1f3e372e19c4dacc79519d8f5322d4be60cb218a415f233
|
|
| MD5 |
567e0fb654de192e9a1c498ed942b821
|
|
| BLAKE2b-256 |
cbff642358de9ca17d066305a4585000f3e8820117ee8f2e8d1d305e4ad45c7b
|
File details
Details for the file plystra-1.0.0.dev10-py3-none-any.whl.
File metadata
- Download URL: plystra-1.0.0.dev10-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a03160a76f3417e7f38d2777604953766f740e7d625d628825708a862cb376e5
|
|
| MD5 |
af96b73106cd56c45875bd6bf9b8417c
|
|
| BLAKE2b-256 |
2d856f6cbb4b20a788fd3e46f64dfa19b9e3c4d38acf899f558c839d3e75404b
|