Metadata-Version: 2.4
Name: g8kepr
Version: 1.0.0
Summary: G8KEPR API Security Platform - Python SDK
Author-email: Wesley Ellis <support@g8kepr.com>
License: Proprietary
Project-URL: Homepage, https://g8kepr.com
Project-URL: Documentation, https://docs.g8kepr.com/python-sdk
Project-URL: Repository, https://github.com/wesellis/Gatekeeper-6.8-SaaS-API-Security-Platform
Project-URL: Issues, https://github.com/wesellis/Gatekeeper-6.8-SaaS-API-Security-Platform/issues
Keywords: api,security,mcp,ai,agents,threat-detection
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"

# G8KEPR Python SDK

Official Python SDK for the G8KEPR API Security Platform.

## Installation

```bash
pip install g8kepr
```

## Quick Start

```python
from g8kepr import G8KEPRClient

# Initialize client
client = G8KEPRClient(
    base_url="https://api.g8kepr.com",
    api_key="your-api-key"
)

# Or authenticate with email/password
client.auth.login(email="user@example.com", password="...")

# List AI agents
agents = client.agents.list()
for agent in agents:
    print(f"Agent: {agent['name']} - Status: {agent['status']}")

# Get recent threats
threats = client.threats.get_recent(limit=10)
for threat in threats:
    print(f"Threat: {threat['type']} - Severity: {threat['severity']}")

# MCP server management
servers = client.mcp.list_servers()
```

## Features

### Authentication
```python
# Login
result = client.auth.login("user@example.com", "password")

# Get current user
user = client.auth.me()

# Refresh token
client.auth.refresh_token()
```

### AI Agents
```python
# List agents
agents = client.agents.list(status="active")

# Create agent
agent = client.agents.create(
    name="MyAgent",
    description="Production agent",
    capabilities=["tool_use", "memory"],
    tools=["read_file", "write_file"]
)

# Update agent
client.agents.update(agent["id"], status="inactive")

# Get interactions
interactions = client.agents.get_interactions(agent["id"])
```

### MCP Security
```python
# List MCP servers
servers = client.mcp.list_servers()

# Register server
server = client.mcp.register_server(
    name="filesystem-server",
    server_type="stdio",
    connection_string="npx @modelcontextprotocol/server-filesystem"
)

# Check permissions
result = client.mcp.check_permission(
    server_id="...",
    tool_name="read_file",
    arguments={"path": "/etc/passwd"}
)
print(f"Allowed: {result['allowed']}, Reason: {result['reason']}")

# Create permission rule
client.mcp.create_permission(
    permission_type="user",
    action="deny",
    tool_name="delete_*",
    priority=100
)
```

### Threat Detection
```python
# Get recent threats
threats = client.threats.get_recent(
    limit=100,
    threat_type="sql_injection",
    blocked_only=True
)

# Get statistics
stats = client.threats.get_stats(period_hours=24)
print(f"Total threats: {stats['total']}")
print(f"Blocked: {stats['blocked']}")

# Block IP
client.threats.block_ip(
    ip_address="192.168.1.100",
    reason="Repeated SQL injection attempts",
    duration_hours=24
)
```

### Dashboard
```python
# Get overview
overview = client.dashboard.get_overview()

# Get metrics
metrics = client.dashboard.get_metrics(period="7d", granularity="day")

# Get security score
score = client.dashboard.get_security_score()
print(f"Security Score: {score['overall']}/100")
```

## Error Handling

```python
from g8kepr import G8KEPRClient
from g8kepr.exceptions import (
    AuthenticationError,
    RateLimitError,
    NotFoundError,
    ValidationError,
)

client = G8KEPRClient(base_url="https://api.g8kepr.com")

try:
    client.auth.login("user@example.com", "wrong_password")
except AuthenticationError as e:
    print(f"Login failed: {e.message}")

try:
    client.agents.get("nonexistent-id")
except NotFoundError as e:
    print(f"Agent not found: {e.message}")

try:
    # Rapid requests
    for i in range(1000):
        client.threats.get_recent()
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
```

## Context Manager

```python
# Automatic cleanup
with G8KEPRClient(base_url="...", api_key="...") as client:
    agents = client.agents.list()
```

## Requirements

- Python 3.8+
- httpx >= 0.24.0

## License

Copyright (c) 2024-2025 Wesley Ellis. All Rights Reserved.
