Skip to content

Commit 0d917dc

Browse files
committed
More APis
1 parent f7c4d97 commit 0d917dc

File tree

4 files changed

+526
-0
lines changed

4 files changed

+526
-0
lines changed

coderd/apidoc/docs.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,48 @@ const docTemplate = `{
6868
}
6969
}
7070
},
71+
"/organizations/{organization}/members/{user}/workspaces": {
72+
"post": {
73+
"security": [
74+
{
75+
"CoderSessionToken": []
76+
}
77+
],
78+
"produces": [
79+
"application/json"
80+
],
81+
"tags": [
82+
"Workspaces"
83+
],
84+
"summary": "Create workspace by organization",
85+
"operationId": "create-workspace-by-organization",
86+
"parameters": [
87+
{
88+
"type": "string",
89+
"format": "uuid",
90+
"description": "Organization ID",
91+
"name": "organization",
92+
"in": "path",
93+
"required": true
94+
},
95+
{
96+
"type": "string",
97+
"description": "Username",
98+
"name": "user",
99+
"in": "path",
100+
"required": true
101+
}
102+
],
103+
"responses": {
104+
"200": {
105+
"description": "OK",
106+
"schema": {
107+
"$ref": "#/definitions/codersdk.Workspace"
108+
}
109+
}
110+
}
111+
}
112+
},
71113
"/templates/{id}": {
72114
"get": {
73115
"security": [
@@ -103,6 +145,53 @@ const docTemplate = `{
103145
}
104146
}
105147
},
148+
"/users/{user}/workspace/{workspacename}": {
149+
"get": {
150+
"security": [
151+
{
152+
"CoderSessionToken": []
153+
}
154+
],
155+
"produces": [
156+
"application/json"
157+
],
158+
"tags": [
159+
"Workspaces"
160+
],
161+
"summary": "Get workspace metadata by owner and workspace name",
162+
"operationId": "get-workspace-metadata-by-owner-and-workspace-name",
163+
"parameters": [
164+
{
165+
"type": "string",
166+
"description": "Owner username",
167+
"name": "user",
168+
"in": "path",
169+
"required": true
170+
},
171+
{
172+
"type": "string",
173+
"description": "Workspace name",
174+
"name": "workspacename",
175+
"in": "path",
176+
"required": true
177+
},
178+
{
179+
"type": "string",
180+
"description": "Return data instead of HTTP 404 if the workspace is deleted",
181+
"name": "include_deleted",
182+
"in": "query"
183+
}
184+
],
185+
"responses": {
186+
"200": {
187+
"description": "OK",
188+
"schema": {
189+
"$ref": "#/definitions/codersdk.Workspace"
190+
}
191+
}
192+
}
193+
}
194+
},
106195
"/workspaces": {
107196
"get": {
108197
"security": [

coderd/apidoc/swagger.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,48 @@
6060
}
6161
}
6262
},
63+
"/organizations/{organization}/members/{user}/workspaces": {
64+
"post": {
65+
"security": [
66+
{
67+
"CoderSessionToken": []
68+
}
69+
],
70+
"produces": [
71+
"application/json"
72+
],
73+
"tags": [
74+
"Workspaces"
75+
],
76+
"summary": "Create workspace by organization",
77+
"operationId": "create-workspace-by-organization",
78+
"parameters": [
79+
{
80+
"type": "string",
81+
"format": "uuid",
82+
"description": "Organization ID",
83+
"name": "organization",
84+
"in": "path",
85+
"required": true
86+
},
87+
{
88+
"type": "string",
89+
"description": "Username",
90+
"name": "user",
91+
"in": "path",
92+
"required": true
93+
}
94+
],
95+
"responses": {
96+
"200": {
97+
"description": "OK",
98+
"schema": {
99+
"$ref": "#/definitions/codersdk.Workspace"
100+
}
101+
}
102+
}
103+
}
104+
},
63105
"/templates/{id}": {
64106
"get": {
65107
"security": [
@@ -95,6 +137,53 @@
95137
}
96138
}
97139
},
140+
"/users/{user}/workspace/{workspacename}": {
141+
"get": {
142+
"security": [
143+
{
144+
"CoderSessionToken": []
145+
}
146+
],
147+
"produces": [
148+
"application/json"
149+
],
150+
"tags": [
151+
"Workspaces"
152+
],
153+
"summary": "Get workspace metadata by owner and workspace name",
154+
"operationId": "get-workspace-metadata-by-owner-and-workspace-name",
155+
"parameters": [
156+
{
157+
"type": "string",
158+
"description": "Owner username",
159+
"name": "user",
160+
"in": "path",
161+
"required": true
162+
},
163+
{
164+
"type": "string",
165+
"description": "Workspace name",
166+
"name": "workspacename",
167+
"in": "path",
168+
"required": true
169+
},
170+
{
171+
"type": "string",
172+
"description": "Return data instead of HTTP 404 if the workspace is deleted",
173+
"name": "include_deleted",
174+
"in": "query"
175+
}
176+
],
177+
"responses": {
178+
"200": {
179+
"description": "OK",
180+
"schema": {
181+
"$ref": "#/definitions/codersdk.Workspace"
182+
}
183+
}
184+
}
185+
}
186+
},
98187
"/workspaces": {
99188
"get": {
100189
"security": [

coderd/workspaces.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
192192
})
193193
}
194194

195+
// @Summary Get workspace metadata by owner and workspace name
196+
// @ID get-workspace-metadata-by-owner-and-workspace-name
197+
// @Security CoderSessionToken
198+
// @Produce json
199+
// @Tags Workspaces
200+
// @Param user path string true "Owner username"
201+
// @Param workspacename path string true "Workspace name"
202+
// @Param include_deleted query string false "Return data instead of HTTP 404 if the workspace is deleted"
203+
// @Success 200 {object} codersdk.Workspace
204+
// @Router /users/{user}/workspace/{workspacename} [get]
195205
func (api *API) workspaceByOwnerAndName(rw http.ResponseWriter, r *http.Request) {
196206
ctx := r.Context()
197207
owner := httpmw.UserParam(r)
@@ -256,6 +266,15 @@ func (api *API) workspaceByOwnerAndName(rw http.ResponseWriter, r *http.Request)
256266
))
257267
}
258268

269+
// @Summary Create workspace by organization
270+
// @ID create-workspace-by-organization
271+
// @Security CoderSessionToken
272+
// @Produce json
273+
// @Tags Workspaces
274+
// @Param organization path string true "Organization ID" format(uuid)
275+
// @Param user path string true "Username"
276+
// @Success 200 {object} codersdk.Workspace
277+
// @Router /organizations/{organization}/members/{user}/workspaces [post]
259278
// Create a new workspace for the currently authenticated user.
260279
func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Request) {
261280
var (

0 commit comments

Comments
 (0)