navmenu: Python
title: Examples
...
+{% comment %}
+Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: CC-BY-SA-3.0
+{% endcomment %}
+
+In these examples, the site prefix is @aaaaa@.
+
+See also the "cookbook":cookbook.html for more complex examples.
h2. Initialize SDK
-<pre>
+{% codeblock as python %}
import arvados
api = arvados.api("v1")
-</pre>
+{% endcodeblock %}
h2. create
-<pre>
-result = api.collection().create(body={"collection": {"name": "create example"}}).execute()
-</pre>
+{% codeblock as python %}
+result = api.collections().create(body={"collection": {"name": "create example"}}).execute()
+{% endcodeblock %}
h2. delete
-<pre>
-result = api.collections().delete(uuid="aaaaa-bbbbb-ccccccccccccccc").execute()
-</pre>
+{% codeblock as python %}
+result = api.collections().delete(uuid="aaaaa-4zz18-ccccccccccccccc").execute()
+{% endcodeblock %}
h2. get
-<pre>
-result = api.collections().get(uuid="aaaaa-bbbbb-ccccccccccccccc").execute()
-</pre>
+{% codeblock as python %}
+result = api.collections().get(uuid="aaaaa-4zz18-ccccccccccccccc").execute()
+{% endcodeblock %}
h2. list
-<pre>
+{% codeblock as python %}
result = api.collections().list(filters=[["uuid", "=", "aaaaa-bbbbb-ccccccccccccccc"]]).execute()
-</pre>
+{% endcodeblock %}
h2. update
-<pre>
-result = api.collections().update(uuid="aaaaa-bbbbb-ccccccccccccccc", body={"collection": {"name": "update example"}}).execute()
-</pre>
+{% codeblock as python %}
+result = api.collections().update(uuid="aaaaa-4zz18-ccccccccccccccc", body={"collection": {"name": "update example"}}).execute()
+{% endcodeblock %}
h2. Get current user
-<pre>
+{% codeblock as python %}
result = api.users().current().execute()
-</pre>
+{% endcodeblock %}
+
+h2. Get the User object for the current user
+
+{% codeblock as python %}
+current_user = arvados.api('v1').users().current().execute()
+{% endcodeblock %}
+
+h2. Get the UUID of an object that was retrieved using the SDK
+
+{% codeblock as python %}
+my_uuid = current_user['uuid']
+{% endcodeblock %}