SDKs

Referência — Go

Cada método de yet-sdk-go, por produto e por serviço, como está no código.

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.

Exemplo
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) error

Rename is the name the company's people see, on every app and at sign-in.

Exemplo
if err := client.Settings.Workspace.Rename(ctx, "Acme"); err != nil {
	log.Fatal(err)
}
func SetOpenJoin(ctx context.Context, open bool) error

SetOpenJoin is whether anyone at the company's domains may join by themselves.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Rename is the person's name: on their sign-in, and on their mailbox.

Exemplo
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) error

SetRunsSettings is whether the person may open the company's Settings.

Exemplo
if err := client.Settings.People.SetRunsSettings(ctx, "ps_1", true); err != nil {
	log.Fatal(err)
}
func SetPassword(ctx context.Context, id, password string) error

SetPassword is a new password; they use it the next time they sign in.

Exemplo
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) error

Remove takes the person away: their sign-in, and their mailbox with all its mail.

Exemplo
if err := client.Settings.People.Remove(ctx, "ps_1"); err != nil {
	log.Fatal(err)
}
func Invite(ctx context.Context, email string) error

Invite 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.

Exemplo
if err := client.Settings.People.Invite(ctx, "ana@acme.dev"); err != nil {
	log.Fatal(err)
}
func RemoveMember(ctx context.Context, email string) error

RemoveMember lets someone with no mailbox here go.

Exemplo
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.

Exemplo
off, err := client.Settings.Apps.Off(ctx)
if err != nil {
	log.Fatal(err)
}
fmt.Println(off)
func SetOff(ctx context.Context, off []string) error

SetOff turns off these apps, and on every other one.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

CancelClaim gives up asking for a domain.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

RegisterSES registers the domain in the SES it sends through — or finishes it.

Exemplo
if err := client.Settings.Domains.RegisterSES(ctx, "acme.dev"); err != nil {
	log.Fatal(err)
}
func SetPaused(ctx context.Context, name string, paused bool) error

SetPaused pauses or resumes the domain's sending in its SES.

Exemplo
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.

Exemplo
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) error

Remove takes a domain with mail off the mail server and out of the company — only one with nobody on it.

Exemplo
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.

Exemplo
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) error

AddAlias gives the person another address, name@ their own domain.

Exemplo
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) error

RemoveAlias takes one of the person's other addresses away; their own stays.

Exemplo
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) error

SetCatchAll is where mail to addresses that do not exist goes; empty turns it off.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

UpdateList replaces the list's recipients, and its description when given.

Exemplo
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) error

DeleteList removes one of the company's lists, by id.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Remove disconnects GitHub: builds and runners from it stop.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Disconnect forgets the key. A company sending through its own SES stops sending.

Exemplo
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.

Exemplo
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) error

Set points Drive at the bucket, once a write to it shows the key may use it.

Exemplo
if err := client.Settings.Storage.Set(ctx, yet.Storage{Bucket: "acme-drive", Prefix: "drive/"}); err != nil {
	log.Fatal(err)
}
func Remove(ctx context.Context) error

Remove sends Drive back to keeping the files itself; the bucket keeps what is in it.

Exemplo
if err := client.Settings.Storage.Remove(ctx); err != nil {
	log.Fatal(err)
}

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.

Exemplo
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) error

Set puts the logo on the company's sign-in page: a PNG, JPEG, WebP, GIF or SVG under 256 KB.

Exemplo
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) error

Remove puts Yet's own mark back on the sign-in page.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete revokes one of the person's own keys.

Exemplo
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.

Exemplo
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) error

Revoke revokes anyone's key, for the company's admins.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes the rack; only one with no servers or runtimes in it.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes the server; only one no runtime runs on.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes the runtime, and its tunnel with it; only one no environment runs on, in no pool.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

DeleteContainer removes the container, its definition with it.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

DeleteRunner removes the runner from the runtime.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes the pool and its tunnel; its runtimes stay, out of it. Only one no environment runs on.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
// 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) error

Delete removes the environment and its records; only one no application has as a stage.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes the namespace, for Cloud admins; only one with no applications.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes the application, with its releases, its deployments and its own databases; it is gone from every cluster at the agents' next look.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
// 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.

Exemplo
// 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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

DeleteResource removes one of the application's own databases: it stops at the agents' next look, its volume kept on each server.

Exemplo
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 "".

Exemplo
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) error

Detach takes an environment's database away from the application; the database stays.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

Delete removes an environment's database — an application's own goes with DeleteResource. Its volume stays on the server.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

DeleteZone removes the zone and its records, for Cloud admins; only one no environment answers under.

Exemplo
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.

Exemplo
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.

Exemplo
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.

Exemplo
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) error

DeleteRecord removes a record; one Cloud keeps itself, for an environment, is refused.

Exemplo
if err := client.Cloud.DNS.DeleteRecord(ctx, "zn_1", "rec_1"); err != nil {
	log.Fatal(err)
}