Skip to main content

Pydantic models and API client for ACE IoT Aerodrome platform

Project description

aceiot-models

Pydantic models and API client for the ACE IoT Aerodrome Platform

Installation

pip install aceiot-models

For upload progress support:

pip install aceiot-models[upload-progress]

Features

  • Pydantic Models: Type-safe data models for all ACE IoT entities
  • API Client: Comprehensive Python SDK for the ACE IoT API
  • Pagination Support: Efficient handling of large datasets
  • Batch Processing: Process large operations in manageable chunks
  • Type Hints: Full type annotations for better IDE support
  • Error Handling: Robust error handling with detailed error information

Usage

Using the API Client

from aceiot_models.api import APIClient, APIError

# Initialize the client
client = APIClient(
    base_url="https://flightdeck.aceiot.cloud/api",
    api_key="your-api-key"
)

# Or use environment variables:
# export ACEIOT_API_URL=https://flightdeck.aceiot.cloud/api
# export ACEIOT_API_KEY=your-api-key
client = APIClient()

# Get clients
clients = client.get_clients(page=1, per_page=20)

# Create a point
from aceiot_models import PointCreate

point = PointCreate(
    name="sensor/temperature/office",
    site_id=1,
    client_id=1,
    point_type="analog",
    collect_enabled=True
)
result = client.create_points([point.model_dump()])

Using Pagination

from aceiot_models.api import PaginatedResults

# Paginate through all sites
paginator = PaginatedResults(client.get_sites, per_page=100)
for page_sites in paginator:
    for site in page_sites:
        print(f"Site: {site['name']}")

# Or get all items at once
all_sites = paginator.all_items()

Batch Processing

from aceiot_models.api import batch_process

# Process points in batches
points = [...]  # List of many points

def create_batch(batch):
    return client.create_points(batch)

results = batch_process(
    items=points,
    process_func=create_batch,
    batch_size=100,
    progress_callback=lambda current, total: print(f"{current}/{total}")
)

Using the Models

from aceiot_models import Point, Sample, PointCreate

# Create a new point
point = PointCreate(
    name="sensor/temperature/office",
    site_id=1,
    client_id=1,
    point_type="analog",
    collect_enabled=True
)

Using the API Client

from aceiot_models.api import APIClient, APIError

# Initialize the client
client = APIClient(
    base_url="https://flightdeck.aceiot.cloud/api",
    api_key="your-api-key"
)

# Fetch sites
try:
    sites = client.get_sites(page=1, per_page=100)
    print(f"Found {sites['total_items']} sites")
except APIError as e:
    print(f"Error: {e}")

Pagination

from aceiot_models.api import PaginatedResults

# Iterate through all points page by page
paginator = PaginatedResults(client.get_points, per_page=500)
for page_points in paginator:
    print(f"Processing {len(page_points)} points...")
    # Process each page

# Or get all items at once
all_points = paginator.all_items()

Batch Processing

from aceiot_models.api import batch_process

# Process items in batches
def process_batch(items):
    return client.create_points(items)

results = batch_process(
    items=large_list_of_points,
    process_func=process_batch,
    batch_size=100,
    progress_callback=lambda current, total: print(f"{current}/{total}")
)

Configuration

The API client can be configured through environment variables:

  • ACEIOT_API_URL: Base URL for the API
  • ACEIOT_API_KEY: Your API key
  • ACEIOT_API_TIMEOUT: Request timeout in seconds (default: 30)

Examples

See the examples directory for complete usage examples.

Testing

Unit Tests

Run the unit tests:

pytest tests/ -v

Integration Tests

Integration tests verify the API client works with a real API endpoint. See tests/api/README_INTEGRATION.md for setup instructions.

# Set environment variables
export ACEIOT_API_URL="https://flightdeck.aceiot.cloud/api"
export ACEIOT_API_KEY="your-api-key"
export ACEIOT_INTEGRATION_TESTS="true"

# Run integration tests
pytest tests/api/test_integration.py -v

Development

This project uses uv for dependency management. To set up a development environment:

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone the repository
git clone https://github.com/yourusername/aceiot-models.git
cd aceiot-models

# Install dependencies
uv sync --all-extras

# Run tests
uv run pytest

# Run linting
uv run ruff check .
uv run ruff format .

# Run type checking
uv run pyrefly check aceiot_models/

License

MIT License

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

aceiot_models-0.3.1.tar.gz (125.5 kB view details)

Uploaded Source

Built Distribution

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

aceiot_models-0.3.1-py3-none-any.whl (65.0 kB view details)

Uploaded Python 3

File details

Details for the file aceiot_models-0.3.1.tar.gz.

File metadata

  • Download URL: aceiot_models-0.3.1.tar.gz
  • Upload date:
  • Size: 125.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aceiot_models-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c760bcba82e789e9d51554a0b12f4b9bbc1e2cdf4eb20033896efea012b31979
MD5 77888485bdc86f7b1665cc9bdbf62f09
BLAKE2b-256 46724a6a106ef8207946ac96e6eec655819b95d65f5cb42b67628a5794e1f3d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for aceiot_models-0.3.1.tar.gz:

Publisher: publish.yml on ACE-IoT-Solutions/aceiot-models

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aceiot_models-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: aceiot_models-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aceiot_models-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31ea3b35b0b48bdecaab19b49263843da7f61de0f18c4909d61f9f16e7b7bc32
MD5 7ae2e5fa4de1eee24ed571d7bef1fcfb
BLAKE2b-256 24acdf1e44c4ff1ba7ddc31057fde69f1291ded1eeeaf5251a9152ae3ac5b58e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aceiot_models-0.3.1-py3-none-any.whl:

Publisher: publish.yml on ACE-IoT-Solutions/aceiot-models

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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