10346: Document SDK examples uniformly
[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 h2.  Initialize SDK
9
10 <pre>
11 import (
12   "git.curoverse.com/arvados.git/sdk/go/arvados"
13   "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
14 }
15
16 func main() {
17   arv, err := arvadosclient.MakeArvadosClient()
18   if err != nil {
19     log.Fatalf("Error setting up arvados client %s", err.Error())
20   }
21 }
22 </pre>
23
24 h2. create
25
26 <pre>
27   var collection arvados.Collection
28   err := api.Create("collections", Dict{"collection": Dict{"name": "create example"}}, &collection)
29 </pre>
30
31 h2. delete
32
33 <pre>
34   var collection arvados.Collection
35   err := api.Delete("collections", "aaaaa-bbbbb-ccccccccccccccc", Dict{}, &collection)
36 </pre>
37
38 h2. get
39
40 <pre>
41   var collection arvados.Collection
42   err := api.Get("collections", "aaaaa-bbbbb-ccccccccccccccc", Dict{}, &collection)
43 </pre>
44
45 h2. list
46
47 <pre>
48   var collection arvados.Collection
49   err := api.List("collections", Dict{}, &collection)
50 </pre>
51
52 h2. update
53
54 <pre>
55   var collection arvados.Collection
56   err := api.Update("collections", "aaaaa-bbbbb-ccccccccccccccc", Dict{"collection": Dict{"name": "update example"}}, &collection)
57 </pre>
58
59 h2. Get current user
60
61 <pre>
62   var user arvados.User
63   err := api.Get("users", "current", Dict{}, &user)
64 </pre>
65
66 h2. Example program
67
68 You can save this source as a .go file and run it:
69
70 <notextile>{% code 'example_sdk_go' as go %}</notextile>
71
72 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.