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

Method organizations

coderd/organizations.go:21–37  ·  view source on GitHub ↗

@Summary Get organizations @ID get-organizations @Security CoderSessionToken @Produce json @Tags Organizations @Success 200 {object} []codersdk.Organization @Router /api/v2/organizations [get]

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

Source from the content-addressed store, hash-verified

19// @Success 200 {object} []codersdk.Organization
20// @Router /api/v2/organizations [get]
21func (api *API) organizations(rw http.ResponseWriter, r *http.Request) {
22 ctx := r.Context()
23 organizations, err := api.Database.GetOrganizations(ctx, database.GetOrganizationsParams{})
24 if httpapi.Is404Error(err) {
25 httpapi.ResourceNotFound(rw)
26 return
27 }
28 if err != nil {
29 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
30 Message: "Internal error fetching organizations.",
31 Detail: err.Error(),
32 })
33 return
34 }
35
36 httpapi.Write(ctx, rw, http.StatusOK, slice.List(organizations, db2sdk.Organization))
37}
38
39// @Summary Get organization by ID
40// @ID get-organization-by-id

Callers

nothing calls this directly

Calls 7

Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
ListFunction · 0.92
ContextMethod · 0.65
GetOrganizationsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected