replicas returns the number of replicas that are active in Coder. @Summary Get active replicas @ID get-active-replicas @Security CoderSessionToken @Produce json @Tags Enterprise @Success 200 {array} codersdk.Replica @Router /api/v2/replicas [get]
(rw http.ResponseWriter, r *http.Request)
| 20 | // @Success 200 {array} codersdk.Replica |
| 21 | // @Router /api/v2/replicas [get] |
| 22 | func (api *API) replicas(rw http.ResponseWriter, r *http.Request) { |
| 23 | if !api.AGPL.Authorize(r, policy.ActionRead, rbac.ResourceReplicas) { |
| 24 | httpapi.ResourceNotFound(rw) |
| 25 | return |
| 26 | } |
| 27 | |
| 28 | replicas := api.replicaManager.AllPrimary() |
| 29 | res := make([]codersdk.Replica, 0, len(replicas)) |
| 30 | for _, replica := range replicas { |
| 31 | res = append(res, convertReplica(replica)) |
| 32 | } |
| 33 | httpapi.Write(r.Context(), rw, http.StatusOK, res) |
| 34 | } |
| 35 | |
| 36 | func convertReplica(replica database.Replica) codersdk.Replica { |
| 37 | return codersdk.Replica{ |
nothing calls this directly
no test coverage detected