Merge branch '3147-py-collection-retries-wip2'
[arvados.git] / doc / sdk / go / index.html.textile.liquid
index 6996a4ed0bc84d6728d2b70ece3b0c116ff5bd30..58446a9edaf9ed05b5ac01deeb692affed4d5590 100644 (file)
@@ -12,89 +12,14 @@ h3. Installation
 
 You don't need to install anything. Just import the client like this. The go tools will fetch the relevant code and dependencies for you.
 
-<notextile>
-<pre><code class="userinput">import (
-       "git.curoverse.com/arvados.git/sdk/go/keepclient"
-       "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
-)
-</code></pre>
-</notextile>
+<notextile>{% code 'example_sdk_go_imports' as go %}</notextile>
 
 If you need pre-release client code, you can use the latest version from the repo by following "these instructions.":https://arvados.org/projects/arvados/wiki/Go#Using-Go-with-Arvados
 
-h3. Examples
+h3. Example
 
-Import the module. (We import the log module here too, so we can use it in the subsequent examples.)
+You can save this source as a .go file and run it:
 
-<notextile>
-<pre><code class="userinput">import (
-       "git.curoverse.com/arvados.git/sdk/go/keepclient"
-       "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
-       "log"
-)
-</code></pre>
-</notextile>
+<notextile>{% code 'example_sdk_go' as go %}</notextile>
 
-Set up an API client user agent:
-
-<notextile>
-<pre><code class="userinput">  arv, err := arvadosclient.MakeArvadosClient()
-       if err != nil {
-               log.Fatalf("Error setting up arvados client %s", err.Error())
-       }
-</code></pre>
-</notextile>
-
-Get the User object for the current user:
-
-<notextile>
-<pre><code class="userinput">  type user struct {
-               Uuid       string   `json:"uuid"`
-               FullName   string   `json:"full_name"`
-       }
-
-       var u user
-       err := arv.Call("GET", "users", "", "current", nil, &u)
-
-       if err != nil {
-               return err
-       }
-
-       log.Printf("Logged in as %s (uuid %s)", user.Uuid, user.FullName)
-</code></pre>
-</notextile>
-
-Print all returned fields for collections:
-
-<notextile>
-<pre><code class="userinput">  var collections map[string]interface{}
-
-       params := arvadosclient.Dict{"limit": 10}
-
-       err = arv.Call("GET", "collections", "", "", params, &collections)
-       if err != nil {
-               log.Fatalf("error querying collections", err.Error())
-       }
-
-       for key, value := range collections {
-               if key == "items" {
-                       items := value.([]interface{})
-                       for index, item := range items {
-                               fmt.Println("===========  ", index, "  ===========")
-                               item_map := item.(map[string]interface{})
-                               if len(item_map) == 0 {
-                                       fmt.Println("item", index, ": empty map")
-                               } else {
-                                       for k,v := range item_map {
-                                               fmt.Println(index, k, ":", v)
-                                       }
-                               }
-                       }
-               } else {
-                       fmt.Println(key, ":", value)
-               }
-       }
-</code></pre>
-</notextile>
-
-A few more usage examples can be found in the services/keepproxy and sdk/go/keepclient directories in the arvados source tree.
+A few more usage examples can be found in the "services/keepproxy":https://arvados.org/projects/arvados/repository/revisions/master/show/services/keepproxy and "sdk/go/keepclient":https://arvados.org/projects/arvados/repository/revisions/master/show/sdk/go/keepclient directories in the arvados source tree.