X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ddeef8adc0cb7cdb55be644b9335ea51919ed513..448f667a574b50da096051a0d062b9059ab3609f:/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 0988a7ce9c..afbec20d95 100644 --- a/doc/sdk/python/events.html.textile.liquid +++ b/doc/sdk/python/events.html.textile.liquid @@ -4,9 +4,26 @@ navsection: sdk navmenu: Python title: Subscribing to events ... +{% comment %} +Copyright (C) The Arvados Authors. All rights reserved. + +SPDX-License-Identifier: CC-BY-SA-3.0 +{% endcomment %} 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 %}