MCPcopy Index your code
hub / github.com/coder/coder / templateByOrganizationAndName

Method templateByOrganizationAndName

coderd/templates.go:619–641  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

617// @Success 200 {object} codersdk.Template
618// @Router /api/v2/organizations/{organization}/templates/{templatename} [get]
619func (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

Callers

nothing calls this directly

Calls 8

convertTemplateMethod · 0.95
OrganizationParamFunction · 0.92
Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected