@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)
| 19 | // @Success 200 {object} []codersdk.Organization |
| 20 | // @Router /api/v2/organizations [get] |
| 21 | func (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 |
nothing calls this directly
no test coverage detected