|
1 | | -# controller-sdk-go |
2 | | -The Go SDK for the Deis Controller API |
| 1 | +# Controller Go SDK |
| 2 | +[](https://travis-ci.org/deis/controller-sdk-go) |
| 3 | +[](https://goreportcard.com/report/github.com/deis/controller-sdk-go) |
| 4 | +[](https://codebeat.co/projects/github-com-deis-controller-sdk-go) |
| 5 | +[](https://godoc.org/github.com/deis/controller-sdk-go) |
| 6 | + |
| 7 | +This is the Go SDK for interacting with the [Deis Controller](https://github.com/deis/controller). |
| 8 | + |
| 9 | +### Usage |
| 10 | + |
| 11 | +```go |
| 12 | +import deis "github.com/deis/controller-sdk-go" |
| 13 | +import "github.com/deis/controller-sdk-go/apps" |
| 14 | +``` |
| 15 | + |
| 16 | +Construct a deis client to interact with the controller API. Then, get the first 100 apps the user has access to. |
| 17 | + |
| 18 | +```go |
| 19 | +// Verify SSL, Controller URL, API Token |
| 20 | +client, err := deis.New(true, "deis.test.io", "abc123") |
| 21 | +if err != nil { |
| 22 | + log.Fatal(err) |
| 23 | +} |
| 24 | +apps, _, err := apps.List(client, 100) |
| 25 | +if err != nil { |
| 26 | + log.Fatal(err) |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +### Authentication |
| 31 | + |
| 32 | +```go |
| 33 | +import deis "github.com/deis/controller-sdk-go" |
| 34 | +import "github.com/deis/controller-sdk-go/auth" |
| 35 | +``` |
| 36 | + |
| 37 | +If you don't already have a token for a user, you can retrieve one with a username and password. |
| 38 | + |
| 39 | +```go |
| 40 | +// Create a client with a blank token to pass to login. |
| 41 | +client, err := deis.New(true, "deis.test.io", "") |
| 42 | +if err != nil { |
| 43 | + log.Fatal(err) |
| 44 | +} |
| 45 | +token, err := auth.Login(client, "user", "password") |
| 46 | +if err != nil { |
| 47 | + log.Fatal(err) |
| 48 | +} |
| 49 | +// Set the client to use the retrieved token |
| 50 | +client.Token = token |
| 51 | +``` |
| 52 | + |
| 53 | +For a complete usage guide to the SDK, see [full package documentation](https://godoc.org/github.com/deis/controller-sdk-go). |
0 commit comments