Skip to main content

Async HTTP client for Atlas Command.

Project description

Atlas Command HTTP Client (Python)

atlas-asset-client is a lightweight async wrapper around the Atlas Command REST API. It replaces the retired WebSocket helpers and provides strongly-typed convenience methods for working with entities, tasks, objects, and query endpoints via HTTP.

Installation

pip install atlas-asset-client

During local development inside this repository:

pip install -e Atlas_Command/connection_packages/atlas_asset_ws_client

Quickstart

import asyncio
from atlas_asset_ws_client import AtlasCommandHttpClient

async def main() -> None:
    async with AtlasCommandHttpClient("http://localhost:8000") as client:
        entity = await client.create_entity(
            entity_id="asset-1",
            entity_type="asset",
            alias="Demo Asset",
            components={"telemetry": {"latitude": 40.7, "longitude": -74.0}},
        )
        print("Created entity:", entity["entity_id"])

        tasks = await client.list_tasks(limit=10)
        print("Existing tasks:", [t["task_id"] for t in tasks])

        snapshot = await client.get_full_dataset()
        print("Snapshot counts:", {k: len(v) for k, v in snapshot.items()})

        with open("mission_video.mp4", "rb") as video:
            stored = await client.create_object(
                file=video,
                object_id="mission-video-1",
                usage_hint="mission_video",
                referenced_by=[{"entity_id": "asset-1"}],
            )
            print("Uploaded object:", stored["object_id"])

asyncio.run(main())

Features

  • Uses httpx.AsyncClient under the hood with pluggable transport/timeouts.
  • Convenience methods for every public endpoint:
    • list_entities, get_entity, create_entity, update_entity, delete_entity, get_entity_by_alias, update_entity_telemetry
    • list_tasks, create_task, get_task, update_task, delete_task, get_tasks_by_entity, start_task, complete_task, fail_task
  • list_objects, create_object (uploads a file via /objects/upload), get_object,
  • update_object, delete_object,
  • get_objects_by_entity, get_objects_by_task, find_orphaned_objects,
  • add_object_reference, remove_object_reference, get_object_references,
  • validate_object_references, cleanup_object_references
    • get_changed_since, get_full_dataset
  • Optional bearer token support via the token= constructor parameter.
  • Context manager support (async with client:) to manage connection lifecycle.

Field reference

Client configuration

  • AtlasCommandHttpClient(base_url, *, token=None, timeout=10.0, transport=None) – requires base_url, optional token, timeout, and transport.

Entities

  • list_entities(*, limit=100, offset=0) – optional pagination parameters based on defaults.
  • get_entity(entity_id) – requires entity_id.
  • get_entity_by_alias(alias) – requires alias.
  • create_entity(*, entity_id, entity_type, alias, components=None) – requires entity_id, entity_type, and alias; components are optional.
  • update_entity(entity_id, *, components=None) – requires entity_id, optional component patch.
  • delete_entity(entity_id) – requires entity_id.
  • update_entity_telemetry(entity_id, *, latitude=None, longitude=None, altitude_m=None, speed_m_s=None, heading_deg=None) – requires entity_id; telemetry values are optional and only set when provided.

Tasks

  • list_tasks(*, status=None, limit=25) – optional status and page size.
  • get_task(task_id) – requires task_id.
  • create_task(*, task_id, components=None) – requires task_id; components optional.
  • update_task(task_id, *, components=None) – requires task_id; components optional.
  • delete_task(task_id) – requires task_id.
  • get_tasks_by_entity(entity_id, *, status=None, limit=25) – requires entity_id; filters optional.
  • start_task(task_id) / complete_task(task_id) – each requires task_id.
  • fail_task(task_id, *, error_message=None, error_details=None) – requires task_id; error info optional.

Objects

  • list_objects(*, content_type=None, limit=100, offset=0) – optional filters.
  • get_object(object_id) – requires object_id.
  • create_object(file, *, object_id, usage_hint=None, referenced_by=None) – requires file data and object_id; usage_hint and referenced_by optional.
  • update_object(object_id, *, usage_hints=None, referenced_by=None) – requires object_id; metadata optional.
  • delete_object(object_id) – requires object_id.
  • get_objects_by_entity(entity_id, *, limit=50) – requires entity_id, optional pagination.
  • get_objects_by_task(task_id, *, limit=50) – requires task_id, optional pagination.
  • add_object_reference(object_id, *, entity_id=None, task_id=None) / remove_object_reference(...) – require object_id; provide either entity_id or task_id to target the reference.
  • find_orphaned_objects(*, limit=100) – optional limit.
  • get_object_references(object_id) / validate_object_references(object_id) / cleanup_object_references(object_id) – each requires object_id.

Queries

  • get_changed_since(since, *, limit_per_type=None) – requires since; optional per-type limit.
  • get_full_dataset(*, entity_limit=None, task_limit=None, object_limit=None) – filters are optional.

Configuration

client = AtlasCommandHttpClient(
    "https://atlas.example.com",
    token="my-api-token",
    timeout=30.0,
)

You can also pass a custom httpx transport for testing:

transport = httpx.MockTransport(my_handler)
client = AtlasCommandHttpClient("http://testserver", transport=transport)

Breaking changes

  • create_entity now requires alias and no longer accepts published_at, updated_at, or extra.
  • create_task / update_task drop status/extra; lifecycle helpers no longer accept started_by or result.
  • create_object is the only object-creation helper and always uploads a file via /objects/upload; storage metadata and sizing is server-managed.

Testing

Run the suite with:

pip install -e .[dev]
pytest

The tests use httpx.MockTransport so they do not require a running Atlas Command instance.

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

atlas_asset_client-0.2.2.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.

atlas_asset_client-0.2.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file atlas_asset_client-0.2.2.tar.gz.

File metadata

  • Download URL: atlas_asset_client-0.2.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for atlas_asset_client-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4b05b849af50c728b118181ab5565c53ebb0f7afd274320c06881c4ef07c3b2b
MD5 50b030b33a6e7712daa4e9bf8394bef4
BLAKE2b-256 27dd8fd49d009acd5560bc8c0c33c16f1378605ff4a75db898e9b804c19f286f

See more details on using hashes here.

File details

Details for the file atlas_asset_client-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for atlas_asset_client-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d41a2a9cb4147848468626c1fdd8df412694cecd66b473edd82fa56a3724739
MD5 5056f378e77e5c8558084eeddcb770fe
BLAKE2b-256 c183b3f494c2ad9983ece9a4e970fc1d3b728ee332d7ebac24b8779553eef63f

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