Metadata-Version: 2.4
Name: yekta-sdk
Version: 0.1.0
Summary: Python SDK for the Yekta data catalog — credential vending, catalog browsing, access control
Project-URL: Homepage, https://github.com/Angelerator/yekta-sdk
Project-URL: Documentation, https://github.com/Angelerator/yekta-sdk#readme
Project-URL: Repository, https://github.com/Angelerator/yekta-sdk
Author: Yekta Team
License: Apache-2.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.0
Provides-Extra: all
Requires-Dist: deltalake>=0.20; extra == 'all'
Requires-Dist: duckdb>=1.0; extra == 'all'
Requires-Dist: fsspec>=2024.0; extra == 'all'
Requires-Dist: pandas>=2.0; extra == 'all'
Requires-Dist: polars>=1.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: duckdb
Requires-Dist: duckdb>=1.0; extra == 'duckdb'
Provides-Extra: pandas
Requires-Dist: fsspec>=2024.0; extra == 'pandas'
Requires-Dist: pandas>=2.0; extra == 'pandas'
Provides-Extra: polars
Requires-Dist: deltalake>=0.20; extra == 'polars'
Requires-Dist: polars>=1.0; extra == 'polars'
Description-Content-Type: text/markdown

# yekta-sdk

Python SDK for the **Yekta data catalog** — credential vending, catalog browsing, access control.

## Install

```bash
pip install yekta-sdk            # Core
pip install yekta-sdk[duckdb]    # + DuckDB integration
pip install yekta-sdk[polars]    # + Polars/Delta integration
pip install yekta-sdk[all]       # Everything
```

## Quick Start

### Browse the catalog

```python
from yekta import YektaClient

client = YektaClient.from_env()  # reads YEKTA_URL, YEKTA_TOKEN

# List resources
for r in client.ls("/dev/bronze"):
    print(f"{r.path} ({r.format})")

# Preview data
df = client.preview_df("/dev/bronze/memotech/patents", rows=100)
df.head()

# Schema
schema = client.schema("/dev/bronze/memotech/patents")
for col in schema.columns:
    print(f"  {col.name}: {col.data_type}")
```

### Get temporary credentials (the core feature)

```python
from yekta import CredentialVendor

vendor = CredentialVendor.from_env()  # reads SEPAR_URL, SEPAR_API_KEY

# Vend a short-lived, scoped SAS token
cred = vendor.vend(
    connection_id="019c479e-...",
    resource_path="dev/bronze/memotech/fabric/memotech_imt_patent",
)

print(cred.expires_at)  # 1 hour from now
print(cred.is_expired)  # False
```

### Use with DuckDB

```python
import duckdb

conn = duckdb.connect()
conn.execute(cred.duckdb_secret())

df = conn.sql("""
    SELECT country, COUNT(*) as cnt
    FROM delta_scan('az://dagster-data-pipelines/dev/bronze/.../memotech_imt_patent')
    GROUP BY country ORDER BY cnt DESC
""").df()
```

### Use with Polars

```python
import polars as pl

df = pl.read_delta(
    cred.abfss_uri(),
    storage_options=cred.storage_options(),
)
```

### Use with Spark

```python
for key, value in cred.spark_config().items():
    spark.conf.set(key, value)

df = spark.read.format("delta").load(cred.abfss_uri())
```

### Access control

```python
# List grants
for g in client.grants():
    print(f"{g.path_prefix} → {g.principal_id}: {g.permission}")

# Grant read access
client.grant("/dev/bronze", principal_id="user-uuid", permission="read")

# Revoke
client.revoke(grant_id="...")
```

## Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `YEKTA_URL` | `http://localhost:8081` | Yekta API URL |
| `YEKTA_TOKEN` | — | JWT token for authentication |
| `SEPAR_URL` | `http://localhost:8080` | Separ auth URL |
| `SEPAR_API_KEY` | — | API key for service-to-service auth |

## License

Apache-2.0
