The QuickDeployer SDK is a Python library for interacting with the QuickDeployer API, enabling developers to manage projects and servers programmatically. Designed for simplicity and modularity, it provides a clean interface for listing, creating, updating, and deleting projects and servers, with robust error handling and support for testing.
- Manage projects (list, get, create, update, delete).
- Manage servers within projects (list, get, create, update, delete, check status).
- Easy integration with Python applications, including Flask and Django.
- Comprehensive unit tests using pytest.
- Built with
requestslibrary for reliable API communication.
- Python 3.7+
requestslibrary (requests>=2.25.0)pytest(for running tests)
Install the SDK via pip:
pip install quick-deployer-sdkIf the SDK is not yet published, you can install it from a Git repository by adding it to your requirements.txt or using pip directly:
pip install git+https://github.com/niravsutariya/python-quick-deployer-sdk.git@mainOr include it in your requirements.txt:
git+https://github.com/niravsutariya/python-quick-deployer-sdk.git@main
Then run:
pip install -r requirements.txtCreate a QuickDeployerClient instance with your API key and base URL:
from quick_deployer_sdk.client import QuickDeployerClient
api_key = "your-api-token"
base_url = "https://staging.quickdeployer.com/api"
client = QuickDeployerClient(base_url, api_key)The base URL defaults to https://staging.quickdeployer.com/api if not specified.
Retrieve a list of projects:
projects = client.projects().list()
for project in projects:
print(f"Project ID: {project['id']}, Name: {project['name']}")Fetch details for a specific project:
project = client.projects().get("project-123")
print(f"Project Name: {project['name']}")Create a new project:
new_project = client.projects().create({
"name": "New Project",
"description": "A test project"
})
print(f"Created Project ID: {new_project['id']}")Update an existing project:
updated_project = client.projects().update("project-123", {
"name": "Updated Project"
})
print(f"Updated Project Name: {updated_project['name']}")Delete a project:
client.projects().delete("project-123")
print("Project deleted successfully")Retrieve servers for a specific project:
servers = client.servers("project-123").list()
for server in servers["servers"]:
print(f"Server ID: {server['id']}, Name: {server['name']}")Fetch details for a specific server:
server = client.servers("project-123").get("server-456")
print(f"Server Name: {server['name']}")Create a new server:
new_server = client.servers("project-123").create({
"name": "New Server",
"type": "web"
})
print(f"Created Server ID: {new_server['id']}")Update an existing server:
updated_server = client.servers("project-123").update("server-456", {
"name": "Updated Server"
})
print(f"Updated Server Name: {updated_server['name']}")Delete a server:
client.servers("project-123").delete("server-456")
print("Server deleted successfully")Check the status of a server:
status = client.servers("project-123").check_status("server-456")
print(f"Server Status: {status['status']}")All methods raise a QuickDeployerError on API failures. Use try-except blocks to handle errors:
from quick_deployer_sdk.exceptions import QuickDeployerError
try:
projects = client.projects().list()
except QuickDeployerError as e:
print(f"Error: {str(e)}")Check the API's health status:
health = client.check_health()
print(f"API Status: {health['status']}")- API Key: Obtain your API key from the QuickDeployer dashboard.
- Base URL: Override the default
https://staging.quickdeployer.com/apiif using a different environment (e.g., production).
The SDK includes unit tests for the Project and Server resources using pytest.
- Install dependencies:
pip install pytest requests- Run tests:
pytestTests are located in the tests/ directory (e.g., test_project.py, test_server.py) and use unittest.mock to simulate API responses.
To use the SDK in a Flask or Django project:
- Install the SDK as a pip package (see Installation).
- Create a service class to wrap SDK usage:
# app/services/deployment_service.py
from quick_deployer_sdk.client import QuickDeployerClient
class DeploymentService:
def __init__(self):
self.client = QuickDeployerClient(
base_url="https://staging.quickdeployer.com/api",
api_key="your-api-token"
)
def get_projects(self):
return self.client.projects().list()- For Django, configure the API key in
settings.pyand inject it into the service. - For Flask, use app configuration or environment variables to manage the API key.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m "Add your feature"). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
Please include tests for new features and follow PEP 8 coding standards.
This SDK is licensed under the MIT License. See the LICENSE file for details.
For issues or questions, open an issue on the GitHub repository or contact [email protected].