Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f37c6b3

Browse files
committed
/workspaces
1 parent d2a9af5 commit f37c6b3

File tree

6 files changed

+791
-8
lines changed

6 files changed

+791
-8
lines changed

coderd/apidoc/docs.go

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,112 @@ const docTemplate = `{
15171517
}
15181518
}
15191519
},
1520+
"/workspaces/{id}/builds": {
1521+
"get": {
1522+
"security": [
1523+
{
1524+
"CoderSessionToken": []
1525+
}
1526+
],
1527+
"produces": [
1528+
"application/json"
1529+
],
1530+
"tags": [
1531+
"Builds"
1532+
],
1533+
"summary": "Get workspace builds by workspace ID",
1534+
"operationId": "get-workspace-builds-by-workspace-id",
1535+
"parameters": [
1536+
{
1537+
"type": "string",
1538+
"format": "uuid",
1539+
"description": "Workspace ID",
1540+
"name": "id",
1541+
"in": "path",
1542+
"required": true
1543+
},
1544+
{
1545+
"type": "string",
1546+
"format": "uuid",
1547+
"description": "After ID",
1548+
"name": "after_id",
1549+
"in": "query"
1550+
},
1551+
{
1552+
"type": "integer",
1553+
"description": "Page limit",
1554+
"name": "limit",
1555+
"in": "query"
1556+
},
1557+
{
1558+
"type": "integer",
1559+
"description": "Page offset",
1560+
"name": "offset",
1561+
"in": "query"
1562+
},
1563+
{
1564+
"type": "string",
1565+
"format": "date-time",
1566+
"description": "Since timestamp",
1567+
"name": "since",
1568+
"in": "query"
1569+
}
1570+
],
1571+
"responses": {
1572+
"200": {
1573+
"description": "OK",
1574+
"schema": {
1575+
"type": "array",
1576+
"items": {
1577+
"$ref": "#/definitions/codersdk.WorkspaceBuild"
1578+
}
1579+
}
1580+
}
1581+
}
1582+
},
1583+
"post": {
1584+
"security": [
1585+
{
1586+
"CoderSessionToken": []
1587+
}
1588+
],
1589+
"produces": [
1590+
"application/json"
1591+
],
1592+
"tags": [
1593+
"Builds"
1594+
],
1595+
"summary": "Create workspace build",
1596+
"operationId": "create-workspace-build",
1597+
"parameters": [
1598+
{
1599+
"type": "string",
1600+
"format": "uuid",
1601+
"description": "Workspace ID",
1602+
"name": "id",
1603+
"in": "path",
1604+
"required": true
1605+
},
1606+
{
1607+
"description": "Create workspace build request",
1608+
"name": "request",
1609+
"in": "body",
1610+
"required": true,
1611+
"schema": {
1612+
"$ref": "#/definitions/codersdk.CreateWorkspaceBuildRequest"
1613+
}
1614+
}
1615+
],
1616+
"responses": {
1617+
"200": {
1618+
"description": "OK",
1619+
"schema": {
1620+
"$ref": "#/definitions/codersdk.WorkspaceBuild"
1621+
}
1622+
}
1623+
}
1624+
}
1625+
},
15201626
"/workspaces/{workspace}": {
15211627
"patch": {
15221628
"security": [
@@ -2104,6 +2210,46 @@ const docTemplate = `{
21042210
}
21052211
}
21062212
},
2213+
"codersdk.CreateWorkspaceBuildRequest": {
2214+
"type": "object",
2215+
"required": [
2216+
"transition"
2217+
],
2218+
"properties": {
2219+
"dry_run": {
2220+
"type": "boolean"
2221+
},
2222+
"orphan": {
2223+
"description": "Orphan may be set for the Destroy transition.",
2224+
"type": "boolean"
2225+
},
2226+
"parameter_values": {
2227+
"description": "ParameterValues are optional. It will write params to the 'workspace' scope.\nThis will overwrite any existing parameters with the same name.\nThis will not delete old params not included in this list.",
2228+
"type": "array",
2229+
"items": {
2230+
"$ref": "#/definitions/codersdk.CreateParameterRequest"
2231+
}
2232+
},
2233+
"state": {
2234+
"type": "array",
2235+
"items": {
2236+
"type": "integer"
2237+
}
2238+
},
2239+
"template_version_id": {
2240+
"type": "string"
2241+
},
2242+
"transition": {
2243+
"type": "string",
2244+
"enum": [
2245+
"create",
2246+
"start",
2247+
"stop",
2248+
"delete"
2249+
]
2250+
}
2251+
}
2252+
},
21072253
"codersdk.DERP": {
21082254
"type": "object",
21092255
"properties": {

coderd/apidoc/swagger.json

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,104 @@
13201320
}
13211321
}
13221322
},
1323+
"/workspaces/{id}/builds": {
1324+
"get": {
1325+
"security": [
1326+
{
1327+
"CoderSessionToken": []
1328+
}
1329+
],
1330+
"produces": ["application/json"],
1331+
"tags": ["Builds"],
1332+
"summary": "Get workspace builds by workspace ID",
1333+
"operationId": "get-workspace-builds-by-workspace-id",
1334+
"parameters": [
1335+
{
1336+
"type": "string",
1337+
"format": "uuid",
1338+
"description": "Workspace ID",
1339+
"name": "id",
1340+
"in": "path",
1341+
"required": true
1342+
},
1343+
{
1344+
"type": "string",
1345+
"format": "uuid",
1346+
"description": "After ID",
1347+
"name": "after_id",
1348+
"in": "query"
1349+
},
1350+
{
1351+
"type": "integer",
1352+
"description": "Page limit",
1353+
"name": "limit",
1354+
"in": "query"
1355+
},
1356+
{
1357+
"type": "integer",
1358+
"description": "Page offset",
1359+
"name": "offset",
1360+
"in": "query"
1361+
},
1362+
{
1363+
"type": "string",
1364+
"format": "date-time",
1365+
"description": "Since timestamp",
1366+
"name": "since",
1367+
"in": "query"
1368+
}
1369+
],
1370+
"responses": {
1371+
"200": {
1372+
"description": "OK",
1373+
"schema": {
1374+
"type": "array",
1375+
"items": {
1376+
"$ref": "#/definitions/codersdk.WorkspaceBuild"
1377+
}
1378+
}
1379+
}
1380+
}
1381+
},
1382+
"post": {
1383+
"security": [
1384+
{
1385+
"CoderSessionToken": []
1386+
}
1387+
],
1388+
"produces": ["application/json"],
1389+
"tags": ["Builds"],
1390+
"summary": "Create workspace build",
1391+
"operationId": "create-workspace-build",
1392+
"parameters": [
1393+
{
1394+
"type": "string",
1395+
"format": "uuid",
1396+
"description": "Workspace ID",
1397+
"name": "id",
1398+
"in": "path",
1399+
"required": true
1400+
},
1401+
{
1402+
"description": "Create workspace build request",
1403+
"name": "request",
1404+
"in": "body",
1405+
"required": true,
1406+
"schema": {
1407+
"$ref": "#/definitions/codersdk.CreateWorkspaceBuildRequest"
1408+
}
1409+
}
1410+
],
1411+
"responses": {
1412+
"200": {
1413+
"description": "OK",
1414+
"schema": {
1415+
"$ref": "#/definitions/codersdk.WorkspaceBuild"
1416+
}
1417+
}
1418+
}
1419+
}
1420+
},
13231421
"/workspaces/{workspace}": {
13241422
"patch": {
13251423
"security": [
@@ -1852,6 +1950,39 @@
18521950
}
18531951
}
18541952
},
1953+
"codersdk.CreateWorkspaceBuildRequest": {
1954+
"type": "object",
1955+
"required": ["transition"],
1956+
"properties": {
1957+
"dry_run": {
1958+
"type": "boolean"
1959+
},
1960+
"orphan": {
1961+
"description": "Orphan may be set for the Destroy transition.",
1962+
"type": "boolean"
1963+
},
1964+
"parameter_values": {
1965+
"description": "ParameterValues are optional. It will write params to the 'workspace' scope.\nThis will overwrite any existing parameters with the same name.\nThis will not delete old params not included in this list.",
1966+
"type": "array",
1967+
"items": {
1968+
"$ref": "#/definitions/codersdk.CreateParameterRequest"
1969+
}
1970+
},
1971+
"state": {
1972+
"type": "array",
1973+
"items": {
1974+
"type": "integer"
1975+
}
1976+
},
1977+
"template_version_id": {
1978+
"type": "string"
1979+
},
1980+
"transition": {
1981+
"type": "string",
1982+
"enum": ["create", "start", "stop", "delete"]
1983+
}
1984+
}
1985+
},
18551986
"codersdk.DERP": {
18561987
"type": "object",
18571988
"properties": {

coderd/workspacebuilds.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ func (api *API) workspaceBuild(rw http.ResponseWriter, r *http.Request) {
7272
httpapi.Write(ctx, rw, http.StatusOK, apiBuild)
7373
}
7474

75+
// @Summary Get workspace builds by workspace ID
76+
// @ID get-workspace-builds-by-workspace-id
77+
// @Security CoderSessionToken
78+
// @Produce json
79+
// @Tags Builds
80+
// @Param id path string true "Workspace ID" format(uuid)
81+
// @Param after_id query string false "After ID" format(uuid)
82+
// @Param limit query int false "Page limit"
83+
// @Param offset query int false "Page offset"
84+
// @Param since query string false "Since timestamp" format(date-time)
85+
// @Success 200 {array} codersdk.WorkspaceBuild
86+
// @Router /workspaces/{id}/builds [get]
7587
func (api *API) workspaceBuilds(rw http.ResponseWriter, r *http.Request) {
7688
ctx := r.Context()
7789
workspace := httpmw.WorkspaceParam(r)
@@ -262,6 +274,19 @@ func (api *API) workspaceBuildByBuildNumber(rw http.ResponseWriter, r *http.Requ
262274
httpapi.Write(ctx, rw, http.StatusOK, apiBuild)
263275
}
264276

277+
// @Summary Create workspace build
278+
// @ID create-workspace-build
279+
// @Security CoderSessionToken
280+
// @Accepts json
281+
// @Produce json
282+
// @Tags Builds
283+
// @Param id path string true "Workspace ID" format(uuid)
284+
// @Param request body codersdk.CreateWorkspaceBuildRequest true "Create workspace build request"
285+
// @Success 200 {object} codersdk.WorkspaceBuild
286+
// @Router /workspaces/{id}/builds [post]
287+
//
288+
// Azure supports instance identity verification:
289+
// https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service?tabs=linux#tabgroup_14
265290
func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
266291
ctx := r.Context()
267292
apiKey := httpmw.APIKey(r)

coderd/workspaceresourceauth.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ func (api *API) postWorkspaceAuthAzureInstanceIdentity(rw http.ResponseWriter, r
4545
api.handleAuthInstanceID(rw, r, instanceID)
4646
}
4747

48-
// AWS supports instance identity verification:
49-
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html
50-
// Using this, we can exchange a signed instance payload for an agent token.
51-
//
5248
// @Summary Authenticate agent on AWS instance
5349
// @ID authenticate-agent-on-aws-instance
5450
// @Security CoderSessionToken
@@ -57,6 +53,10 @@ func (api *API) postWorkspaceAuthAzureInstanceIdentity(rw http.ResponseWriter, r
5753
// @Param request body codersdk.AWSInstanceIdentityToken true "Instance identity token"
5854
// @Success 200 {object} codersdk.WorkspaceAgentAuthenticateResponse
5955
// @Router /workspaceagents/aws-instance-identity [post]
56+
//
57+
// AWS supports instance identity verification:
58+
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html
59+
// Using this, we can exchange a signed instance payload for an agent token.
6060
func (api *API) postWorkspaceAuthAWSInstanceIdentity(rw http.ResponseWriter, r *http.Request) {
6161
ctx := r.Context()
6262
var req codersdk.AWSInstanceIdentityToken
@@ -74,10 +74,6 @@ func (api *API) postWorkspaceAuthAWSInstanceIdentity(rw http.ResponseWriter, r *
7474
api.handleAuthInstanceID(rw, r, identity.InstanceID)
7575
}
7676

77-
// Google Compute Engine supports instance identity verification:
78-
// https://cloud.google.com/compute/docs/instances/verifying-instance-identity
79-
// Using this, we can exchange a signed instance payload for an agent token.
80-
//
8177
// @Summary Authenticate agent on Google Cloud instance
8278
// @ID authenticate-agent-on-google-cloud-instance
8379
// @Security CoderSessionToken
@@ -86,6 +82,10 @@ func (api *API) postWorkspaceAuthAWSInstanceIdentity(rw http.ResponseWriter, r *
8682
// @Param request body codersdk.GoogleInstanceIdentityToken true "Instance identity token"
8783
// @Success 200 {object} codersdk.WorkspaceAgentAuthenticateResponse
8884
// @Router /workspaceagents/google-instance-identity [post]
85+
//
86+
// Google Compute Engine supports instance identity verification:
87+
// https://cloud.google.com/compute/docs/instances/verifying-instance-identity
88+
// Using this, we can exchange a signed instance payload for an agent token.
8989
func (api *API) postWorkspaceAuthGoogleInstanceIdentity(rw http.ResponseWriter, r *http.Request) {
9090
ctx := r.Context()
9191
var req codersdk.GoogleInstanceIdentityToken

0 commit comments

Comments
 (0)