Vortex Python SDK for invitation management and JWT generation
Project description
Vortex Python SDK
A Python SDK for Vortex invitation management and JWT generation.
Installation
pip install vortex-python-sdk
Note: The package will be available on PyPI once published. See PUBLISHING.md for publishing instructions.
Usage
Basic Setup
from vortex_sdk import Vortex
# Initialize the client with your Vortex API key
vortex = Vortex(api_key="your-vortex-api-key")
# Or with custom base URL
vortex = Vortex(api_key="your-vortex-api-key", base_url="https://custom-api.example.com")
JWT Generation
# Generate JWT for a user
user = {
"id": "user-123",
"email": "user@example.com",
"admin_scopes": ["autojoin"] # Optional - included as adminScopes array in JWT
}
jwt = vortex.generate_jwt(user=user)
print(f"JWT: {jwt}")
# With additional properties
jwt = vortex.generate_jwt(
user=user,
role="admin",
department="Engineering"
)
# Or using type-safe models
from vortex_sdk import User
user = User(
id="user-123",
email="user@example.com",
admin_scopes=["autojoin"]
)
jwt = vortex.generate_jwt(user=user)
Invitation Management
Get Invitations by Target
import asyncio
async def get_user_invitations():
# Async version
invitations = await vortex.get_invitations_by_target("email", "user@example.com")
for invitation in invitations:
print(f"Invitation ID: {invitation.id}, Status: {invitation.status}")
# Sync version
invitations = vortex.get_invitations_by_target_sync("email", "user@example.com")
Accept Invitations
async def accept_user_invitations():
# Async version
result = await vortex.accept_invitations(
invitation_ids=["inv1", "inv2"],
target={"type": "email", "value": "user@example.com"}
)
print(f"Result: {result}")
# Sync version
result = vortex.accept_invitations_sync(
invitation_ids=["inv1", "inv2"],
target={"type": "email", "value": "user@example.com"}
)
Get Specific Invitation
async def get_invitation():
# Async version
invitation = await vortex.get_invitation("invitation-id")
print(f"Invitation: {invitation.id}")
# Sync version
invitation = vortex.get_invitation_sync("invitation-id")
Revoke Invitation
async def revoke_invitation():
# Async version
result = await vortex.revoke_invitation("invitation-id")
print(f"Revoked: {result}")
# Sync version
result = vortex.revoke_invitation_sync("invitation-id")
Group Operations
Get Invitations by Group
async def get_group_invitations():
# Async version
invitations = await vortex.get_invitations_by_group("organization", "org123")
print(f"Found {len(invitations)} invitations")
# Sync version
invitations = vortex.get_invitations_by_group_sync("organization", "org123")
Delete Invitations by Group
async def delete_group_invitations():
# Async version
result = await vortex.delete_invitations_by_group("organization", "org123")
print(f"Deleted: {result}")
# Sync version
result = vortex.delete_invitations_by_group_sync("organization", "org123")
Reinvite
async def reinvite_user():
# Async version
invitation = await vortex.reinvite("invitation-id")
print(f"Reinvited: {invitation.id}")
# Sync version
invitation = vortex.reinvite_sync("invitation-id")
Context Manager Usage
# Async context manager
async with Vortex(api_key="your-api-key") as vortex:
invitations = await vortex.get_invitations_by_target("email", "user@example.com")
# Sync context manager
with Vortex(api_key="your-api-key") as vortex:
invitations = vortex.get_invitations_by_target_sync("email", "user@example.com")
Error Handling
from vortex_sdk import VortexApiError
try:
invitation = vortex.get_invitation_sync("invalid-id")
except VortexApiError as e:
print(f"API Error: {e.message} (Status: {e.status_code})")
except Exception as e:
print(f"Unexpected error: {e}")
Development
Installation
# Install development dependencies
pip install -e ".[dev]"
Running Tests
pytest
Code Formatting
# Format code
black src/ tests/
isort src/ tests/
# Lint code
ruff check src/ tests/
mypy src/
License
MIT
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
vortex_python_sdk-0.1.1.tar.gz
(11.0 kB
view details)
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 vortex_python_sdk-0.1.1.tar.gz.
File metadata
- Download URL: vortex_python_sdk-0.1.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dfbb9d957fdc728977bc3dd7b593e5aff6b00ab8f1923d9e923e4d9ad38a852
|
|
| MD5 |
0d28fe6164a9b0d9a1ad0e57b6422aaf
|
|
| BLAKE2b-256 |
aa9fc47eeeefc78c8dcb08b3ece3511f6f16f1030fd144b754227632485db4df
|
File details
Details for the file vortex_python_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: vortex_python_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47c2f1826c53306e665e28c823accfc0e122cd2b151b255c27916f7fdffa33d7
|
|
| MD5 |
d2fc078fdc3e64b311fb85b8b972e0d0
|
|
| BLAKE2b-256 |
7600aa68bbeab313b55db502be7bdfc7893d2794cb927a514a8eaa00c17f2407
|