Skip to content

Commit f5a3de0

Browse files
committed
feat(workspaces): migrate sdk to workspace-based api model
1 parent b196e69 commit f5a3de0

42 files changed

Lines changed: 772 additions & 552 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,45 @@ apps, _, err := apps.List(client, 100)
2626
if err != nil {
2727
log.Fatal(err)
2828
}
29+
30+
// Create app in a workspace (workspace is required in the new API)
31+
app, err := apps.New(client, "example-go", "team-a")
32+
if err != nil {
33+
log.Fatal(err)
34+
}
35+
36+
_ = app
37+
```
38+
39+
### Workspaces
40+
41+
```go
42+
import drycc "github.com/drycc/controller-sdk-go"
43+
import "github.com/drycc/controller-sdk-go/workspaces"
44+
import members "github.com/drycc/controller-sdk-go/workspaces/members"
45+
import invitations "github.com/drycc/controller-sdk-go/workspaces/invitations"
46+
```
47+
48+
```go
49+
client, err := drycc.New(true, "drycc.test.io", "abc123")
50+
if err != nil {
51+
log.Fatal(err)
52+
}
53+
54+
ws, err := workspaces.Create(client, "team-a", "team-a@example.com")
55+
if err != nil {
56+
log.Fatal(err)
57+
}
58+
59+
_, _, err = members.List(client, ws.Name, 100)
60+
if err != nil {
61+
log.Fatal(err)
62+
}
63+
64+
_, err = invitations.Create(client, ws.Name, "new-user@example.com")
65+
if err != nil {
66+
log.Fatal(err)
67+
}
2968
```
3069

3170
### Authentication

api/apps.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package api
55
type App struct {
66
Created string `json:"created"`
77
ID string `json:"id"`
8-
Owner string `json:"owner"`
8+
Workspace string `json:"workspace"`
99
Updated string `json:"updated"`
1010
UUID string `json:"uuid"`
1111
}
@@ -19,12 +19,13 @@ func (a Apps) Less(i, j int) bool { return a[i].ID < a[j].ID }
1919

2020
// AppCreateRequest is the definition of POST /v2/apps/.
2121
type AppCreateRequest struct {
22-
ID string `json:"id,omitempty"`
22+
ID string `json:"id,omitempty"`
23+
Workspace string `json:"workspace,omitempty"`
2324
}
2425

25-
// AppUpdateRequest is the definition of POST /v2/apps/<app id>/.
26+
// AppUpdateRequest is the definition of PATCH /v2/apps/<app id>/.
2627
type AppUpdateRequest struct {
27-
Owner string `json:"owner,omitempty"`
28+
Workspace string `json:"workspace,omitempty"`
2829
}
2930

3031
// AppRunRequest is the definition of POST /v2/apps/<app id>/run.

api/appsettings.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77

88
// AppSettings is the structure of an app's settings.
99
type AppSettings struct {
10-
// Owner is the app owner. It cannot be updated with AppSettings.Set(). See app.Transfer().
11-
Owner string `json:"owner,omitempty"`
1210
// App is the app name. It cannot be updated at all right now.
1311
App string `json:"app,omitempty"`
1412
// Created is the time that the application settings was created and cannot be updated.

api/builds.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ type Build struct {
77
Dockerfile string `json:"dockerfile,omitempty"`
88
Image string `json:"image,omitempty"`
99
Stack string `json:"stack,omitempty"`
10-
Owner string `json:"owner"`
1110
Procfile map[string]string `json:"procfile"`
1211
Dryccfile map[string]any `json:"dryccfile"`
1312
Sha string `json:"sha,omitempty"`

api/certs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type Cert struct {
1818
Subject string `json:"subject"`
1919
SubjectAltName []string `json:"san,omitempty"`
2020
Domains []string `json:"domains,omitempty"`
21-
Owner string `json:"owner,omitempty"`
2221
ID int `json:"id,omitempty"`
2322
}
2423

api/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ type ConfigUnset struct {
4949

5050
// Config is the structure of an app's config.
5151
type Config struct {
52-
// Owner is the app owner. It cannot be updated with config.Set(). See app.Transfer().
53-
Owner string `json:"owner,omitempty"`
5452
// App is the app name. It cannot be updated at all right now.
5553
App string `json:"app,omitempty"`
5654
// Values are exposed as environment variables to the app.

api/domains.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ type Domain struct {
55
App string `json:"app"`
66
Created string `json:"created"`
77
Domain string `json:"domain"`
8-
Owner string `json:"owner"`
98
Ptype string `json:"ptype"`
109
Updated string `json:"updated"`
1110
}

api/domains_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77

88
func TestDomainsSorted(t *testing.T) {
99
domains := Domains{
10-
{"Alpha", "", "gamma.example.com", "web", "", ""},
11-
{"Alpha", "", "alpha1.example.com", "web", "", ""},
12-
{"Alpha", "", "zulu.example.com", "web", "", ""},
13-
{"Alpha", "", "delta.example.com", "web", "", ""},
10+
{"Alpha", "", "gamma.example.com", "web", ""},
11+
{"Alpha", "", "alpha1.example.com", "web", ""},
12+
{"Alpha", "", "zulu.example.com", "web", ""},
13+
{"Alpha", "", "delta.example.com", "web", ""},
1414
}
1515

1616
sort.Sort(domains)

api/gateways.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package api
22

33
// Gateway is the structure of an app's gateways.
44
type Gateway struct {
5-
// Owner is the app owner. It cannot be updated with AppSettings.Set(). See app.Transfer().
6-
Owner string `json:"owner,omitempty"`
75
// App is the app name. It cannot be updated at all right now.
86
App string `json:"app,omitempty"`
97
// Created is the time that the application settings was created and cannot be updated.

api/perms.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)