[ARVADOS] updated: c8b329a7764af3094d46b79441b9f9b07605abb2

git at public.curoverse.com git at public.curoverse.com
Tue Sep 16 16:54:27 EDT 2014


Summary of changes:
 doc/_includes/_example_sdk_go.liquid               | 109 +++++++++++++++++++++
 .../_example_sdk_go_collection_list.liquid         |  27 -----
 doc/_includes/_example_sdk_go_imports.liquid       |   4 +
 doc/sdk/go/index.html.textile.liquid               |  56 +----------
 4 files changed, 118 insertions(+), 78 deletions(-)
 create mode 100644 doc/_includes/_example_sdk_go.liquid
 delete mode 100644 doc/_includes/_example_sdk_go_collection_list.liquid
 create mode 100644 doc/_includes/_example_sdk_go_imports.liquid

       via  c8b329a7764af3094d46b79441b9f9b07605abb2 (commit)
       via  3babb86cbbb3275d55b1cb928248d0cff436fb3f (commit)
      from  f6ea610fcc842abdbc9cfe2dd10a64debc81ac1a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c8b329a7764af3094d46b79441b9f9b07605abb2
Author: mishaz <misha at curoverse.com>
Date:   Tue Sep 16 20:52:40 2014 +0000

    Combined all examples into one big, runable source file with syntax coloring.
    
    Found and fixed some bugs in example code.
    Added example of requesting manifest text.
    Turned references to source directories into links.
    syntax-colored import statemtns.

diff --git a/doc/_includes/_example_sdk_go.liquid b/doc/_includes/_example_sdk_go.liquid
new file mode 100644
index 0000000..08124e6
--- /dev/null
+++ b/doc/_includes/_example_sdk_go.liquid
@@ -0,0 +1,109 @@
+package main
+
+
+// *******************
+// Import the modules.
+//
+// Our examples don't use keepclient, but they do use fmt and log to
+// display output.
+
+import (
+	"fmt"
+	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"log"
+)
+
+func main() {
+
+
+	// ********************************
+	// Set up an API client user agent.
+	//
+
+	arv, err := arvadosclient.MakeArvadosClient()
+	if err != nil {
+		log.Fatalf("Error setting up arvados client %s", err.Error())
+	}
+
+
+	// *****************************************
+	// Print the full name of the current user.
+	//
+
+	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 {
+		log.Fatalf("error querying current user", err.Error())
+	}
+
+	log.Printf("Logged in as %s (uuid %s)", u.FullName, u.Uuid)
+
+
+	// ********************************************************
+	// Print all fields from the first five collections returned.
+	//
+	// Note that some fields, are not returned by default and have to be
+	// requested. See below for an example.
+
+	var results map[string]interface{}
+
+	params := arvadosclient.Dict{"limit": 5}
+
+	err = arv.List("collections", params, &results)
+	if err != nil {
+		log.Fatalf("error querying collections", err.Error())
+	}
+
+	printArvadosResults(results)
+
+
+	// *********************************************************
+	// Print some fields from the first two collections returned.
+	//
+	// We also print manifest_test, which has to be explicitly requested.
+	//
+
+	collection_fields_wanted := []string{"manifest_text", "owner_uuid", "uuid"}
+	params = arvadosclient.Dict{"limit": 2, "select": collection_fields_wanted}
+
+	err = arv.List("collections", params, &results)
+	if err != nil {
+		log.Fatalf("error querying collections", err.Error())
+	}
+
+	printArvadosResults(results)
+}
+
+
+// A helper method which will print out a result map returned by
+// arvadosclient.
+func printArvadosResults(results map[string]interface{}) {
+	for key, value := range results {
+		// "items", if it exists, holds a map.
+		// So we print it prettily below.
+		if key != "items" {
+			fmt.Println(key, ":", value)
+		}
+	}
+
+	if value, ok := results["items"]; ok {
+		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)
+				}
+			}
+		}
+	}
+}
diff --git a/doc/_includes/_example_sdk_go_collection_list.liquid b/doc/_includes/_example_sdk_go_collection_list.liquid
deleted file mode 100644
index fecf909..0000000
--- a/doc/_includes/_example_sdk_go_collection_list.liquid
+++ /dev/null
@@ -1,27 +0,0 @@
-	var collections map[string]interface{}
-
-	params := arvadosclient.Dict{"limit": 10}
-
-	err = arv.List("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)
-		}
-	}
diff --git a/doc/_includes/_example_sdk_go_imports.liquid b/doc/_includes/_example_sdk_go_imports.liquid
new file mode 100644
index 0000000..fe2cfca
--- /dev/null
+++ b/doc/_includes/_example_sdk_go_imports.liquid
@@ -0,0 +1,4 @@
+import (
+	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"git.curoverse.com/arvados.git/sdk/go/keepclient"
+)
diff --git a/doc/sdk/go/index.html.textile.liquid b/doc/sdk/go/index.html.textile.liquid
index e4653b2..58446a9 100644
--- a/doc/sdk/go/index.html.textile.liquid
+++ b/doc/sdk/go/index.html.textile.liquid
@@ -12,59 +12,13 @@ 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.)
-
-<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>
-
-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:
+You can save this source as a .go file and run it:
 
 <notextile>{% code 'example_sdk_go' as go %}</notextile>
 

commit 3babb86cbbb3275d55b1cb928248d0cff436fb3f
Author: mishaz <misha at curoverse.com>
Date:   Tue Sep 16 20:01:56 2014 +0000

    Moved file.

diff --git a/doc/sdk/go/index.html.textile.liquid b/doc/sdk/go/index.html.textile.liquid
index e4e3821..e4653b2 100644
--- a/doc/sdk/go/index.html.textile.liquid
+++ b/doc/sdk/go/index.html.textile.liquid
@@ -66,6 +66,6 @@ Get the User object for the current user:
 
 Print all returned fields for collections:
 
-{% code 'example_sdk_go_collection_list' as go %}
+<notextile>{% code 'example_sdk_go' as go %}</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.

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list