Channels
Create and manage the channels that events are published to, and the apps they belong to.
A channel is the destination for events. Channels live inside an app, and every
events.publish call names one by UUID.
Create a channel
A channel needs an app to live in, so create the app first if you do not have one:
from axonpush import AxonPush
with AxonPush() as client:
app = client.apps.create("research-service")
channel = client.channels.create(app.app_id, "events")
print(channel.channel_id, channel.name, channel.app_id)channels.create(app_id, name) takes both arguments positionally, app first.
The returned Channel carries channel_id, app_id, org_id, name,
created_at and, when set, updated_at.
Read
channels = client.channels.list(app_id) # every channel in one app
channel = client.channels.get(app_id, channel_id) # one channelEvery channel call is scoped to its app, so get, update and delete take
the app UUID first.
Rename and delete
client.channels.update(app_id, channel_id, name="events-v2")
client.channels.delete(app_id, channel_id)update renames the channel (PUT /apps/{appId}/channels/{channelId}); name
is keyword-only and required.
Async
Every method has an async sibling with the same signature:
from axonpush import AsyncAxonPush
async with AsyncAxonPush() as client:
channel = await client.channels.create(app_id, "events")
channels = await client.channels.list(app_id)
await client.channels.delete(app_id, channel.channel_id)Apps
Apps are managed the same way, one level up:
apps = client.apps.list()
app = client.apps.get(app_id)
app = client.apps.create("research-service")
client.apps.update(app_id, name="research-service-v2")
client.apps.delete(app_id)create takes the name positionally; update takes the app UUID positionally
and name by keyword. An App carries app_id, org_id, name,
created_at and the optional repo_url, default_branch, creator_user_id
and updated_at.
Environments
Environments are org-level, not per-app, and are addressed by slug:
envs = client.environments.list()
env = client.environments.create("Staging", slug="staging")
client.environments.update("staging", color="#f59e0b")
client.environments.promote("staging")
client.environments.delete("staging")create takes the name positionally and accepts slug, color,
is_production and is_default as keywords. update changes name, color
or is_production. promote (also available as promote_to_default) makes
that environment the org default. Pass the slug, not the UUID, to
environment= on a client.