Python SDK for the Pragmatiks platform
Project description
Pragmatiks SDK
Documentation | CLI | Providers
Build providers and interact with the Pragmatiks platform programmatically.
Quick Start
from pragma_sdk import PragmaClient, Resource
with PragmaClient() as client:
# Apply a resource
client.apply_resource(
Resource(
provider="gcp",
resource="storage",
name="my-bucket",
config={"location": "US", "storage_class": "STANDARD"}
)
)
# Get resource status
bucket = client.get_resource("gcp", "storage", "my-bucket")
print(bucket.outputs)
Installation
pip install pragmatiks-sdk
Or with uv:
uv add pragmatiks-sdk
Features
- HTTP Clients - Sync and async clients for the Pragma API
- Provider Authoring - Build custom providers with type-safe Config and Outputs
- Field References - Reference outputs from other resources dynamically
- Testing Harness - Test provider lifecycle methods locally without deployment
- Auto-discovery - Automatic credential resolution from environment or config files
Building Providers
Define resources with typed configuration and lifecycle methods:
from pragma_sdk import Provider, Resource, Config, Outputs, Field
gcp = Provider(name="gcp")
class BucketConfig(Config):
location: Field[str]
storage_class: Field[str] = "STANDARD"
class BucketOutputs(Outputs):
url: str
created_at: str
@gcp.resource("storage")
class Bucket(Resource[BucketConfig, BucketOutputs]):
async def on_create(self) -> BucketOutputs:
# Provision the bucket
return BucketOutputs(url=f"gs://{self.name}", created_at="...")
async def on_update(self, previous_config: BucketConfig) -> BucketOutputs:
# Handle config changes
return self.outputs
async def on_delete(self) -> None:
# Clean up
pass
Field References
Reference outputs from other resources:
from pragma_sdk import FieldReference
config = AppConfig(
database_url=FieldReference(
provider="postgres",
resource="database",
name="my-db",
field="outputs.connection_url"
)
)
Testing Providers
Test lifecycle methods locally with ProviderHarness:
from pragma_sdk.provider import ProviderHarness
async def test_bucket_creation():
harness = ProviderHarness()
result = await harness.invoke_create(
Bucket,
name="test-bucket",
config=BucketConfig(location="US")
)
assert result.success
assert "gs://test-bucket" in result.outputs.url
Authentication
Credentials are discovered automatically:
- Explicit
auth_tokenparameter - Environment variable:
PRAGMA_AUTH_TOKEN - Credentials file:
~/.config/pragma/credentials
# Auto-discover credentials
client = PragmaClient()
# Explicit token
client = PragmaClient(auth_token="sk_...")
# Require authentication (fail if no token)
client = PragmaClient(require_auth=True)
API Reference
HTTP Client Methods
| Method | Description |
|---|---|
list_resources(provider, resource, tags) |
List resources with optional filters |
get_resource(provider, resource, name) |
Get a specific resource |
apply_resource(resource) |
Create or update a resource |
delete_resource(provider, resource, name) |
Delete a resource |
is_healthy() |
Check API health |
Provider Classes
| Class | Description |
|---|---|
Provider(name) |
Provider namespace with @provider.resource() decorator |
Resource[ConfigT, OutputsT] |
Base class with on_create, on_update, on_delete |
Config |
Base class for resource configuration (Pydantic model) |
Outputs |
Base class for resource outputs (Pydantic model) |
Field[T] |
Type alias for `T |
ProviderHarness |
Local testing harness |
Development
# Run tests
task sdk:test
# Format code
task sdk:format
# Type check and lint
task sdk:check
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
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 pragmatiks_sdk-0.4.0.tar.gz.
File metadata
- Download URL: pragmatiks_sdk-0.4.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8639dd5ca57f07e2d5b3a3ac51aa2e888ebd57037c0e030c48895fd1190995ca
|
|
| MD5 |
f7f4aba4ea30b1eff1194b6c2bc2d9f2
|
|
| BLAKE2b-256 |
c9eedbbae549847ec04adb2e2685f69da618c300dcba1c8fd9a2c90fe4519d65
|
Provenance
The following attestation bundles were made for pragmatiks_sdk-0.4.0.tar.gz:
Publisher:
publish.yaml on pragmatiks/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pragmatiks_sdk-0.4.0.tar.gz -
Subject digest:
8639dd5ca57f07e2d5b3a3ac51aa2e888ebd57037c0e030c48895fd1190995ca - Sigstore transparency entry: 821278950
- Sigstore integration time:
-
Permalink:
pragmatiks/sdk@396d89d2efce1a10105973f9e08ed97de734e1b9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pragmatiks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@396d89d2efce1a10105973f9e08ed97de734e1b9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pragmatiks_sdk-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pragmatiks_sdk-0.4.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55bfcf23f150d130076dc348a68fc88103bd17d9a88a58ffcedcce7f791ffd05
|
|
| MD5 |
73678c704c9651810454535f0fbd4a0a
|
|
| BLAKE2b-256 |
a8cee8db6347ef5ab58f581213bba61baea7fea30990031a7d67f8f741237568
|
Provenance
The following attestation bundles were made for pragmatiks_sdk-0.4.0-py3-none-any.whl:
Publisher:
publish.yaml on pragmatiks/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pragmatiks_sdk-0.4.0-py3-none-any.whl -
Subject digest:
55bfcf23f150d130076dc348a68fc88103bd17d9a88a58ffcedcce7f791ffd05 - Sigstore transparency entry: 821278962
- Sigstore integration time:
-
Permalink:
pragmatiks/sdk@396d89d2efce1a10105973f9e08ed97de734e1b9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pragmatiks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@396d89d2efce1a10105973f9e08ed97de734e1b9 -
Trigger Event:
push
-
Statement type: