commit | c6e512b136e8c27bb144c0f8b625e833fbae878a | [log] [tgz] |
---|---|---|
author | Ben Browning <ben324@gmail.com> | Wed Sep 20 15:21:51 2017 -0400 |
committer | Ying Chun Guo <guoyingc@cn.ibm.com> | Fri Sep 22 11:14:24 2017 +0800 |
tree | f200fb2416fb601368a7543e66284f5d4bfe014e | |
parent | d9d11f0b21f8c32b3d78cd632d41a69a818be200 [diff] |
Don't assume apihost is https for sdk and action urls (#2748) * Don't assume apihost is https for sdk and action urls Reuse the getURLBase utility method when computing the URL for sdk downloads and action URLs. This fixes #2720 and fixes #2719. * Cleanup some trailing whitespace I missed * Missed this import in last-second rebase * Update debug messages to match `GetURLBase` method name
This project openwhisk-client-go
is a Go client library to access Openwhisk API.
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.
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)
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)
}