Load the credentials for the client go library (#29)

There are two ways to configure the credentials for client go, which are local wskprops, and
whisk.properties from openwhisk in a precedence descending order.

For local wskprops: we can specify the path of the local properties file or it will
by default look up the file under system HOME dir. The valid file name is .wskprops.

For openwhisk properties file, we will look up the OPENWHISK_HOME directory to load whisk.properties
in order to get the credentials to access openwhisk service.

Closes-Bug: #22
9 files changed
tree: fccec240e22193dfd0082bef065bf1ee641699c5
  1. Godeps/
  2. tools/
  3. whisk/
  4. wski18n/
  5. .gitignore
  6. .travis.yml
  7. CONTRIBUTING.md
  8. LICENSE.txt
  9. Makefile
  10. README.md
README.md

Openwhisk Client Go

License Build Status

This project openwhisk-client-go is a Go client library to access Openwhisk API.

Disclaimer

This project is currently on an experimental stage. We periodically synchronize the source code of this repository with the Go whisk folder in OpenWhisk. The framework of test cases is under construction for this repository. Please contribute to the Go whisk folder in OpenWhisk for any Go whisk changes, before we officially announce the separation of OpenWhisk CLI from OpenWhisk.

Usage

import "github.com/apache/incubator-openwhisk-client-go/whisk"

Construct a new whisk client, then use various services to access different parts of the whisk api. For example to get the hello action:

client, _ := whisk.NewClient(http.DefaultClient, nil)
action, resp, err := client.Actions.List("hello")

Some API methods have optional parameters that can be passed. For example, to list the first 30 actions, after the 30th action:

client, _ := whisk.NewClient(http.DefaultClient, nil)

options := &whisk.ActionListOptions{
  Limit: 30,
  Skip: 30,
}

actions, resp, err := client.Actions.List(options)

Whisk can be configured by passing in a *whisk.Config object as the second argument to whisk.New( ... ). For example:

u, _ := url.Parse("https://whisk.stage1.ng.bluemix.net:443/api/v1/")
config := &whisk.Config{
  Namespace: "_",
  AuthKey: "aaaaa-bbbbb-ccccc-ddddd-eeeee",
  BaseURL: u
}
client, err := whisk.Newclient(http.DefaultClient, config)

Example

import (
  "net/http"
  "net/url"

  "github.com/apache/incubator-openwhisk-client-go/whisk"
)

func main() {
  client, err := whisk.NewClient(http.DefaultClient, nil)
  if err != nil {
    fmt.Println(err)
    os.Exit(-1)
  }

  options := &whisk.ActionListOptions{
    Limit: 30,
    Skip: 30,
  }

  actions, resp, err := client.Actions.List(options)
  if err != nil {
    fmt.Println(err)
    os.Exit(-1)
  }

  fmt.Println("Returned with status: ", resp.Status)
  fmt.Println("Returned actions: \n%+v", actions)

}