Skip to content

Latest commit

 

History

History
111 lines (92 loc) · 3.65 KB

File metadata and controls

111 lines (92 loc) · 3.65 KB

Controller Go SDK

Build Status codecov Go Report Card codebeat badge GoDoc

This is the Go SDK for interacting with the Drycc Controller.

Usage

import drycc "github.com/drycc/controller-sdk-go"
import "github.com/drycc/controller-sdk-go/apps"

Construct a drycc client to interact with the controller API. Then, get the first 100 apps the user has access to.

//                    Verify SSL, Controller URL, API Token
client, err := drycc.New(true, "drycc.test.io", "abc123")
if err != nil {
    log.Fatal(err)
}
apps, _, err := apps.List(client, 100)
if err != nil {
    log.Fatal(err)
}

// Create app in a workspace (workspace is required in the new API)
app, err := apps.New(client, "example-go", "team-a")
if err != nil {
    log.Fatal(err)
}

_ = app

Workspaces

import drycc "github.com/drycc/controller-sdk-go"
import "github.com/drycc/controller-sdk-go/workspaces"
import members "github.com/drycc/controller-sdk-go/workspaces/members"
import invitations "github.com/drycc/controller-sdk-go/workspaces/invitations"
client, err := drycc.New(true, "drycc.test.io", "abc123")
if err != nil {
    log.Fatal(err)
}

ws, err := workspaces.Create(client, "team-a", "team-a@example.com")
if err != nil {
    log.Fatal(err)
}

_, _, err = members.List(client, ws.Name, 100)
if err != nil {
    log.Fatal(err)
}

_, err = invitations.Create(client, ws.Name, "new-user@example.com")
if err != nil {
    log.Fatal(err)
}

Authentication

import drycc "github.com/drycc/controller-sdk-go"
import "github.com/drycc/controller-sdk-go/auth"

If you don't already have a token for a user, you can retrieve one with a username and password.

// Create a client with a blank token to pass to login.
client, err := drycc.New(true, "drycc.test.io", "")
if err != nil {
    log.Fatal(err)
}
token, err := auth.Login(client, "user", "password")
if err != nil {
    log.Fatal(err)
}
// Set the client to use the retrieved token
client.Token = token

For a complete usage guide to the SDK, see full package documentation.