8784: Fix test for latest firefox.
[arvados.git] / doc / sdk / go / example.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Python
5 title: Examples
6 ...
7
8 See "Arvados GoDoc":https://godoc.org/git.curoverse.com/arvados.git/sdk/go for detailed documentation.
9
10 In these examples, the site prefix is @aaaaa@.
11
12 h2.  Initialize SDK
13
14 <pre>
15 import (
16   "git.curoverse.com/arvados.git/sdk/go/arvados"
17   "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
18 }
19
20 func main() {
21   arv, err := arvadosclient.MakeArvadosClient()
22   if err != nil {
23     log.Fatalf("Error setting up arvados client %s", err.Error())
24   }
25 }
26 </pre>
27
28 h2. create
29
30 <pre>
31   var collection arvados.Collection
32   err := api.Create("collections", Dict{"collection": Dict{"name": "create example"}}, &collection)
33 </pre>
34
35 h2. delete
36
37 <pre>
38   var collection arvados.Collection
39   err := api.Delete("collections", "aaaaa-4zz18-ccccccccccccccc", Dict{}, &collection)
40 </pre>
41
42 h2. get
43
44 <pre>
45   var collection arvados.Collection
46   err := api.Get("collections", "aaaaa-4zz18-ccccccccccccccc", Dict{}, &collection)
47 </pre>
48
49 h2. list
50
51 <pre>
52   var collection arvados.Collection
53   err := api.List("collections", Dict{}, &collection)
54 </pre>
55
56 h2. update
57
58 <pre>
59   var collection arvados.Collection
60   err := api.Update("collections", "aaaaa-4zz18-ccccccccccccccc", Dict{"collection": Dict{"name": "update example"}}, &collection)
61 </pre>
62
63 h2. Get current user
64
65 <pre>
66   var user arvados.User
67   err := api.Get("users", "current", Dict{}, &user)
68 </pre>
69
70 h2. Example program
71
72 You can save this source as a .go file and run it:
73
74 <notextile>{% code 'example_sdk_go' as go %}</notextile>
75
76 A few more usage examples can be found in the "services/keepproxy":https://dev.arvados.org/projects/arvados/repository/revisions/master/show/services/keepproxy and "sdk/go/keepclient":https://dev.arvados.org/projects/arvados/repository/revisions/master/show/sdk/go/keepclient directories in the arvados source tree.