SDKs

Go SDK

yet-sdk-go: one typed client for every product of your company. The CLI and the Terraform provider are built on it.

Install

bash
go get github.com/yetcombr/yet-sdk-go

A client

A client holds one API key, and finds your company’s addresses from it:

main.go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	yet "github.com/yetcombr/yet-sdk-go"
)

func main() {
	client, err := yet.New(yet.Config{APIKey: os.Getenv("YET_API_KEY")})
	if err != nil {
		log.Fatal(err)
	}
	envs, err := client.Cloud.Environments.List(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	for _, e := range envs {
		fmt.Println(e.Name, e.Domain)
	}
}

yet.ConfigFromEnv() reads the same from the environment — what the CLI and the provider fall back on:

VariableFieldDefault
YET_API_KEYAPIKey—
YET_BASE_DOMAINBaseDomainyet.com.br
YET_CLOUD_URLCloudURLhttps://cloud.<base>
YET_WORKSPACE_URLWorkspaceURLhttps://<company>.<base>

Product by product

The client has a field per product, and a service per thing in it:

ProductServices
client.SettingsWorkspace, People, Apps
client.IAMAccess, Keys, Activity
client.CloudRacks, Servers, Runtimes, Pools, Environments, Namespaces, Applications, Databases, DNS

Settings

go
people, members, err := client.Settings.People.List(ctx)

email, err := client.Settings.People.Add(ctx, yet.NewPerson{
	FullName: "Ana Costa",
	Via:      "password",
	Password: password,
	Mailbox:  &yet.Mailbox{Name: "ana", Domains: []string{"acme.dev"}},
})

err = client.Settings.Apps.SetOff(ctx, []string{"sketch"})

Cloud

go
server, err := client.Cloud.Servers.Create(ctx, "box", "")
join, err := client.Cloud.Servers.Join(ctx, server.ID)
fmt.Println(join.Command) // run it on the machine

db, err := client.Cloud.Databases.Create(ctx, "postgres", "orders", env.ID)

release, deployment, err := client.Cloud.Applications.Release(ctx, app.ID, "ghcr.io/acme/api:1.4.0")

Fields a change may leave as they are are pointers: nil keeps them, a value sets them.

go
replicas := 3
_, err := client.Cloud.Applications.Update(ctx, app.ID, yet.ApplicationInput{Replicas: &replicas})

Errors

A refusal is a *yet.Error, with Yet’s own words in Message. yet.IsNotFound and yet.IsConflict tell the usual ones apart:

go
env, err := client.Cloud.Environments.Get(ctx, id)
switch {
case yet.IsNotFound(err):
	// gone
case err != nil:
	var e *yet.Error
	if errors.As(err, &e) {
		log.Printf("%d: %s", e.StatusCode, e.Message)
	}
}
The SDK is versioned on its own, in SemVer. While below 1.0, a minor version may change what it exposes; its CHANGELOG says how.