@@ -821,7 +821,8 @@ func (api *API) templateDAUs(rw http.ResponseWriter, r *http.Request) {
821
821
// @Param organization path string true "Organization ID" format(uuid)
822
822
// @Success 200 {array} codersdk.TemplateExample
823
823
// @Router /organizations/{organization}/templates/examples [get]
824
- func (api * API ) templateExamples (rw http.ResponseWriter , r * http.Request ) {
824
+ // @Deprecated Use /templates/examples instead
825
+ func (api * API ) templateExamplesByOrganization (rw http.ResponseWriter , r * http.Request ) {
825
826
var (
826
827
ctx = r .Context ()
827
828
organization = httpmw .OrganizationParam (r )
@@ -844,6 +845,33 @@ func (api *API) templateExamples(rw http.ResponseWriter, r *http.Request) {
844
845
httpapi .Write (ctx , rw , http .StatusOK , ex )
845
846
}
846
847
848
+ // @Summary Get template examples
849
+ // @ID get-template-examples
850
+ // @Security CoderSessionToken
851
+ // @Produce json
852
+ // @Tags Templates
853
+ // @Success 200 {array} codersdk.TemplateExample
854
+ // @Router /templates/examples [get]
855
+ func (api * API ) templateExamples (rw http.ResponseWriter , r * http.Request ) {
856
+ ctx := r .Context ()
857
+
858
+ if ! api .Authorize (r , policy .ActionRead , rbac .ResourceTemplate .AnyOrganization ()) {
859
+ httpapi .ResourceNotFound (rw )
860
+ return
861
+ }
862
+
863
+ ex , err := examples .List ()
864
+ if err != nil {
865
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
866
+ Message : "Internal error fetching examples." ,
867
+ Detail : err .Error (),
868
+ })
869
+ return
870
+ }
871
+
872
+ httpapi .Write (ctx , rw , http .StatusOK , ex )
873
+ }
874
+
847
875
func (api * API ) convertTemplates (templates []database.Template ) []codersdk.Template {
848
876
apiTemplates := make ([]codersdk.Template , 0 , len (templates ))
849
877
0 commit comments