gsn-proxy/internal/repository/satellites.go
2025-03-26 17:14:00 +03:00

27 lines
673 B
Go

package repository
import (
"context"
"net/http"
"git.intra.yksa.space/gsn/gsn-proxy/internal/pkg/ds"
"git.intra.yksa.space/gsn/gsn-proxy/internal/pkg/errcodes"
)
func (r *Repository) GetSatellites(ctx context.Context) ([]ds.Satellite, error) {
satellites, err := r.queries.GetSatellites(ctx)
if err != nil {
return nil, errcodes.New(http.StatusInternalServerError, "failed to get satellites", err.Error())
}
ret := make([]ds.Satellite, 0, len(satellites))
for _, val := range satellites {
ret = append(ret, ds.Satellite{
ID: PGToUUID(val.ID),
DisplayName: val.DisplayName,
Status: ds.Status(val.Status),
})
}
return ret, nil
}