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

Method templateExamplesByOrganization

coderd/templates.go:919–940  ·  view source on GitHub ↗

@Summary Get template examples by organization @ID get-template-examples-by-organization @Security CoderSessionToken @Produce json @Tags Templates @Param organization path string true "Organization ID" format(uuid) @Success 200 {array} codersdk.TemplateExample @Router /api/v2/organizations/{organiza

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

917// @Router /api/v2/organizations/{organization}/templates/examples [get]
918// @Deprecated Use /templates/examples instead
919func (api *API) templateExamplesByOrganization(rw http.ResponseWriter, r *http.Request) {
920 var (
921 ctx = r.Context()
922 organization = httpmw.OrganizationParam(r)
923 )
924
925 if !api.Authorize(r, policy.ActionRead, rbac.ResourceTemplate.InOrg(organization.ID)) {
926 httpapi.ResourceNotFound(rw)
927 return
928 }
929
930 ex, err := examples.List()
931 if err != nil {
932 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
933 Message: "Internal error fetching examples.",
934 Detail: err.Error(),
935 })
936 return
937 }
938
939 httpapi.Write(ctx, rw, http.StatusOK, ex)
940}
941
942// @Summary Get template examples
943// @ID get-template-examples

Callers

nothing calls this directly

Calls 8

AuthorizeMethod · 0.95
OrganizationParamFunction · 0.92
ResourceNotFoundFunction · 0.92
ListFunction · 0.92
WriteFunction · 0.92
InOrgMethod · 0.80
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected