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

Method licenses

enterprise/coderd/licenses.go:235–267  ·  view source on GitHub ↗

@Summary Get licenses @ID get-licenses @Security CoderSessionToken @Produce json @Tags Enterprise @Success 200 {array} codersdk.License @Router /api/v2/licenses [get]

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

Source from the content-addressed store, hash-verified

233// @Success 200 {array} codersdk.License
234// @Router /api/v2/licenses [get]
235func (api *API) licenses(rw http.ResponseWriter, r *http.Request) {
236 ctx := r.Context()
237 licenses, err := api.Database.GetLicenses(ctx)
238 if xerrors.Is(err, sql.ErrNoRows) {
239 httpapi.Write(ctx, rw, http.StatusOK, []codersdk.License{})
240 return
241 }
242 if err != nil {
243 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
244 Message: "Internal error fetching licenses.",
245 Detail: err.Error(),
246 })
247 return
248 }
249
250 licenses, err = coderd.AuthorizeFilter(api.AGPL.HTTPAuth, r, policy.ActionRead, licenses)
251 if err != nil {
252 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
253 Message: "Internal error fetching licenses.",
254 Detail: err.Error(),
255 })
256 return
257 }
258 sdkLicenses, err := convertLicenses(licenses)
259 if err != nil {
260 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
261 Message: "Internal error parsing licenses.",
262 Detail: err.Error(),
263 })
264 return
265 }
266 httpapi.Write(ctx, rw, http.StatusOK, sdkLicenses)
267}
268
269// @Summary Delete license
270// @ID delete-license

Callers

nothing calls this directly

Calls 7

WriteFunction · 0.92
AuthorizeFilterFunction · 0.92
convertLicensesFunction · 0.85
ContextMethod · 0.65
GetLicensesMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected