Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / doc / sdk / python / example.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Python
5 title: Examples
6 ...
7 {% comment %}
8 Copyright (C) The Arvados Authors. All rights reserved.
9
10 SPDX-License-Identifier: CC-BY-SA-3.0
11 {% endcomment %}
12
13 In these examples, the site prefix is @aaaaa@.
14
15 See also the "cookbook":cookbook.html for more complex examples.
16
17 h2.  Initialize SDK
18
19 {% codeblock as python %}
20 import arvados
21 api = arvados.api("v1")
22 {% endcodeblock %}
23
24 h2. create
25
26 {% codeblock as python %}
27 result = api.collections().create(body={"collection": {"name": "create example"}}).execute()
28 {% endcodeblock %}
29
30 h2. delete
31
32 {% codeblock as python %}
33 result = api.collections().delete(uuid="aaaaa-4zz18-ccccccccccccccc").execute()
34 {% endcodeblock %}
35
36 h2. get
37
38 {% codeblock as python %}
39 result = api.collections().get(uuid="aaaaa-4zz18-ccccccccccccccc").execute()
40 {% endcodeblock %}
41
42 h2. list
43
44 {% codeblock as python %}
45 result = api.collections().list(filters=[["uuid", "=", "aaaaa-bbbbb-ccccccccccccccc"]]).execute()
46 {% endcodeblock %}
47
48 h2. update
49
50 {% codeblock as python %}
51 result = api.collections().update(uuid="aaaaa-4zz18-ccccccccccccccc", body={"collection": {"name": "update example"}}).execute()
52 {% endcodeblock %}
53
54 h2. Get current user
55
56 {% codeblock as python %}
57 result = api.users().current().execute()
58 {% endcodeblock %}
59
60 h2. Get the User object for the current user
61
62 {% codeblock as python %}
63 current_user = arvados.api('v1').users().current().execute()
64 {% endcodeblock %}
65
66 h2. Get the UUID of an object that was retrieved using the SDK
67
68 {% codeblock as python %}
69 my_uuid = current_user['uuid']
70 {% endcodeblock %}