Skip to content

Commit 2912d03

Browse files
committed
add backend
1 parent 5dbf5b4 commit 2912d03

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

coderd/workspaces.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,9 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
142142
filter := database.GetWorkspacesWithFilterParams{Deleted: false}
143143
if orgFilter != "" {
144144
orgID, err := uuid.Parse(orgFilter)
145-
if err != nil {
146-
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
147-
Message: fmt.Sprintf("organization_id must be a uuid: %s", err.Error()),
148-
})
149-
return
145+
if err == nil {
146+
filter.OrganizationID = orgID
150147
}
151-
filter.OrganizationID = orgID
152148
}
153149
if ownerFilter == "me" {
154150
filter.OwnerID = apiKey.UserID
@@ -161,15 +157,12 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
161157
Username: ownerFilter,
162158
Email: ownerFilter,
163159
})
164-
if err != nil {
165-
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
166-
Message: "owner must be a uuid or username",
167-
})
168-
return
160+
if err == nil {
161+
filter.OwnerID = user.ID
169162
}
170-
userID = user.ID
163+
} else {
164+
filter.OwnerID = userID
171165
}
172-
filter.OwnerID = userID
173166
}
174167
if nameFilter != "" {
175168
filter.Name = nameFilter

codersdk/workspaces.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/http"
8-
"strconv"
98
"time"
109

1110
"github.com/google/uuid"
@@ -199,11 +198,10 @@ func (c *Client) PutExtendWorkspace(ctx context.Context, id uuid.UUID, req PutEx
199198
}
200199

201200
type WorkspaceFilter struct {
202-
OrganizationID uuid.UUID
201+
OrganizationID uuid.UUID `json:"organization_id,omitempty"`
203202
// Owner can be a user_id (uuid), "me", or a username
204-
Owner string
205-
Name string
206-
Deleted bool
203+
Owner string `json:"owner,omitempty"`
204+
Name string `json:"name,omitempty"`
207205
}
208206

209207
// asRequestOption returns a function that can be used in (*Client).Request.
@@ -220,9 +218,6 @@ func (f WorkspaceFilter) asRequestOption() requestOption {
220218
if f.Name != "" {
221219
q.Set("name", f.Name)
222220
}
223-
if f.Deleted {
224-
q.Set("deleted", strconv.FormatBool(f.Deleted))
225-
}
226221
r.URL.RawQuery = q.Encode()
227222
}
228223
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy