SDKs
Go reference
yet-sdk-go, by product and by service, as its source has it.Settings
client.Settings.Workspace
WorkspaceService is the company itself: its name, and who may join.
func Get(ctx context.Context) (*Workspace, error)Get is the company: its name, who may join, the apps it has off and its domains.
w, err := client.Settings.Workspace.Get(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(w.Name, w.Domains)func Rename(ctx context.Context, name string) errorRename is the name the company's people see, on every app and at sign-in.
if err := client.Settings.Workspace.Rename(ctx, "Acme"); err != nil {
log.Fatal(err)
}func SetOpenJoin(ctx context.Context, open bool) errorSetOpenJoin is whether anyone at the company's domains may join by themselves.
if err := client.Settings.Workspace.SetOpenJoin(ctx, true); err != nil {
log.Fatal(err)
}client.Settings.People
PeopleService is the company's people: with a mailbox here, or who only sign in.
func List(ctx context.Context) ([]Person, []Member, error)List is everyone of the company: with a mailbox here, and those who only sign in.
people, members, err := client.Settings.People.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, p := range people {
fmt.Println(p.Email, p.FullName)
}
for _, m := range members {
fmt.Println(m.Email)
}func Get(ctx context.Context, id string) (*Person, error)Get is one person with a mailbox here, by id.
p, err := client.Settings.People.Get(ctx, "ps_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(p.FullName, p.RunsSettings)func Add(ctx context.Context, p NewPerson) (string, error)Add adds someone, and says the address they sign in with.
email, err := client.Settings.People.Add(ctx, yet.NewPerson{
FullName: "Ana Costa",
Via: "password",
Password: "correct-horse-battery-staple",
Mailbox: &yet.Mailbox{Name: "ana", Domains: []string{"acme.dev"}},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(email)func Rename(ctx context.Context, id, fullName string) errorRename is the person's name: on their sign-in, and on their mailbox.
if err := client.Settings.People.Rename(ctx, "ps_1", "Ana Costa"); err != nil {
log.Fatal(err)
}func SetRunsSettings(ctx context.Context, id string, on bool) errorSetRunsSettings is whether the person may open the company's Settings.
if err := client.Settings.People.SetRunsSettings(ctx, "ps_1", true); err != nil {
log.Fatal(err)
}func SetPassword(ctx context.Context, id, password string) errorSetPassword is a new password; they use it the next time they sign in.
if err := client.Settings.People.SetPassword(ctx, "ps_1", "correct-horse-battery-staple"); err != nil {
log.Fatal(err)
}func Remove(ctx context.Context, id string) errorRemove takes the person away: their sign-in, and their mailbox with all its mail.
if err := client.Settings.People.Remove(ctx, "ps_1"); err != nil {
log.Fatal(err)
}func Invite(ctx context.Context, email string) errorInvite sends someone at one of the company's domains a link to join, for a day. Add, with Via "invite", invites at any address, with a mailbox or not.
if err := client.Settings.People.Invite(ctx, "ana@acme.dev"); err != nil {
log.Fatal(err)
}func RemoveMember(ctx context.Context, email string) errorRemoveMember lets someone with no mailbox here go.
if err := client.Settings.People.RemoveMember(ctx, "billing@example.com"); err != nil {
log.Fatal(err)
}client.Settings.Apps
AppsService is which apps the company's people see.
func Off(ctx context.Context) ([]string, error)Off is the apps the company's people do not see.
off, err := client.Settings.Apps.Off(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(off)func SetOff(ctx context.Context, off []string) errorSetOff turns off these apps, and on every other one.
if err := client.Settings.Apps.SetOff(ctx, []string{"sketch", "agile"}); err != nil {
log.Fatal(err)
}client.Settings.Domains
DomainsService is the company's domains: asked for, shown, and with mail here.
func List(ctx context.Context) ([]Domain, []DomainClaim, error)List is the company's domains, and those it asked for and has not shown yet.
domains, claims, err := client.Settings.Domains.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, d := range domains {
fmt.Println(d.Name, d.Mail)
}
fmt.Println(len(claims), "waiting")func Claim(ctx context.Context, name string) (*DomainClaim, error)Claim asks for a domain: it is the company's once Verify finds its DNS shows it.
claim, err := client.Settings.Domains.Claim(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
fmt.Println(claim.Domain, claim.TXT)func Verify(ctx context.Context, name string) (how string, err error)Verify checks an asked-for domain's DNS and, shown, makes it the company's; how says what showed it, "txt" or "cloud". Not shown yet is a conflict.
how, err := client.Settings.Domains.Verify(ctx, "acme.dev")
if yet.IsConflict(err) {
log.Fatal("acme.dev's DNS does not show it yet")
}
if err != nil {
log.Fatal(err)
}
fmt.Println(how)func CancelClaim(ctx context.Context, name string) errorCancelClaim gives up asking for a domain.
if err := client.Settings.Domains.CancelClaim(ctx, "acme.dev"); err != nil {
log.Fatal(err)
}func HostClaimInCloud(ctx context.Context, name string) (map[string]any, error)HostClaimInCloud makes an asked-for domain's zone in the company's Cloud: pointed there, its zone answering shows it the company's. The zone, and the nameservers to point the domain to, as Cloud answers.
out, err := client.Settings.Domains.HostClaimInCloud(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
zone := out["zone"].(map[string]any)
fmt.Println(zone["nameservers"])func EnableMail(ctx context.Context, name string) ([]string, error)EnableMail turns the domain's mail on: the mail server, SES, a mailbox for each of its people. What did not go as it should comes back as warnings.
warnings, err := client.Settings.Domains.EnableMail(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
fmt.Println(len(warnings), "warnings")func Health(ctx context.Context, name string) (map[string]any, error)Health is a domain with mail as the internet and SES see it: its DNS records checked, its standing in SES, the week's numbers, its Cloud zone.
health, err := client.Settings.Domains.Health(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
for _, r := range health["dns"].([]any) {
check := r.(map[string]any)
fmt.Println(check["type"], check["ok"])
}func RegisterSES(ctx context.Context, name string) errorRegisterSES registers the domain in the SES it sends through — or finishes it.
if err := client.Settings.Domains.RegisterSES(ctx, "acme.dev"); err != nil {
log.Fatal(err)
}func SetPaused(ctx context.Context, name string, paused bool) errorSetPaused pauses or resumes the domain's sending in its SES.
if err := client.Settings.Domains.SetPaused(ctx, "acme.dev", true); err != nil {
log.Fatal(err)
}func PublishDNS(ctx context.Context, name string) (map[string]any, error)PublishDNS puts the domain's mail records in Cloud, making its zone there first if need be.
out, err := client.Settings.Domains.PublishDNS(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
fmt.Println("added", out["added"], "fixed", out["fixed"])func Remove(ctx context.Context, name string) errorRemove takes a domain with mail off the mail server and out of the company — only one with nobody on it.
if err := client.Settings.Domains.Remove(ctx, "acme.dev"); err != nil {
log.Fatal(err)
}client.Settings.Addresses
AddressesService is a domain's addresses that are not a person: its aliases, its lists and its catch-all.
func Get(ctx context.Context, domain string) (*Addresses, error)Get is the domain's aliases, lists and catch-all.
a, err := client.Settings.Addresses.Get(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
for _, alias := range a.Aliases {
fmt.Println(alias.Address, "→", alias.Owner)
}
fmt.Println("catch-all:", a.CatchAll)func AddAlias(ctx context.Context, domain, accountID, name string) errorAddAlias gives the person another address, name@ their own domain.
if err := client.Settings.Addresses.AddAlias(ctx, "acme.dev", "ps_1", "contact"); err != nil {
log.Fatal(err)
}func RemoveAlias(ctx context.Context, domain, accountID, name string) errorRemoveAlias takes one of the person's other addresses away; their own stays.
if err := client.Settings.Addresses.RemoveAlias(ctx, "acme.dev", "ps_1", "contact"); err != nil {
log.Fatal(err)
}func SetCatchAll(ctx context.Context, domain, address string) errorSetCatchAll is where mail to addresses that do not exist goes; empty turns it off.
if err := client.Settings.Addresses.SetCatchAll(ctx, "acme.dev", "ana@acme.dev"); err != nil {
log.Fatal(err)
}func CreateList(ctx context.Context, domain string, l NewList) (*MailList, error)CreateList makes a list in the domain.
list, err := client.Settings.Addresses.CreateList(ctx, "acme.dev", yet.NewList{
Name: "sales",
Description: "Sales",
Recipients: []string{"ana@acme.dev"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(list.ID, list.Address)func GetList(ctx context.Context, id string) (*MailList, error)GetList is one of the company's lists, by id.
list, err := client.Settings.Addresses.GetList(ctx, "ml_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(list.Address, list.Recipients)func UpdateList(ctx context.Context, id string, change ListChange) errorUpdateList replaces the list's recipients, and its description when given.
err := client.Settings.Addresses.UpdateList(ctx, "ml_1", yet.ListChange{
Description: yet.Ptr("Everyone at Acme"),
Recipients: []string{"ana@acme.dev"},
})
if err != nil {
log.Fatal(err)
}func DeleteList(ctx context.Context, id string) errorDeleteList removes one of the company's lists, by id.
if err := client.Settings.Addresses.DeleteList(ctx, "ml_2"); err != nil {
log.Fatal(err)
}client.Settings.Sending
SendingService is how the company's mail leaves.
func Get(ctx context.Context) (*Sending, error)Get is how the company's mail leaves now, and whether Yet's SES is open to it.
s, err := client.Settings.Sending.Get(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(s.Sending, s.SESAllowed)func Set(ctx context.Context, sending string) ([]string, error)Set chooses "yet" or "own"; the company's domains move to that SES, and what did not move comes back as warnings.
warnings, err := client.Settings.Sending.Set(ctx, "own")
if err != nil {
log.Fatal(err)
}
fmt.Println(len(warnings), "warnings")client.Settings.Connections.GitHub
GitHubConnection is the company's GitHub, which Cloud builds from and runs GitHub's runners with.
func Get(ctx context.Context) (*Connection, error)Get is how the company's GitHub is connected: through Yet's GitHub App, with a token, or not at all.
gh, err := client.Settings.Connections.GitHub.Get(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(gh.Account, gh.Connected, gh.App)func SetToken(ctx context.Context, token string) (*Connection, error)SetToken connects GitHub with a token: GitHub is asked whose it is, so a wrong one is refused at once. It takes the place of Yet's GitHub App, if it was installed.
gh, err := client.Settings.Connections.GitHub.SetToken(ctx, os.Getenv("GITHUB_TOKEN"))
if err != nil {
log.Fatal(err)
}
fmt.Println(gh.Account, gh.Connected)func Remove(ctx context.Context) errorRemove disconnects GitHub: builds and runners from it stop.
if err := client.Settings.Connections.GitHub.Remove(ctx); err != nil {
log.Fatal(err)
}func InstallURL(ctx context.Context, returnTo string) (string, error)InstallURL is where a person installs Yet's GitHub App on the company's organization, coming back to returnTo after: it takes a person, on GitHub.
url, err := client.Settings.Connections.GitHub.InstallURL(ctx, "https://acme.yet.com.br/settings/connections")
if err != nil {
log.Fatal(err)
}
fmt.Println(url)func Repositories(ctx context.Context) ([]Repository, error)Repositories are those the connection reaches, to build from.
repos, err := client.Settings.Connections.GitHub.Repositories(ctx)
if err != nil {
log.Fatal(err)
}
for _, r := range repos {
fmt.Println(r.FullName, r.DefaultBranch)
}client.Settings.Connections.AWS
AWSConnection is the company's AWS key, for its own SES and Drive's bucket.
func Get(ctx context.Context) (*AWSKey, error)Get is the key the company connected, or nil when there is none.
key, err := client.Settings.Connections.AWS.Get(ctx)
if err != nil {
log.Fatal(err)
}
if key == nil {
fmt.Println("no AWS key")
return
}
fmt.Println(key.Region, key.AccessKeyID)func Connect(ctx context.Context, region, accessKeyID, secretAccessKey string) ([]string, error)Connect checks the key with AWS, keeps it sealed and registers the company's domains in its SES when it sends through its own.
warnings, err := client.Settings.Connections.AWS.Connect(ctx, "us-east-1",
os.Getenv("AWS_ACCESS_KEY_ID"), os.Getenv("AWS_SECRET_ACCESS_KEY"))
if err != nil {
log.Fatal(err)
}
fmt.Println(len(warnings), "warnings")func Disconnect(ctx context.Context) errorDisconnect forgets the key. A company sending through its own SES stops sending.
if err := client.Settings.Connections.AWS.Disconnect(ctx); err != nil {
log.Fatal(err)
}client.Settings.Storage
StorageService is where Drive keeps the company's files.
func Get(ctx context.Context) (*Storage, error)Get is Drive's bucket, or nil while Drive keeps the files itself.
st, err := client.Settings.Storage.Get(ctx)
if err != nil {
log.Fatal(err)
}
if st == nil {
fmt.Println("Drive keeps the files itself")
return
}
fmt.Println(st.Bucket, st.Prefix)func Set(ctx context.Context, st Storage) errorSet points Drive at the bucket, once a write to it shows the key may use it.
if err := client.Settings.Storage.Set(ctx, yet.Storage{Bucket: "acme-drive", Prefix: "drive/"}); err != nil {
log.Fatal(err)
}func Remove(ctx context.Context) errorRemove sends Drive back to keeping the files itself; the bucket keeps what is in it.
if err := client.Settings.Storage.Remove(ctx); err != nil {
log.Fatal(err)
}client.Settings.Logo
LogoService is the company's logo on its sign-in page.
func Get(ctx context.Context) (*Logo, error)Get is the company's logo, or nil while the sign-in page shows Yet's mark.
logo, err := client.Settings.Logo.Get(ctx)
if err != nil {
log.Fatal(err)
}
if logo == nil {
fmt.Println("Yet's mark")
return
}
fmt.Println(logo.ContentType, len(logo.Data), "bytes")func Set(ctx context.Context, l Logo) errorSet puts the logo on the company's sign-in page: a PNG, JPEG, WebP, GIF or SVG under 256 KB.
svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"/></svg>`)
if err := client.Settings.Logo.Set(ctx, yet.Logo{ContentType: "image/svg+xml", Data: svg}); err != nil {
log.Fatal(err)
}func Remove(ctx context.Context) errorRemove puts Yet's own mark back on the sign-in page.
if err := client.Settings.Logo.Remove(ctx); err != nil {
log.Fatal(err)
}IAM
client.IAM.Access
AccessService is the roles people have in Cloud.
func List(ctx context.Context) ([]Grant, error)List is every role given, for the company's admins.
grants, err := client.IAM.Access.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, g := range grants {
fmt.Println(g.Email, g.Environment, g.Role)
}client.IAM.Keys
KeysService is people's API keys.
func List(ctx context.Context) ([]Key, error)List is the key's person's own keys.
keys, err := client.IAM.Keys.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, k := range keys {
fmt.Println(k.Name, k.Prefix)
}func Delete(ctx context.Context, id string) errorDelete revokes one of the person's own keys.
if err := client.IAM.Keys.Delete(ctx, "key_1"); err != nil {
log.Fatal(err)
}func ListAll(ctx context.Context) ([]Key, error)ListAll is everyone's keys, for the company's admins.
keys, err := client.IAM.Keys.ListAll(ctx)
if err != nil {
log.Fatal(err)
}
for _, k := range keys {
fmt.Println(k.Email, k.Name)
}func Revoke(ctx context.Context, id string) errorRevoke revokes anyone's key, for the company's admins.
if err := client.IAM.Keys.Revoke(ctx, "key_2"); err != nil {
log.Fatal(err)
}client.IAM.Activity
ActivityService is what was done in the company, and by whom.
func List(ctx context.Context) ([]Event, error)List is what was done, the latest first, for the company's admins.
events, err := client.IAM.Activity.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, e := range events {
fmt.Println(e.Actor, e.Via, e.Action, e.Target)
}Cloud
client.Cloud
CloudService is Yet Cloud: where the company's things run — its racks, servers, runtimes and pools — and what runs there: environments, applications, databases and DNS.
func Me(ctx context.Context) (*Me, error)Me is who the key is in Cloud: their role, everywhere and by environment.
me, err := client.Cloud.Me(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(me.Email, me.Role)func Stacks(ctx context.Context) ([]Stack, error)Stacks is every way a runtime can be, and whether each is there yet.
stacks, err := client.Cloud.Stacks(ctx)
if err != nil {
log.Fatal(err)
}
for _, st := range stacks {
fmt.Println(st.ID, st.Available)
}client.Cloud.Racks
RacksService is the company's racks; only Cloud admins make or change them.
func List(ctx context.Context) ([]Rack, error)List is every rack.
racks, err := client.Cloud.Racks.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, r := range racks {
fmt.Println(r.ID, r.Name)
}func Get(ctx context.Context, id string) (*Rack, error)Get is one rack, by id.
rack, err := client.Cloud.Racks.Get(ctx, "rk_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(rack.Name, rack.Kind)func Create(ctx context.Context, in RackInput) (*Rack, error)Create makes a rack; for now a local one — aws and gcp are coming.
rack, err := client.Cloud.Racks.Create(ctx, yet.RackInput{Name: yet.Ptr("Home Rack"), Kind: "local"})
if err != nil {
log.Fatal(err)
}
fmt.Println(rack.Name, rack.Kind)func Update(ctx context.Context, id string, in RackInput) (*Rack, error)Update renames the rack, or changes its description.
rack, err := client.Cloud.Racks.Update(ctx, "rk_1", yet.RackInput{
Description: yet.Ptr("The machines in the office and the lab"),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(rack.Description)func Delete(ctx context.Context, id string) errorDelete removes the rack; only one with no servers or runtimes in it.
if err := client.Cloud.Racks.Delete(ctx, "rk_1"); err != nil {
log.Fatal(err)
}client.Cloud.Servers
ServersService is the machines of the company's local racks; only Cloud admins make or change them.
func List(ctx context.Context) ([]Server, error)List is every server, with its agent's status.
servers, err := client.Cloud.Servers.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, s := range servers {
fmt.Println(s.Name, s.Status)
}func Get(ctx context.Context, id string) (*Server, error)Get is one server, by id.
s, err := client.Cloud.Servers.Get(ctx, "sv_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(s.Name, s.OS, s.Arch, s.AgentVersion)func Create(ctx context.Context, name, rackID string) (*Server, error)Create is a server waiting for its machine; rackID may be empty when the company has one local rack.
s, err := client.Cloud.Servers.Create(ctx, "office-2", "rk_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(s.ID, s.Status)func Rename(ctx context.Context, id, name string) (*Server, error)Rename is the server's name: lowercase letters, digits and dashes, up to 32.
s, err := client.Cloud.Servers.Rename(ctx, "sv_1", "office-main")
if err != nil {
log.Fatal(err)
}
fmt.Println(s.Name)func Delete(ctx context.Context, id string) errorDelete removes the server; only one no runtime runs on.
if err := client.Cloud.Servers.Delete(ctx, "sv_2"); err != nil {
log.Fatal(err)
}func Join(ctx context.Context, id string) (*Join, error)Join is a new join token for the server, and the commands to run with it.
join, err := client.Cloud.Servers.Join(ctx, "sv_2")
if err != nil {
log.Fatal(err)
}
// Run on the machine, as root:
fmt.Println(join.Command)client.Cloud.Runtimes
RuntimesService is how things run on the company's servers; only Cloud admins make or change them.
func List(ctx context.Context) ([]Runtime, error)List is every runtime.
runtimes, err := client.Cloud.Runtimes.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, rt := range runtimes {
fmt.Println(rt.Name, rt.Stack, rt.Status)
}func Get(ctx context.Context, id string) (*Runtime, error)Get is one runtime, by id, with how its k3s stands.
rt, err := client.Cloud.Runtimes.Get(ctx, "rt_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(rt.Name, rt.K3s.Ready, rt.K3s.Version)func Create(ctx context.Context, in RuntimeInput) (*Runtime, error)Create makes a runtime of a stack on one of the company's servers.
rt, err := client.Cloud.Runtimes.Create(ctx, yet.RuntimeInput{
Name: yet.Ptr("office-k3s"),
Stack: "local:traefik+k3s",
ServerID: "sv_1",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(rt.ID, rt.Status)func Update(ctx context.Context, id string, in RuntimeInput) (*Runtime, error)Update renames the runtime or sets its ingress — not while its tunnel is its ingress.
rt, err := client.Cloud.Runtimes.Update(ctx, "rt_1", yet.RuntimeInput{Ingress: yet.Ptr("203.0.113.20")})
if err != nil {
log.Fatal(err)
}
fmt.Println(rt.Ingress)func Delete(ctx context.Context, id string) errorDelete removes the runtime, and its tunnel with it; only one no environment runs on, in no pool.
if err := client.Cloud.Runtimes.Delete(ctx, "rt_1"); err != nil {
log.Fatal(err)
}func OpenTunnel(ctx context.Context, id string) (*Runtime, error)OpenTunnel puts the runtime behind a Cloudflare tunnel: its edge.
runtime, err := client.Cloud.Runtimes.OpenTunnel(ctx, "rt_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(runtime.TunnelID, runtime.Ingress)func CloseTunnel(ctx context.Context, id string) (*Runtime, error)CloseTunnel takes the runtime's tunnel away, hostnames and all.
runtime, err := client.Cloud.Runtimes.CloseTunnel(ctx, "rt_1")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%q\n", runtime.TunnelID)func Containers(ctx context.Context, runtimeID string) ([]Container, error)Containers are a Docker runtime's; only Cloud admins define them.
containers, err := client.Cloud.Runtimes.Containers(ctx, "rt_2")
if err != nil {
log.Fatal(err)
}
for _, ct := range containers {
fmt.Println(ct.Name, ct.Image, ct.State)
}func CreateContainer(ctx context.Context, runtimeID string, in ContainerInput) (*Container, error)CreateContainer defines a container on a Docker runtime, for its agent to keep running.
ct, err := client.Cloud.Runtimes.CreateContainer(ctx, "rt_2", yet.ContainerInput{
Name: "uptime",
Image: "louislam/uptime-kuma:1",
Volumes: []string{"uptime:/app/data"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(ct.ID, ct.State)func UpdateContainer(ctx context.Context, runtimeID, id string, in ContainerInput) (*Container, error)UpdateContainer replaces the container's whole definition; a secret sent empty keeps its value.
ct, err := client.Cloud.Runtimes.UpdateContainer(ctx, "rt_2", "ct_1", yet.ContainerInput{
Name: "uptime",
Image: "louislam/uptime-kuma:2",
Volumes: []string{"uptime:/app/data"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(ct.Image)func EnableContainer(ctx context.Context, runtimeID, id string, enabled bool) (*Container, error)EnableContainer turns a container on, or off: the agent takes it away, its definition kept, secrets and all.
ct, err := client.Cloud.Runtimes.EnableContainer(ctx, "rt_2", "ct_1", false)
if err != nil {
log.Fatal(err)
}
fmt.Println(ct.Name, ct.Disabled)func DeleteContainer(ctx context.Context, runtimeID, id string) errorDeleteContainer removes the container, its definition with it.
if err := client.Cloud.Runtimes.DeleteContainer(ctx, "rt_2", "ct_1"); err != nil {
log.Fatal(err)
}func Runners(ctx context.Context, runtimeID string) ([]Runner, error)Runners are a native runtime's; only Cloud admins define them.
runners, err := client.Cloud.Runtimes.Runners(ctx, "rt_3")
if err != nil {
log.Fatal(err)
}
for _, rn := range runners {
for _, c := range rn.Copies {
fmt.Println(rn.Name, c.Replica, c.State)
}
}func CreateRunner(ctx context.Context, runtimeID string, in RunnerInput) (*Runner, error)CreateRunner defines a GitHub runner on a native runtime.
rn, err := client.Cloud.Runtimes.CreateRunner(ctx, "rt_3", yet.RunnerInput{
Name: "mac-builds",
URL: "https://github.com/acme",
Labels: []string{"macos", "arm64"},
Replicas: 2,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(rn.ID, rn.Labels)func UpdateRunner(ctx context.Context, runtimeID, id string, in RunnerInput) (*Runner, error)UpdateRunner replaces the runner's whole definition; an empty GitHubToken keeps the one it has.
rn, err := client.Cloud.Runtimes.UpdateRunner(ctx, "rt_3", "rn_1", yet.RunnerInput{
Name: "mac-builds",
URL: "https://github.com/acme",
Labels: []string{"macos", "arm64"},
Replicas: 4,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(rn.Name, rn.Replicas)func DeleteRunner(ctx context.Context, runtimeID, id string) errorDeleteRunner removes the runner from the runtime.
if err := client.Cloud.Runtimes.DeleteRunner(ctx, "rt_3", "rn_1"); err != nil {
log.Fatal(err)
}client.Cloud.Pools
PoolsService is the company's pools; only Cloud admins make or change them.
func List(ctx context.Context) ([]Pool, error)List is every pool, with its members and its environments.
pools, err := client.Cloud.Pools.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, p := range pools {
fmt.Println(p.Name, len(p.Members), "runtimes")
}func Get(ctx context.Context, id string) (*Pool, error)Get is one pool, by id, with its members and its environments.
p, err := client.Cloud.Pools.Get(ctx, "pl_1")
if err != nil {
log.Fatal(err)
}
for _, env := range p.Environments {
fmt.Println(p.Name, env.Name)
}func Create(ctx context.Context, in PoolInput) (*Pool, error)Create makes a pool of the k3s runtimes in RuntimeIDs, each in no other pool.
p, err := client.Cloud.Pools.Create(ctx, yet.PoolInput{
Name: yet.Ptr("office"),
Color: yet.Ptr("blue"),
RuntimeIDs: &[]string{"rt_1", "rt_4"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(p.ID, len(p.Members))func Update(ctx context.Context, id string, in PoolInput) (*Pool, error)Update changes the pool; RuntimeIDs, when given, are all its members — those left out leave it, and what ran there for the pool goes away.
p, err := client.Cloud.Pools.Update(ctx, "pl_1", yet.PoolInput{
Description: yet.Ptr("Everything in the office"),
Color: yet.Ptr("green"),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(p.Description, p.Color)func Delete(ctx context.Context, id string) errorDelete removes the pool and its tunnel; its runtimes stay, out of it. Only one no environment runs on.
if err := client.Cloud.Pools.Delete(ctx, "pl_1"); err != nil {
log.Fatal(err)
}func OpenTunnel(ctx context.Context, id string) (*Pool, error)OpenTunnel puts the pool behind a Cloudflare tunnel of its own: its edge, for every member.
p, err := client.Cloud.Pools.OpenTunnel(ctx, "pl_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(p.Ingress)func CloseTunnel(ctx context.Context, id string) (*Pool, error)CloseTunnel takes the pool's tunnel away: its hostnames, and its environments' records with them.
p, err := client.Cloud.Pools.CloseTunnel(ctx, "pl_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(p.TunnelID == "", p.Ingress)client.Cloud.Environments
EnvironmentsService is where the company's stages run; only Cloud admins make or change them.
func List(ctx context.Context) ([]Environment, error)List is the environments the key's person has a role in — every one, for a role everywhere.
envs, err := client.Cloud.Environments.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, env := range envs {
fmt.Println(env.Name, env.Domain)
}func Get(ctx context.Context, id string) (*Environment, error)Get is one environment, by id, among those List gives.
env, err := client.Cloud.Environments.Get(ctx, "env_2")
if err != nil {
log.Fatal(err)
}
fmt.Println(env.Name, env.PoolID)func Create(ctx context.Context, in EnvironmentInput) (*Environment, error)Create makes an environment, on a runtime or a pool.
env, err := client.Cloud.Environments.Create(ctx, yet.EnvironmentInput{
Name: "staging",
Color: yet.Ptr("amber"),
RuntimeID: yet.Ptr("rt_1"),
ZoneID: yet.Ptr("zn_1"),
Prefix: yet.Ptr("staging"),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(env.ID, env.Domain)func Update(ctx context.Context, id string, in EnvironmentInput) (*Environment, error)Update changes the environment; its name never changes. Naming a runtime takes it off its pool, and the other way round; one with something deployed moves only between a pool and one of its members.
// From one runtime to the pool it is in.
env, err := client.Cloud.Environments.Update(ctx, "env_2", yet.EnvironmentInput{PoolID: yet.Ptr("pl_1")})
if err != nil {
log.Fatal(err)
}
fmt.Println(env.Name, env.PoolID)func Delete(ctx context.Context, id string) errorDelete removes the environment and its records; only one no application has as a stage.
if err := client.Cloud.Environments.Delete(ctx, "env_1"); err != nil {
log.Fatal(err)
}client.Cloud.Namespaces
NamespacesService is the company's namespaces: developers everywhere and admins make them.
func List(ctx context.Context) ([]Namespace, error)List is every namespace.
namespaces, err := client.Cloud.Namespaces.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, ns := range namespaces {
fmt.Println(ns.ID, ns.Name)
}func Get(ctx context.Context, id string) (*Namespace, error)Get is one namespace, by id.
ns, err := client.Cloud.Namespaces.Get(ctx, "ns_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(ns.Name)func Create(ctx context.Context, name string) (*Namespace, error)Create makes a namespace.
ns, err := client.Cloud.Namespaces.Create(ctx, "shop")
if err != nil {
log.Fatal(err)
}
fmt.Println(ns.ID, ns.Name)func Rename(ctx context.Context, id, name string) (*Namespace, error)Rename is the namespace's name.
ns, err := client.Cloud.Namespaces.Rename(ctx, "ns_2", "tools")
if err != nil {
log.Fatal(err)
}
fmt.Println(ns.Name)func Delete(ctx context.Context, id string) errorDelete removes the namespace, for Cloud admins; only one with no applications.
if err := client.Cloud.Namespaces.Delete(ctx, "ns_2"); err != nil {
log.Fatal(err)
}client.Cloud.Applications
ApplicationsService is what the company runs: developers everywhere and admins make and change it.
func List(ctx context.Context) ([]Application, error)List is every application.
apps, err := client.Cloud.Applications.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, app := range apps {
fmt.Println(app.Namespace, app.Name, app.Repository)
}func Get(ctx context.Context, id string) (*Application, error)Get is one application, by id.
app, err := client.Cloud.Applications.Get(ctx, "app_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(app.Name, app.Stages)func Create(ctx context.Context, in ApplicationInput) (*Application, error)Create makes an application; its namespace, its name and its stages are needed.
app, err := client.Cloud.Applications.Create(ctx, yet.ApplicationInput{
NamespaceID: yet.Ptr("ns_1"),
Name: yet.Ptr("storefront"),
Port: yet.Ptr(3000),
Stages: &[]string{"env_1", "env_2"},
Repository: yet.Ptr("acme/storefront"),
Branch: yet.Ptr("main"),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(app.ID, app.Name)func Update(ctx context.Context, id string, in ApplicationInput) (*Application, error)Update changes the application. A repository just picked, or another branch, is built as it is now, not at the next push.
app, err := client.Cloud.Applications.Update(ctx, "app_1", yet.ApplicationInput{Replicas: yet.Ptr(3)})
if err != nil {
log.Fatal(err)
}
fmt.Println(app.Name, app.Replicas)func Delete(ctx context.Context, id string) errorDelete removes the application, with its releases, its deployments and its own databases; it is gone from every cluster at the agents' next look.
if err := client.Cloud.Applications.Delete(ctx, "app_1"); err != nil {
log.Fatal(err)
}func Release(ctx context.Context, id, image string) (*Release, *Deployment, error)Release makes a release of an image, and deploys it to the first stage.
release, deployment, err := client.Cloud.Applications.Release(ctx, "app_1", "ghcr.io/acme/storefront:1.8.0")
if err != nil {
log.Fatal(err)
}
fmt.Println(release.Number, deployment.EnvironmentID, deployment.Status)func Releases(ctx context.Context, id string) ([]Release, error)Releases are the application's latest 50, the newest first.
releases, err := client.Cloud.Applications.Releases(ctx, "app_1")
if err != nil {
log.Fatal(err)
}
for _, r := range releases {
fmt.Println(r.Number, r.Image)
}func Deploy(ctx context.Context, id, environmentID, releaseID string) (*Deployment, error)Deploy sends a release to an environment.
// Release 7 back to production.
d, err := client.Cloud.Applications.Deploy(ctx, "app_1", "env_2", "rl_7")
if err != nil {
log.Fatal(err)
}
fmt.Println(d.ID, d.Status)func Promote(ctx context.Context, id, fromEnvironmentID string) (*Deployment, error)Promote sends what runs in one stage to the next.
// What runs in staging, to production.
d, err := client.Cloud.Applications.Promote(ctx, "app_1", "env_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(d.EnvironmentID, d.ReleaseID)func Build(ctx context.Context, id, buildID string) (*Build, []BuildRun, error)Build is one build, with how each runtime ran it.
build, runs, err := client.Cloud.Applications.Build(ctx, "app_1", "bd_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(build.Commit, build.Status)
for _, run := range runs {
fmt.Println(run.Runtime, run.Status)
}func BuildNow(ctx context.Context, id string) (*Build, error)BuildNow builds its branch as it is now — its latest commit — without waiting for a push: a release, deployed to its first stage once built.
build, err := client.Cloud.Applications.BuildNow(ctx, "app_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(build.Commit, build.Status)func Resources(ctx context.Context, id string) ([]Database, error)Resources are the application's own databases, and its environments' it is attached to — AttachedAs says in which variable.
dbs, err := client.Cloud.Applications.Resources(ctx, "app_1")
if err != nil {
log.Fatal(err)
}
for _, db := range dbs {
fmt.Println(db.Name, db.Kind, db.EnvVar+db.AttachedAs)
}func CreateResource(ctx context.Context, id string, in ResourceInput) (*Database, error)CreateResource adds a database of its own to the application, run beside it on each of its stages. How it runs changes with Databases.Update.
db, err := client.Cloud.Applications.CreateResource(ctx, "app_1", yet.ResourceInput{Kind: "overlite"})
if err != nil {
log.Fatal(err)
}
fmt.Println(db.ID, db.EnvVar, db.Placement)func DeleteResource(ctx context.Context, id, resourceID string) errorDeleteResource removes one of the application's own databases: it stops at the agents' next look, its volume kept on each server.
if err := client.Cloud.Applications.DeleteResource(ctx, "app_1", "db_2"); err != nil {
log.Fatal(err)
}func Attach(ctx context.Context, id, databaseID, envVar string) (*Database, error)Attach hands the application one of its environments' databases, on its stage there, in a variable — the database's own when envVar is "".
db, err := client.Cloud.Applications.Attach(ctx, "app_1", "db_1", "ORDERS_URL")
if err != nil {
log.Fatal(err)
}
for _, a := range db.Attached {
fmt.Println(db.Name, "→", a.Application, a.EnvVar)
}func Detach(ctx context.Context, id, databaseID string) errorDetach takes an environment's database away from the application; the database stays.
if err := client.Cloud.Applications.Detach(ctx, "app_1", "db_1"); err != nil {
log.Fatal(err)
}func OpenSession(ctx context.Context, id string, in SessionInput) (*Session, error)OpenSession is the application's logs, or a shell in a copy of it, on one of its stages; a shell is a developer's, in that environment.
s, err := client.Cloud.Applications.OpenSession(ctx, "app_1", yet.SessionInput{Kind: "logs", EnvironmentID: "env_2"})
if err != nil {
log.Fatal(err)
}
// A WebSocket to read the logs from, for a few minutes.
fmt.Println(s.URL)client.Cloud.Databases
DatabasesService is the company's databases: its environments', and its applications' own. Developers everywhere and admins change them.
func List(ctx context.Context) ([]Database, error)List is every database: the environments', then the applications' own.
dbs, err := client.Cloud.Databases.List(ctx)
if err != nil {
log.Fatal(err)
}
for _, db := range dbs {
fmt.Println(db.Name, db.Kind, db.Environment+db.Application)
}func Get(ctx context.Context, id string) (*Database, error)Get is one database, by id.
db, err := client.Cloud.Databases.Get(ctx, "db_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(db.Name, db.Version, db.Versions)func Create(ctx context.Context, kind, name, environmentID string) (*Database, error)Create is a database of a kind — overlite, postgres, redis — in an environment.
db, err := client.Cloud.Databases.Create(ctx, "postgres", "orders", "env_2")
if err != nil {
log.Fatal(err)
}
fmt.Println(db.ID, db.EnvVar)func Update(ctx context.Context, id string, in DatabaseInput) (*Database, error)Update changes how the database runs: its name, version, memory, features, host and Studio.
db, err := client.Cloud.Databases.Update(ctx, "db_1", yet.DatabaseInput{
Version: yet.Ptr("17"),
MemoryMB: yet.Ptr(1024),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(db.Version, db.MemoryMB)func Delete(ctx context.Context, id string) errorDelete removes an environment's database — an application's own goes with DeleteResource. Its volume stays on the server.
if err := client.Cloud.Databases.Delete(ctx, "db_1"); err != nil {
log.Fatal(err)
}func SetBackups(ctx context.Context, id string, in BackupsInput) (*Backups, error)SetBackups sets how a database is copied — an Overlite on a runtime of the company's — and answers with its copies, as Backups does.
b, err := client.Cloud.Databases.SetBackups(ctx, "db_2", yet.BackupsInput{Every: yet.Ptr(6), Keep: yet.Ptr(28)})
if err != nil {
log.Fatal(err)
}
fmt.Println("every", b.Every, "hours, the newest", b.Keep)func DownloadURL(ctx context.Context, id, backupID string) (string, error)DownloadURL is where one copy downloads from, for a few minutes.
url, err := client.Cloud.Databases.DownloadURL(ctx, "db_2", "bk_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(url)func Query(ctx context.Context, id, statement, environmentID string) (*Query, error)Query runs a statement, on an application's own database's stage environmentID — its last unless said. Cloud waits a few seconds for the answer; one still running is asked for again with GetQuery.
q, err := client.Cloud.Databases.Query(ctx, "db_1", "select count(*) from orders", "")
if err != nil {
log.Fatal(err)
}
fmt.Println(q.Status, q.Result.Columns, q.Result.Rows)func GetQuery(ctx context.Context, id, queryID string) (*Query, error)GetQuery is a query run before, as it stands now.
q, err := client.Cloud.Databases.GetQuery(ctx, "db_1", "q_2")
if err != nil {
log.Fatal(err)
}
for _, row := range q.Result.Rows {
fmt.Println(row[0], row[1])
}func Backups(ctx context.Context, id string) (*Backups, error)Backups is how the database is copied, and its copies, the latest first.
b, err := client.Cloud.Databases.Backups(ctx, "db_2")
if err != nil {
log.Fatal(err)
}
for _, c := range b.Backups {
fmt.Println(c.ID, c.Status, c.Size)
}func BackUp(ctx context.Context, id string) ([]Backup, error)BackUp asks for a copy now — one per stage it runs on; the agents take them at their next look.
copies, err := client.Cloud.Databases.BackUp(ctx, "db_2")
if err != nil {
log.Fatal(err)
}
for _, c := range copies {
fmt.Println(c.ID, c.EnvironmentID, c.Status)
}client.Cloud.DNS
DNSService is the domains whose records Cloud keeps.
func Zones(ctx context.Context) ([]Zone, error)Zones is every zone, with how many records it has.
zones, err := client.Cloud.DNS.Zones(ctx)
if err != nil {
log.Fatal(err)
}
for _, z := range zones {
fmt.Println(z.Name, z.Status, z.Records)
}func Zone(ctx context.Context, id string) (*Zone, []Record, error)Zone is one zone, with its records.
zone, records, err := client.Cloud.DNS.Zone(ctx, "zn_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(zone.Name)
for _, r := range records {
fmt.Println(r.FQDN, r.Type, r.Values)
}func CreateZone(ctx context.Context, name string) (*Zone, error)CreateZone makes a zone for a domain, for Cloud admins: its registrar points at the zone's Nameservers. Yet's own names, and one another workspace set up, are refused.
zone, err := client.Cloud.DNS.CreateZone(ctx, "acme.dev")
if err != nil {
log.Fatal(err)
}
// Point the domain's registrar at these.
fmt.Println(zone.Nameservers)func DeleteZone(ctx context.Context, id string) errorDeleteZone removes the zone and its records, for Cloud admins; only one no environment answers under.
if err := client.Cloud.DNS.DeleteZone(ctx, "zn_1"); err != nil {
log.Fatal(err)
}func VerifyZone(ctx context.Context, id string) (*Zone, error)VerifyZone asks the domain's nameservers again, now.
zone, err := client.Cloud.DNS.VerifyZone(ctx, "zn_1")
if err != nil {
log.Fatal(err)
}
fmt.Println(zone.Name, zone.Status)func CreateRecord(ctx context.Context, zoneID string, in RecordInput) (*Record, error)CreateRecord adds a record to the zone, for developers everywhere.
r, err := client.Cloud.DNS.CreateRecord(ctx, "zn_1", yet.RecordInput{
Name: "www",
Type: "CNAME",
TTL: 300,
Values: []string{"acme.dev."},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(r.ID, r.FQDN)func UpdateRecord(ctx context.Context, zoneID, id string, ttl int, values []string) (*Record, error)UpdateRecord replaces a record's TTL and values; one Cloud keeps itself, for an environment, is refused.
r, err := client.Cloud.DNS.UpdateRecord(ctx, "zn_1", "rec_1", 3600, []string{"acme.dev."})
if err != nil {
log.Fatal(err)
}
fmt.Println(r.FQDN, r.TTL)func DeleteRecord(ctx context.Context, zoneID, id string) errorDeleteRecord removes a record; one Cloud keeps itself, for an environment, is refused.
if err := client.Cloud.DNS.DeleteRecord(ctx, "zn_1", "rec_1"); err != nil {
log.Fatal(err)
}