X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0eb72b526bf8bbb011551ecf019f604e17a534f1..4a7d0843a42986501fbfd18ba7ab96fc8669d1af:/doc/sdk/python/events.html.textile.liquid?ds=sidebyside diff --git a/doc/sdk/python/events.html.textile.liquid b/doc/sdk/python/events.html.textile.liquid index 9960e66836..afbec20d95 100644 --- a/doc/sdk/python/events.html.textile.liquid +++ b/doc/sdk/python/events.html.textile.liquid @@ -12,6 +12,18 @@ SPDX-License-Identifier: CC-BY-SA-3.0 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 - -{% code 'events_py' as python %} - +{% 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 %}