Skip to main content

A Python SDK for the QuickDeployer API, supporting API interactions for project and server management.

Project description

Python QuickDeployer SDK

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.

Features

  • 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 requests library for reliable API communication.

Requirements

  • Python 3.7+
  • requests library (requests>=2.25.0)
  • pytest (for running tests)

Installation

Install the SDK via pip:

pip install quick-deployer-sdk

If 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@main

Or include it in your requirements.txt:

git+https://github.com/niravsutariya/python-quick-deployer-sdk.git@main

Then run:

pip install -r requirements.txt

Usage

Initializing the Client

Create 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.

Managing Projects

List Projects

Retrieve a list of projects:

projects = client.projects().list()
for project in projects:
    print(f"Project ID: {project['id']}, Name: {project['name']}")

Get a Project

Fetch details for a specific project:

project = client.projects().get("project-123")
print(f"Project Name: {project['name']}")

Create a Project

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 a Project

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

Delete a project:

client.projects().delete("project-123")
print("Project deleted successfully")

Managing Servers

List Servers

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']}")

Get a Server

Fetch details for a specific server:

server = client.servers("project-123").get("server-456")
print(f"Server Name: {server['name']}")

Create a Server

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 a Server

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

Delete a server:

client.servers("project-123").delete("server-456")
print("Server deleted successfully")

Check Server Status

Check the status of a server:

status = client.servers("project-123").check_status("server-456")
print(f"Server Status: {status['status']}")

Error Handling

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)}")

Health Check

Check the API's health status:

health = client.check_health()
print(f"API Status: {health['status']}")

Configuration

  • API Key: Obtain your API key from the QuickDeployer dashboard.
  • Base URL: Override the default https://staging.quickdeployer.com/api if using a different environment (e.g., production).

Testing

The SDK includes unit tests for the Project and Server resources using pytest.

Running Tests

  1. Install dependencies:
pip install pytest requests
  1. Run tests:
pytest

Tests are located in the tests/ directory (e.g., test_project.py, test_server.py) and use unittest.mock to simulate API responses.

Flask/Django Integration

To use the SDK in a Flask or Django project:

  1. Install the SDK as a pip package (see Installation).
  2. 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()
  1. For Django, configure the API key in settings.py and inject it into the service.
  2. For Flask, use app configuration or environment variables to manage the API key.

Contributing

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m "Add your feature").
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a pull request.

Please include tests for new features and follow PEP 8 coding standards.

License

This SDK is licensed under the MIT License. See the LICENSE file for details.

Support

For issues or questions, open an issue on the GitHub repository or contact support@quickdeployer.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quick_deployer_sdk-1.0.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quick_deployer_sdk-1.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file quick_deployer_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: quick_deployer_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for quick_deployer_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4ba5ab13c6be3e0bc84c7b05a213c27b5ee6d5de9d067a611248f977f667d700
MD5 2ece604a146e2c03f314f4f9af82afa3
BLAKE2b-256 743d9cc832cb935b79a6aa3588c737dd14890aca99dfd25d62a0b28802096f02

See more details on using hashes here.

File details

Details for the file quick_deployer_sdk-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for quick_deployer_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe0acd4889a16c514c5192b942b76b27a8bcffbfec5d7e1fbd338c6beb4c4535
MD5 bddac12ff9a406cc445a85b31c186eef
BLAKE2b-256 aae89b4764c68dd030bc1d74bf7fc8fe41980fa2964ee568ff6b017e21f8601c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page