# Devopness SDK - Python
[](https://pypi.org/project/devopness/)
The official Devopness SDK for Python.
This SDK provides predefined classes to access Devopness platform resources. It's suitable for building CLI tools, backend services, or automation scripts, helping you interact with the Devopness API.
## 📌 Table of Contents
- [Usage](#usage)
- [Install](#install)
- [Initializing](#initializing)
- [Custom Configuration](#custom-configuration)
- [Authenticating](#authenticating)
- [Asynchronous usage](#asynchronous-usage)
- [Synchronous usage](#synchronous-usage)
- [Invoking authentication-protected endpoints](#invoking-authentication-protected-endpoints)
- [Asynchronous usage](#asynchronous-usage-1)
- [Synchronous usage](#synchronous-usage-1)
- [Error Handling](#error-handling)
- [Development](#development)
- [With Docker](#with-docker)
## Usage
The SDK supports both asynchronous and synchronous usage, so you can choose based on your needs.
### Install
Install the SDK using your preferred package manager:
```bash
# Using uv
uv add devopness
# Using poetry
poetry add devopness
# Using pip
pip install devopness
```
### Initializing
Import the SDK and create an instance of `DevopnessClient` or `DevopnessClientAsync`:
```python
from devopness import DevopnessClient, DevopnessClientAsync
devopness = DevopnessClient()
devopness_async = DevopnessClientAsync()
```
### Custom Configuration
You can provide a custom configuration when initializing the client:
```python
from devopness import DevopnessClient, DevopnessClientAsync, DevopnessClientConfig
config = DevopnessClientConfig(base_url='https://api.devopness.com', timeout=10)
devopness = DevopnessClient(config)
devopness_async = DevopnessClientAsync(config)
```
Configuration options:
| Parameter | Default | Description |
| -------------------- | --------------------------- | --------------------------------------------------- |
| `auto_refresh_token` | `True` | Whether the access token is automatically refreshed |
| `base_url` | `https://api.devopness.com` | Base URL for all API requests |
| `timeout` | `30` | Timeout for HTTP requests (in seconds) |
| `default_encoding` | `utf-8` | Encoding for response content |
### Authenticating
To authenticate, invoke the `login_user` method on the `users` service.
#### Asynchronous usage
```python
import asyncio
from devopness import DevopnessClientAsync
from devopness.models import UserLogin
devopness = DevopnessClientAsync({'auto_refresh_token': False})
async def authenticate(user_email, user_pass):
user_data = UserLogin(email=user_email, password=user_pass)
user_tokens = await devopness.users.login_user(user_data)
# The `access_token` must be set every time a token is obtained or refreshed,
# if the `auto_refresh_token` option is set to `False`.
devopness.access_token = user_tokens.data.access_token
if __name__ == "__main__":
asyncio.run(authenticate('user@email.com', 'secret-password'))
```
#### Synchronous usage
```python
from devopness import DevopnessClient
from devopness.models import UserLogin
devopness = DevopnessClient({'auto_refresh_token': False})
def authenticate(user_email, user_pass):
user_data = UserLogin(email=user_email, password=user_pass)
user_tokens = devopness.users.login_user(user_data)
# The `access_token` must be set every time a token is obtained or refreshed,
# if the `auto_refresh_token` option is set to `False`.
devopness.access_token = user_tokens.data.access_token
if __name__ == "__main__":
authenticate('user@email.com', 'secret-password')
```
### Invoking authentication-protected endpoints
Once authenticated, you can invoke protected endpoints like retrieving user details.
#### Asynchronous usage
```python
import asyncio
from devopness import DevopnessClientAsync
from devopness.models import UserLogin
devopness = DevopnessClientAsync()
async def authenticate(user_email, user_pass):
user_data = UserLogin(email=user_email, password=user_pass)
await devopness.users.login_user(user_data)
async def get_user_profile():
await authenticate('user@email.com', 'secret-password')
current_user = await devopness.users.get_user_me()
print(f'User ID: {current_user.data.id}')
if __name__ == "__main__":
asyncio.run(get_user_profile())
```
#### Synchronous usage
```python
from devopness import DevopnessClient
from devopness.models import UserLogin
devopness = DevopnessClient()
def authenticate(user_email, user_pass):
user_data = UserLogin(email=user_email, password=user_pass)
devopness.users.login_user(user_data)
def get_user_profile():
authenticate('user@email.com', 'secret-password')
current_user = devopness.users.get_user_me()
print(f'User ID: {current_user.data.id}')
if __name__ == "__main__":
get_user_profile()
```
### Error Handling
The SDK provides structured error handling through exceptions:
- `DevopnessApiError`: This exception is raised when the Devopness API returns an error response. This typically indicates issues with the request itself, such as invalid input data, unauthorized access, or resource not found. It provides the following attributes to help diagnose the error:
| Attribute | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------------ |
| status_code | The HTTP status code returned by the API |
| message | A general error message from the API |
| errors | An optional dictionary containing detailed validation errors, often encountered during create or update operations |
- `DevopnessNetworkError`: This exception is raised when a generic network-related issue occurs during the communication with the Devopness API. This could be due to problems like an unreachable host, connection timeouts, or other network configuration errors.
Both exceptions inherit from `DevopnessSdkError`, the base class for all SDK exceptions. You can use this class to catch and handle all exceptions raised by the SDK.
## Development
To build the SDK locally, use Docker:
### With Docker
#### Prerequisites
- [Docker](https://www.docker.com/products/docker-desktop/)
- [Make](https://www.gnu.org/software/make/)
#### Steps
1. Navigate to the project directory:
```shell
cd packages/sdks/python/
```
1. Build the Docker image:
```shell
make build-image
```
1. Build the Python SDK:
```shell
make build-sdk-python
```
Raw data
{
"_id": null,
"home_page": "https://www.devopness.com",
"name": "devopness",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "API Client, Cloud Engineering, Cloud Infrastructure, Cloud Platform, Cloud Resource Management, Configuration Management, Deployment Automation, Devopness, DevOps, Infrastructure as Code, Platform Engineering, Python SDK, Server Management, Server Provisioning, Zero Downtime Deployment",
"author": "Devopness (https://www.devopness.com)",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/11/21/d85313e3f4a9d73d3b7af377ebd044749a59dd6b8971eebba0092f39faeb/devopness-1.3.1.tar.gz",
"platform": null,
"description": "# Devopness SDK - Python\n\n[](https://pypi.org/project/devopness/)\n\nThe official Devopness SDK for Python.\n\nThis SDK provides predefined classes to access Devopness platform resources. It's suitable for building CLI tools, backend services, or automation scripts, helping you interact with the Devopness API.\n\n## \ud83d\udccc Table of Contents\n\n- [Usage](#usage)\n - [Install](#install)\n - [Initializing](#initializing)\n - [Custom Configuration](#custom-configuration)\n - [Authenticating](#authenticating)\n - [Asynchronous usage](#asynchronous-usage)\n - [Synchronous usage](#synchronous-usage)\n - [Invoking authentication-protected endpoints](#invoking-authentication-protected-endpoints)\n - [Asynchronous usage](#asynchronous-usage-1)\n - [Synchronous usage](#synchronous-usage-1)\n - [Error Handling](#error-handling)\n- [Development](#development)\n - [With Docker](#with-docker)\n\n## Usage\n\nThe SDK supports both asynchronous and synchronous usage, so you can choose based on your needs.\n\n### Install\n\nInstall the SDK using your preferred package manager:\n\n```bash\n# Using uv\nuv add devopness\n\n# Using poetry\npoetry add devopness\n\n# Using pip\npip install devopness\n```\n\n### Initializing\n\nImport the SDK and create an instance of `DevopnessClient` or `DevopnessClientAsync`:\n\n```python\nfrom devopness import DevopnessClient, DevopnessClientAsync\n\ndevopness = DevopnessClient()\ndevopness_async = DevopnessClientAsync()\n```\n\n### Custom Configuration\n\nYou can provide a custom configuration when initializing the client:\n\n```python\nfrom devopness import DevopnessClient, DevopnessClientAsync, DevopnessClientConfig\n\nconfig = DevopnessClientConfig(base_url='https://api.devopness.com', timeout=10)\n\ndevopness = DevopnessClient(config)\ndevopness_async = DevopnessClientAsync(config)\n```\n\nConfiguration options:\n\n| Parameter | Default | Description |\n| -------------------- | --------------------------- | --------------------------------------------------- |\n| `auto_refresh_token` | `True` | Whether the access token is automatically refreshed |\n| `base_url` | `https://api.devopness.com` | Base URL for all API requests |\n| `timeout` | `30` | Timeout for HTTP requests (in seconds) |\n| `default_encoding` | `utf-8` | Encoding for response content |\n\n### Authenticating\n\nTo authenticate, invoke the `login_user` method on the `users` service.\n\n#### Asynchronous usage\n\n```python\nimport asyncio\n\nfrom devopness import DevopnessClientAsync\nfrom devopness.models import UserLogin\n\ndevopness = DevopnessClientAsync({'auto_refresh_token': False})\n\nasync def authenticate(user_email, user_pass):\n user_data = UserLogin(email=user_email, password=user_pass)\n user_tokens = await devopness.users.login_user(user_data)\n\n # The `access_token` must be set every time a token is obtained or refreshed,\n # if the `auto_refresh_token` option is set to `False`.\n devopness.access_token = user_tokens.data.access_token\n\nif __name__ == \"__main__\":\n asyncio.run(authenticate('user@email.com', 'secret-password'))\n```\n\n#### Synchronous usage\n\n```python\nfrom devopness import DevopnessClient\nfrom devopness.models import UserLogin\n\ndevopness = DevopnessClient({'auto_refresh_token': False})\n\ndef authenticate(user_email, user_pass):\n user_data = UserLogin(email=user_email, password=user_pass)\n user_tokens = devopness.users.login_user(user_data)\n\n # The `access_token` must be set every time a token is obtained or refreshed,\n # if the `auto_refresh_token` option is set to `False`.\n devopness.access_token = user_tokens.data.access_token\n\nif __name__ == \"__main__\":\n authenticate('user@email.com', 'secret-password')\n```\n\n### Invoking authentication-protected endpoints\n\nOnce authenticated, you can invoke protected endpoints like retrieving user details.\n\n#### Asynchronous usage\n\n```python\nimport asyncio\n\nfrom devopness import DevopnessClientAsync\nfrom devopness.models import UserLogin\n\ndevopness = DevopnessClientAsync()\n\nasync def authenticate(user_email, user_pass):\n user_data = UserLogin(email=user_email, password=user_pass)\n await devopness.users.login_user(user_data)\n\nasync def get_user_profile():\n await authenticate('user@email.com', 'secret-password')\n current_user = await devopness.users.get_user_me()\n print(f'User ID: {current_user.data.id}')\n\nif __name__ == \"__main__\":\n asyncio.run(get_user_profile())\n```\n\n#### Synchronous usage\n\n```python\nfrom devopness import DevopnessClient\nfrom devopness.models import UserLogin\n\ndevopness = DevopnessClient()\n\ndef authenticate(user_email, user_pass):\n user_data = UserLogin(email=user_email, password=user_pass)\n devopness.users.login_user(user_data)\n\ndef get_user_profile():\n authenticate('user@email.com', 'secret-password')\n current_user = devopness.users.get_user_me()\n print(f'User ID: {current_user.data.id}')\n\nif __name__ == \"__main__\":\n get_user_profile()\n```\n\n### Error Handling\n\nThe SDK provides structured error handling through exceptions:\n\n- `DevopnessApiError`: This exception is raised when the Devopness API returns an error response. This typically indicates issues with the request itself, such as invalid input data, unauthorized access, or resource not found. It provides the following attributes to help diagnose the error:\n\n| Attribute | Description |\n| ----------- | ------------------------------------------------------------------------------------------------------------------ |\n| status_code | The HTTP status code returned by the API |\n| message | A general error message from the API |\n| errors | An optional dictionary containing detailed validation errors, often encountered during create or update operations |\n\n- `DevopnessNetworkError`: This exception is raised when a generic network-related issue occurs during the communication with the Devopness API. This could be due to problems like an unreachable host, connection timeouts, or other network configuration errors.\n\nBoth exceptions inherit from `DevopnessSdkError`, the base class for all SDK exceptions. You can use this class to catch and handle all exceptions raised by the SDK.\n\n## Development\n\nTo build the SDK locally, use Docker:\n\n### With Docker\n\n#### Prerequisites\n\n- [Docker](https://www.docker.com/products/docker-desktop/)\n- [Make](https://www.gnu.org/software/make/)\n\n#### Steps\n\n1. Navigate to the project directory:\n\n```shell\ncd packages/sdks/python/\n```\n\n1. Build the Docker image:\n\n```shell\nmake build-image\n```\n\n1. Build the Python SDK:\n\n```shell\nmake build-sdk-python\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Devopness API Python SDK - Painless essential DevOps to everyone",
"version": "1.3.1",
"project_urls": {
"Homepage": "https://www.devopness.com",
"Repository": "https://github.com/devopness/devopness"
},
"split_keywords": [
"api client",
" cloud engineering",
" cloud infrastructure",
" cloud platform",
" cloud resource management",
" configuration management",
" deployment automation",
" devopness",
" devops",
" infrastructure as code",
" platform engineering",
" python sdk",
" server management",
" server provisioning",
" zero downtime deployment"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5a2a0cb0b462d7a6f1ff7d88ddd37b80056ce7a49de5da28963831f52fbd3e7f",
"md5": "d9c232ef7814c0fd8f81238adc259bb2",
"sha256": "38776094f58563e6141ae6560c98de1ac631a6fb60f56523739869d3f0f988c1"
},
"downloads": -1,
"filename": "devopness-1.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d9c232ef7814c0fd8f81238adc259bb2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 360880,
"upload_time": "2025-07-08T22:08:25",
"upload_time_iso_8601": "2025-07-08T22:08:25.750073Z",
"url": "https://files.pythonhosted.org/packages/5a/2a/0cb0b462d7a6f1ff7d88ddd37b80056ce7a49de5da28963831f52fbd3e7f/devopness-1.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1121d85313e3f4a9d73d3b7af377ebd044749a59dd6b8971eebba0092f39faeb",
"md5": "7bc29b87da346baa22c88bc4690ddf16",
"sha256": "9a03805b974cf7811467bd47dc40ea57b6d055aca810efb064ef4acf82664fa0"
},
"downloads": -1,
"filename": "devopness-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "7bc29b87da346baa22c88bc4690ddf16",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 112066,
"upload_time": "2025-07-08T22:08:27",
"upload_time_iso_8601": "2025-07-08T22:08:27.239097Z",
"url": "https://files.pythonhosted.org/packages/11/21/d85313e3f4a9d73d3b7af377ebd044749a59dd6b8971eebba0092f39faeb/devopness-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 22:08:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "devopness",
"github_project": "devopness",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "devopness"
}