Skip to content

Commit 8412076

Browse files
authored
docs: API templateversions, templates, members, organizations (#5546)
* docs: audit, deploymentconfig, files, parameters * Swagger comments in workspacebuilds.go * structs in workspacebuilds.go * workspaceagents: instance identity * workspaceagents.go in progress * workspaceagents.go in progress * Agents * workspacebuilds.go * /workspaces * templates.go, templateversions.go * templateversion.go in progress * cancel * templateversions * wip * Merge * x-apidocgen * NullTime hack not needed anymore * Fix: x-apidocgen * Members * Fixes * Fix
1 parent 5a3985e commit 8412076

24 files changed

+5469
-472
lines changed

coderd/apidoc/docs.go

+1,467-126
Large diffs are not rendered by default.

coderd/apidoc/swagger.json

+1,342-133
Large diffs are not rendered by default.

coderd/coderd.go

-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ func New(options *Options) *API {
431431
apiKeyMiddleware,
432432
httpmw.ExtractTemplateVersionParam(options.Database),
433433
)
434-
435434
r.Get("/", api.templateVersion)
436435
r.Patch("/cancel", api.patchCancelTemplateVersion)
437436
r.Get("/schema", api.templateVersionSchema)

coderd/members.go

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ import (
1616
"github.com/coder/coder/codersdk"
1717
)
1818

19+
// @Summary Assign role to organization member
20+
// @ID assign-role-to-organization-member
21+
// @Security CoderSessionToken
22+
// @Accept json
23+
// @Produce json
24+
// @Tags Members
25+
// @Param request body codersdk.UpdateRoles true "Update roles request"
26+
// @Param organization path string true "Organization ID"
27+
// @Param user path string true "Username, UUID, or me"
28+
// @Success 200 {object} codersdk.OrganizationMember
29+
// @Router /organizations/{organization}/members/{user}/roles [put]
1930
func (api *API) putMemberRoles(rw http.ResponseWriter, r *http.Request) {
2031
var (
2132
ctx = r.Context()

coderd/organizations.go

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ import (
1616
"github.com/coder/coder/codersdk"
1717
)
1818

19+
// @Summary Get organization by ID
20+
// @ID get-organization-by-id
21+
// @Security CoderSessionToken
22+
// @Produce json
23+
// @Tags Organizations
24+
// @Param organization path string true "Organization ID" format(uuid)
25+
// @Success 200 {object} codersdk.Organization
26+
// @Router /organizations/{organization} [get]
1927
func (api *API) organization(rw http.ResponseWriter, r *http.Request) {
2028
ctx := r.Context()
2129
organization := httpmw.OrganizationParam(r)
@@ -29,6 +37,14 @@ func (api *API) organization(rw http.ResponseWriter, r *http.Request) {
2937
httpapi.Write(ctx, rw, http.StatusOK, convertOrganization(organization))
3038
}
3139

40+
// @Summary Create organization
41+
// @ID create-organization
42+
// @Security CoderSessionToken
43+
// @Produce json
44+
// @Tags Organizations
45+
// @Param request body codersdk.CreateOrganizationRequest true "Create organization request"
46+
// @Success 201 {object} codersdk.Organization
47+
// @Router /organizations [post]
3248
func (api *API) postOrganizations(rw http.ResponseWriter, r *http.Request) {
3349
ctx := r.Context()
3450
apiKey := httpmw.APIKey(r)

coderd/roles.go

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ func (api *API) assignableSiteRoles(rw http.ResponseWriter, r *http.Request) {
2323
httpapi.Write(ctx, rw, http.StatusOK, assignableRoles(actorRoles.Roles, roles))
2424
}
2525

26+
// @Summary Get member roles by organization
27+
// @ID get-member-roles-by-organization
28+
// @Security CoderSessionToken
29+
// @Produce json
30+
// @Tags Members
31+
// @Param organization path string true "Organization ID" format(uuid)
32+
// @Success 200 {array} codersdk.AssignableRoles
33+
// @Router /organizations/{organization}/members/roles [get]
34+
//
2635
// assignableSiteRoles returns all site wide roles that can be assigned.
2736
func (api *API) assignableOrgRoles(rw http.ResponseWriter, r *http.Request) {
2837
ctx := r.Context()

coderd/templates.go

+21-5
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ func (api *API) deleteTemplate(rw http.ResponseWriter, r *http.Request) {
138138
// @Produce json
139139
// @Tags Templates
140140
// @Param request body codersdk.CreateTemplateRequest true "Request body"
141-
// @Param organization-id path string true "Organization ID"
141+
// @Param organization path string true "Organization ID"
142142
// @Success 200 {object} codersdk.Template
143-
// @Router /organizations/{organization-id}/templates/ [post]
143+
// @Router /organizations/{organization}/templates [post]
144144
// Returns a single template.
145145
// Create a new template in an organization.
146146
func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Request) {
@@ -336,7 +336,7 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque
336336
// @Produce json
337337
// @Tags Templates
338338
// @Param organization path string true "Organization ID" format(uuid)
339-
// @Success 200 {object} []codersdk.Template
339+
// @Success 200 {array} codersdk.Template
340340
// @Router /organizations/{organization}/templates [get]
341341
func (api *API) templatesByOrganization(rw http.ResponseWriter, r *http.Request) {
342342
ctx := r.Context()
@@ -402,9 +402,9 @@ func (api *API) templatesByOrganization(rw http.ResponseWriter, r *http.Request)
402402
// @Produce json
403403
// @Tags Templates
404404
// @Param organization path string true "Organization ID" format(uuid)
405-
// @Param template-name path string true "Template name"
405+
// @Param templatename path string true "Template name"
406406
// @Success 200 {object} codersdk.Template
407-
// @Router /organizations/{organization}/templates/{template-name} [get]
407+
// @Router /organizations/{organization}/templates/{templatename} [get]
408408
func (api *API) templateByOrganizationAndName(rw http.ResponseWriter, r *http.Request) {
409409
ctx := r.Context()
410410
organization := httpmw.OrganizationParam(r)
@@ -588,6 +588,14 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
588588
httpapi.Write(ctx, rw, http.StatusOK, api.convertTemplate(updated, count, createdByNameMap[updated.ID.String()]))
589589
}
590590

591+
// @Summary Get template DAUs by ID
592+
// @ID get-template-daus-by-id
593+
// @Security CoderSessionToken
594+
// @Produce json
595+
// @Tags Templates
596+
// @Param id path string true "Template ID" format(uuid)
597+
// @Success 200 {object} codersdk.TemplateDAUsResponse
598+
// @Router /templates/{id}/daus [get]
591599
func (api *API) templateDAUs(rw http.ResponseWriter, r *http.Request) {
592600
ctx := r.Context()
593601
template := httpmw.TemplateParam(r)
@@ -606,6 +614,14 @@ func (api *API) templateDAUs(rw http.ResponseWriter, r *http.Request) {
606614
httpapi.Write(ctx, rw, http.StatusOK, resp)
607615
}
608616

617+
// @Summary Get template examples by organization
618+
// @ID get-template-examples-by-organization
619+
// @Security CoderSessionToken
620+
// @Produce json
621+
// @Tags Templates
622+
// @Param organization path string true "Organization ID" format(uuid)
623+
// @Success 200 {array} codersdk.TemplateExample
624+
// @Router /organizations/{organization}/templates/examples [get]
609625
func (api *API) templateExamples(rw http.ResponseWriter, r *http.Request) {
610626
var (
611627
ctx = r.Context()

0 commit comments

Comments
 (0)