Skip to content

Commit 7d751e6

Browse files
committed
chore(api): add uid for app and workspace
1 parent 6560840 commit 7d751e6

7 files changed

Lines changed: 27 additions & 18 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ if err != nil {
5656
log.Fatal(err)
5757
}
5858

59-
_, _, err = members.List(client, ws.Name, 100)
59+
_, _, err = members.List(client, ws.ID, 100)
6060
if err != nil {
6161
log.Fatal(err)
6262
}
6363

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

api/apps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package api
55
type App struct {
66
Created string `json:"created"`
77
ID string `json:"id"`
8+
UID int `json:"uid"`
89
Workspace string `json:"workspace"`
910
Updated string `json:"updated"`
1011
UUID string `json:"uuid"`

api/apps_test.go

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

88
func TestAppsSorted(t *testing.T) {
99
apps := Apps{
10-
{"2014-01-01T00:00:00UTC", "Zulu", "John", "2016-01-02", "d57be2ba-7ae2-4825-9ace-7c86cb893046"},
11-
{"2014-01-01T00:00:00UTC", "Alpha", "John", "2016-01-02", "3d501190-1b8e-41ef-94c5-dd9a0bb707bb"},
12-
{"2014-01-01T00:00:00UTC", "Gamma", "John", "2016-01-02", "41d95133-fd4d-4f4c-92a2-e454857371cc"},
13-
{"2014-01-01T00:00:00UTC", "Beta", "John", "2016-01-02", "222ed1aa-e985-4bec-9966-a88215300661"},
10+
{Created: "2014-01-01T00:00:00UTC", ID: "Zulu", Workspace: "John", Updated: "2016-01-02", UUID: "d57be2ba-7ae2-4825-9ace-7c86cb893046"},
11+
{Created: "2014-01-01T00:00:00UTC", ID: "Alpha", Workspace: "John", Updated: "2016-01-02", UUID: "3d501190-1b8e-41ef-94c5-dd9a0bb707bb"},
12+
{Created: "2014-01-01T00:00:00UTC", ID: "Gamma", Workspace: "John", Updated: "2016-01-02", UUID: "41d95133-fd4d-4f4c-92a2-e454857371cc"},
13+
{Created: "2014-01-01T00:00:00UTC", ID: "Beta", Workspace: "John", Updated: "2016-01-02", UUID: "222ed1aa-e985-4bec-9966-a88215300661"},
1414
}
1515

1616
sort.Sort(apps)

api/workspaces.go

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

33
// Workspace is the definition of the workspace object.
44
type Workspace struct {
5-
ID int `json:"id"`
6-
Name string `json:"name"`
5+
UUID string `json:"uuid"`
6+
ID string `json:"id"`
7+
UID int `json:"uid"`
78
Email string `json:"email"`
89
Created string `json:"created"`
910
Updated string `json:"updated"`
@@ -14,11 +15,11 @@ type Workspaces []Workspace
1415

1516
func (w Workspaces) Len() int { return len(w) }
1617
func (w Workspaces) Swap(i, j int) { w[i], w[j] = w[j], w[i] }
17-
func (w Workspaces) Less(i, j int) bool { return w[i].Name < w[j].Name }
18+
func (w Workspaces) Less(i, j int) bool { return w[i].ID < w[j].ID }
1819

1920
// WorkspaceCreateRequest is the definition of POST /v2/workspaces.
2021
type WorkspaceCreateRequest struct {
21-
Name string `json:"name"`
22+
ID string `json:"id"`
2223
Email string `json:"email"`
2324
}
2425

apps/apps_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const appFixture string = `
1616
{
1717
"created": "2014-01-01T00:00:00UTC",
1818
"id": "example-go",
19+
"uid": 1001,
1920
"workspace": "test",
2021
"structure": {},
2122
"updated": "2014-01-01T00:00:00UTC",
@@ -31,6 +32,7 @@ const appsFixture string = `
3132
{
3233
"created": "2014-01-01T00:00:00UTC",
3334
"id": "example-go",
35+
"uid": 1001,
3436
"workspace": "test",
3537
"structure": {},
3638
"updated": "2014-01-01T00:00:00UTC",
@@ -156,6 +158,7 @@ func TestAppsCreate(t *testing.T) {
156158

157159
expected := api.App{
158160
ID: "example-go",
161+
UID: 1001,
159162
Created: "2014-01-01T00:00:00UTC",
160163
Workspace: "test",
161164
Updated: "2014-01-01T00:00:00UTC",
@@ -188,6 +191,7 @@ func TestAppsGet(t *testing.T) {
188191

189192
expected := api.App{
190193
ID: "example-go",
194+
UID: 1001,
191195
Created: "2014-01-01T00:00:00UTC",
192196
Workspace: "test",
193197
Updated: "2014-01-01T00:00:00UTC",
@@ -253,6 +257,7 @@ func TestAppsList(t *testing.T) {
253257
expected := api.Apps{
254258
{
255259
ID: "example-go",
260+
UID: 1001,
256261
Created: "2014-01-01T00:00:00UTC",
257262
Workspace: "test",
258263
Updated: "2014-01-01T00:00:00UTC",

workspaces/workspaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func List(c *drycc.Client, results int) (api.Workspaces, int, error) {
2727

2828
// Create creates a workspace.
2929
func Create(c *drycc.Client, name, email string) (api.Workspace, error) {
30-
req := api.WorkspaceCreateRequest{Name: name, Email: email}
30+
req := api.WorkspaceCreateRequest{ID: name, Email: email}
3131
body, err := json.Marshal(req)
3232
if err != nil {
3333
return api.Workspace{}, err

workspaces/workspaces_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import (
1414

1515
const workspaceFixture = `
1616
{
17-
"id": 1,
18-
"name": "wsalpha",
17+
"uuid": "9e5e56f2-4dc5-45ba-87f8-5fd2cd49c5a0",
18+
"id": "wsalpha",
19+
"uid": 1001,
1920
"email": "ws@example.com",
2021
"created": "2026-03-24T00:00:00Z",
2122
"updated": "2026-03-24T00:00:00Z"
@@ -28,8 +29,9 @@ const workspacesFixture = `
2829
"previous": null,
2930
"results": [
3031
{
31-
"id": 1,
32-
"name": "wsalpha",
32+
"uuid": "9e5e56f2-4dc5-45ba-87f8-5fd2cd49c5a0",
33+
"id": "wsalpha",
34+
"uid": 1001,
3335
"email": "ws@example.com",
3436
"created": "2026-03-24T00:00:00Z",
3537
"updated": "2026-03-24T00:00:00Z"
@@ -38,7 +40,7 @@ const workspacesFixture = `
3840
}`
3941

4042
const (
41-
workspaceCreateExpected = `{"name":"wsalpha","email":"ws@example.com"}`
43+
workspaceCreateExpected = `{"id":"wsalpha","email":"ws@example.com"}`
4244
workspaceUpdateExpected = `{"email":"ws-new@example.com"}`
4345
)
4446

@@ -71,7 +73,7 @@ func (f *fakeWorkspaceServer) ServeHTTP(res http.ResponseWriter, req *http.Reque
7173
res.WriteHeader(http.StatusInternalServerError)
7274
return
7375
}
74-
res.Write([]byte(`{"id":1,"name":"wsalpha","email":"ws-new@example.com","created":"2026-03-24T00:00:00Z","updated":"2026-03-24T00:00:00Z"}`))
76+
res.Write([]byte(`{"uuid":"9e5e56f2-4dc5-45ba-87f8-5fd2cd49c5a0","id":"wsalpha","uid":1001,"email":"ws-new@example.com","created":"2026-03-24T00:00:00Z","updated":"2026-03-24T00:00:00Z"}`))
7577
return
7678
}
7779
if req.URL.Path == "/v2/workspaces/wsalpha" && req.Method == "DELETE" {
@@ -94,7 +96,7 @@ func TestWorkspaces(t *testing.T) {
9496
t.Fatal(err)
9597
}
9698

97-
expected := api.Workspace{ID: 1, Name: "wsalpha", Email: "ws@example.com", Created: "2026-03-24T00:00:00Z", Updated: "2026-03-24T00:00:00Z"}
99+
expected := api.Workspace{UUID: "9e5e56f2-4dc5-45ba-87f8-5fd2cd49c5a0", ID: "wsalpha", UID: 1001, Email: "ws@example.com", Created: "2026-03-24T00:00:00Z", Updated: "2026-03-24T00:00:00Z"}
98100

99101
list, _, err := List(c, 100)
100102
if err != nil {

0 commit comments

Comments
 (0)