X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/eff37344f3cecd5aed259c9852aca4bdcdfb6922..505c8fa50631201e289cc55230d46fdf52fa2055:/doc/sdk/python/events.html.textile.liquid diff --git a/doc/sdk/python/events.html.textile.liquid b/doc/sdk/python/events.html.textile.liquid index 6afb9b51a3..302af20c83 100644 --- a/doc/sdk/python/events.html.textile.liquid +++ b/doc/sdk/python/events.html.textile.liquid @@ -2,11 +2,28 @@ layout: default navsection: sdk navmenu: Python -title: Subscribing to events +title: Subscribing to database events ... +{% comment %} +Copyright (C) The Arvados Authors. All rights reserved. -Arvados applications can subscribe to a live event stream from the database. Events are described in the "Log record schema.":{{site.baseurl}}/api/schema/Log.html +SPDX-License-Identifier: CC-BY-SA-3.0 +{% endcomment %} - -{% code 'events_py' as python %} - +Arvados applications can subscribe to a live event stream from the database. Events are described in the "Log resource.":{{site.baseurl}}/api/methods/logs.html + +{% codeblock as python %} +#!/usr/bin/env python + +import arvados +import arvados.events + +# 'ev' is a dict containing the log table record describing the change. +def on_message(ev): + if ev.get("event_type") == "create" and ev.get("object_kind") == "arvados#collection": + print "A new collection was created: %s" % ev["object_uuid"] + +api = arvados.api("v1") +ws = arvados.events.subscribe(api, [], on_message) +ws.run_forever() +{% endcodeblock %}