Skip to main content

III SDK for Python

Project description

iii-sdk

Python SDK for the iii engine.

PyPI Python License

Install

pip install iii-sdk

Hello World

from iii import register_worker

iii = register_worker("ws://localhost:49134")

def greet(data):
    return {"message": f"Hello, {data['name']}!"}

iii.register_function("hello::greet", greet)

iii.register_trigger({
    "type": "http",
    "function_id": "hello::greet",
    "config": {"api_path": "/greet", "http_method": "POST"},
})

iii.connect()

result = iii.trigger({"function_id": "hello::greet", "payload": {"name": "world"}})
print(result)  # {"message": "Hello, world!"}

API

Operation Signature Description
Initialize register_worker(url, options?) Create an SDK instance and auto-connect
Register function iii.register_function(id, handler) Register a function that can be invoked by name
Register trigger iii.register_trigger({"type": ..., "function_id": ..., "config": ...}) Bind a trigger (HTTP, cron, queue, etc.) to a function
Invoke (await result) iii.trigger({"function_id": id, "payload": data}) Invoke a function and wait for the result
Invoke (fire-and-forget) iii.trigger({"function_id": id, ..., "action": TriggerAction.Void()}) Fire-and-forget
Invoke (enqueue) iii.trigger({"function_id": id, ..., "action": TriggerAction.Enqueue(queue="name")}) Route invocation through a named queue
Shutdown iii.shutdown() Disconnect and stop background thread

register_worker() creates the SDK instance and auto-connects to the engine.

Registering Functions

def create_order(data):
    return {"status_code": 201, "body": {"id": "123", "item": data["body"]["item"]}}

iii.register_function("orders::create", create_order)

Registering Triggers

iii.register_trigger({
    "type": "http",
    "function_id": "orders::create",
    "config": {"api_path": "/orders", "http_method": "POST"},
})

Invoking Functions

result = iii.trigger({"function_id": "orders::create", "payload": {"body": {"item": "widget"}}})

Development

Install in development mode

pip install -e .

Type checking

mypy src

Linting

ruff check src

Resources

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

iii_sdk-0.19.0.dev4.tar.gz (188.3 kB view details)

Uploaded Source

Built Distribution

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

iii_sdk-0.19.0.dev4-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file iii_sdk-0.19.0.dev4.tar.gz.

File metadata

  • Download URL: iii_sdk-0.19.0.dev4.tar.gz
  • Upload date:
  • Size: 188.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iii_sdk-0.19.0.dev4.tar.gz
Algorithm Hash digest
SHA256 f4f70bbf0a50e623be8f984695a4028af3d9fa874f4872fd8929b159e11e71ea
MD5 eefda4b3205abcf490809e46d8e61172
BLAKE2b-256 b687b8916d325e10cc0ab3cb364894f750322d310fa871a95df68192eb16130f

See more details on using hashes here.

File details

Details for the file iii_sdk-0.19.0.dev4-py3-none-any.whl.

File metadata

  • Download URL: iii_sdk-0.19.0.dev4-py3-none-any.whl
  • Upload date:
  • Size: 37.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iii_sdk-0.19.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 601bf07e3d075a3605212d774cb02eac6dc6db0f4338852ea4c99325e2c22c6c
MD5 81f01f2b2eaadac17c728d505e7fd79e
BLAKE2b-256 065f93ef18c38c4648a1b40e930384b9ebc32553256ab1e08718f2118b2c2937

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