Skip to main content

Client SDK for the Airlock Gateway — submit artifacts, poll for decisions, manage pairing and presence.

Project description

airlock-gateway (Python)

An async Python client SDK for the Airlock Gateway API.

Installation

pip install airlock-gateway

Quick Start

import asyncio
from airlock_gateway import (
    AirlockGatewayClient,
    ArtifactSubmitRequest,
    CiphertextRef,
)


async def main():
    async with AirlockGatewayClient(
        "https://gw.example.com", token="your-token"
    ) as client:
        # Submit an artifact for approval
        request_id = await client.submit_artifact(
            ArtifactSubmitRequest(
                enforcer_id="my-enforcer",
                artifact_hash="sha256-hash",
                ciphertext=CiphertextRef(
                    alg="aes-256-gcm",
                    data="base64-encrypted-content",
                    nonce="nonce",
                    tag="tag",
                ),
                metadata={"routingToken": "rt-abc"},
            )
        )

        # Wait for a decision (long-poll)
        decision = await client.wait_for_decision(request_id, timeout_seconds=30)
        if decision and decision.body and decision.body.is_approved:
            print(f"Approved: {decision.body.reason}")


asyncio.run(main())

API Reference

Method Description
echo() Gateway discovery/health
submit_artifact(request) Submit artifact for approval
get_exchange_status(request_id) Get exchange status
wait_for_decision(request_id, timeout) Long-poll for decision
withdraw_exchange(request_id) Withdraw pending exchange
acknowledge(msg_id, enforcer_id) Acknowledge inbox message
initiate_pairing(request) Start pairing session
resolve_pairing(code) Resolve pairing code
get_pairing_status(nonce) Poll pairing status
complete_pairing(request) Complete pairing
revoke_pairing(routing_token) Revoke a pairing
get_pairing_status_batch(tokens) Batch check pairings
send_heartbeat(request) Presence heartbeat
list_enforcers() List online enforcers
get_enforcer_presence(id) Get enforcer presence

Error Handling

All errors raise AirlockGatewayError with helper properties:

from airlock_gateway import AirlockGatewayError

try:
    await client.submit_artifact(request)
except AirlockGatewayError as e:
    if e.is_quota_exceeded:
        print("Quota exceeded")
    elif e.is_pairing_revoked:
        print("Pairing revoked")
    elif e.is_conflict:
        print("Idempotency conflict")
    else:
        print(f"Error {e.status_code}: {e}")

Requirements

  • Python 3.9+
  • httpx >= 0.25.0
  • pydantic >= 2.0.0

Development

pip install -e ".[dev]"
pytest

License

MIT

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

airlock_gateway-0.1.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

airlock_gateway-0.1.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file airlock_gateway-0.1.1.tar.gz.

File metadata

  • Download URL: airlock_gateway-0.1.1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airlock_gateway-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c7d46cd90a25e9c18ac944ca88a7b2e3eafb0da0b47684921b596a9db4585877
MD5 1bf644826fd0059bb0db3793c1990165
BLAKE2b-256 8d46aa94f4b2d0bff1194a411b61bee4bfa59642db43cc83c711b973bcbbdbb4

See more details on using hashes here.

File details

Details for the file airlock_gateway-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for airlock_gateway-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1edec4e1213bdb850f3b86f3e8328b2aa92f6e07e7e6ee2f6e825c5df4093b5
MD5 cfd45caf56d33b35cc377a1a81ae42b9
BLAKE2b-256 3d1ccb184f950055a818bfcad72be666ddba48585f46821b4afa0f4b6e029cfc

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