Metadata-Version: 2.4
Name: nexqloud-dcp
Version: 1.0.0
Summary: Official Python SDK for Nexqloud DCP (Distributed Cloud Platform)
Author: Nexqloud
License-Expression: MIT
Project-URL: Homepage, https://nexqloud.io
Project-URL: Repository, https://github.com/nexqloud/dcp-sdk-python
Keywords: nexqloud,dcp,cloud,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: typing-extensions>=4.0.0
Dynamic: license-file

# Nexqloud DCP Python SDK

Official Python SDK for Nexqloud DCP (Distributed Cloud Platform).

This SDK provides a high-level `DCPClient` wrapper over the generated API client, with:

- API key authentication via constructor or `DCP_API_KEY`
- Service aliases that match the JavaScript SDK style (`dc2`, `dks`, `dds`, `dcr`, `dss`)
- Configurable timeout and retries
- Passthrough `fetch(...)` for authenticated low-level requests

## Requirements

- Python 3.9+
- A Nexqloud DCP API key

## Installation

Install from PyPI:

```bash
pip install nexqloud-dcp
```

The import path remains:

```python
from nexqloud_dcp import DCPClient, DCPClientOptions
```

## Local Development Setup

If you are working from this repository directly, run your scripts with `src` on `PYTHONPATH`:

```bash
PYTHONPATH=src python your_script.py
```

## Quick Start

```python
import os
from nexqloud_dcp import DCPClient

os.environ["DCP_API_KEY"] = "dcp_your_api_key"

client = DCPClient()

node_types = client.nodeTypes.node_types_controller_find_all()
for node_type in node_types:
    print(node_type.node_type_id, node_type.label)
```

## Authentication

### Option 1: Environment variable

```bash
export DCP_API_KEY=dcp_your_api_key
```

```python
from nexqloud_dcp import DCPClient

client = DCPClient()
```

### Option 2: Pass key directly

```python
from nexqloud_dcp import DCPClient, DCPClientOptions

client = DCPClient(
    DCPClientOptions(api_key="dcp_your_api_key")
)
```

## Service Clients

`DCPClient` exposes service aliases aligned with the TypeScript SDK naming:

- `client.dc2` -> Virtual Machines
- `client.dks` -> Kubernetes Clusters
- `client.dds` -> Managed Databases
- `client.dcr` -> Container Registry
- `client.dss` -> Object Storage
- `client.nodeTypes` (or `client.node_types`) -> Node Types
- `client.regions` -> Metadata

## Usage Examples

### List Virtual Machines

```python
from nexqloud_dcp import DCPClient, DCPClientOptions

client = DCPClient(DCPClientOptions(api_key="dcp_your_api_key"))

vms = client.dc2.virtual_machines_controller_find_all()
print(vms)
```

### List Clusters

```python
from nexqloud_dcp import DCPClient, DCPClientOptions

client = DCPClient(DCPClientOptions(api_key="dcp_your_api_key"))

clusters = client.dks.clusters_controller_find_all(query="")
print(clusters)
```

### List Managed Databases

```python
from nexqloud_dcp import DCPClient, DCPClientOptions

client = DCPClient(DCPClientOptions(api_key="dcp_your_api_key"))

databases = client.dds.managed_databases_controller_list_databases(
    include_deleted="false",
    page=1,
    page_size=10,
)
print(databases)
```

## Advanced Configuration

```python
from nexqloud_dcp import DCPClient, DCPClientOptions

client = DCPClient(
    DCPClientOptions(
        api_key="dcp_your_api_key",
        base_url="https://gateway.dcp.nexqloud.net",
        timeout_in_seconds=60,
        max_retries=3,
    )
)
```

## Low-Level Authenticated Requests

Use `fetch(...)` when you need raw HTTP behavior while still using SDK auth/retry config.

```python
from nexqloud_dcp import DCPClient, DCPClientOptions

client = DCPClient(DCPClientOptions(api_key="dcp_your_api_key"))

response = client.fetch("/api/v1/node-types", method="GET")
response.raise_for_status()
print(response.json())
```

You can also pass a full URL:

```python
response = client.fetch("https://gateway.dcp.nexqloud.net/api/v1/node-types")
```

## Error Handling

```python
from nexqloud_dcp import DCPClient, DCPClientOptions
from generated.errors import BadRequestError, NotFoundError

client = DCPClient(DCPClientOptions(api_key="dcp_your_api_key"))

try:
    client.dc2.virtual_machines_controller_find_one("vm-id")
except NotFoundError:
    print("VM not found")
except BadRequestError as err:
    print("Bad request:", err)
```

## Notes

- The generated SDK lives under `src/generated`.
- The high-level wrapper lives under `src/nexqloud_dcp`.
- Prefer adding custom behavior in `src/nexqloud_dcp` so regenerated files are not overwritten.

## Contributing

See `CONTRIBUTING.md` for developer setup, SDK regeneration steps, and PR guidelines.
