@Summary Get templates by organization and template name @ID get-templates-by-organization-and-template-name @Security CoderSessionToken @Produce json @Tags Templates @Param organization path string true "Organization ID" format(uuid) @Param templatename path string true "Template name" @Success 200
(rw http.ResponseWriter, r *http.Request)
| 617 | // @Success 200 {object} codersdk.Template |
| 618 | // @Router /api/v2/organizations/{organization}/templates/{templatename} [get] |
| 619 | func (api *API) templateByOrganizationAndName(rw http.ResponseWriter, r *http.Request) { |
| 620 | ctx := r.Context() |
| 621 | organization := httpmw.OrganizationParam(r) |
| 622 | templateName := chi.URLParam(r, "templatename") |
| 623 | template, err := api.Database.GetTemplateByOrganizationAndName(ctx, database.GetTemplateByOrganizationAndNameParams{ |
| 624 | OrganizationID: organization.ID, |
| 625 | Name: templateName, |
| 626 | }) |
| 627 | if err != nil { |
| 628 | if httpapi.Is404Error(err) { |
| 629 | httpapi.ResourceNotFound(rw) |
| 630 | return |
| 631 | } |
| 632 | |
| 633 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 634 | Message: "Internal error fetching template.", |
| 635 | Detail: err.Error(), |
| 636 | }) |
| 637 | return |
| 638 | } |
| 639 | |
| 640 | httpapi.Write(ctx, rw, http.StatusOK, api.convertTemplate(template)) |
| 641 | } |
| 642 | |
| 643 | // @Summary Update template settings by ID |
| 644 | // @ID update-template-settings-by-id |
nothing calls this directly
no test coverage detected