56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
// "time"
|
|
|
|
diags "git.coopgo.io/coopgo-platform/diags/grpcapi"
|
|
"git.coopgo.io/coopgo-platform/diags/storage"
|
|
"google.golang.org/grpc"
|
|
// "google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
type DiagsService struct {
|
|
diags.DiagsClient
|
|
}
|
|
|
|
func NewDiagsService(dial string) (*DiagsService, error) {
|
|
conn, err := grpc.Dial(dial, grpc.WithInsecure())
|
|
|
|
client := diags.NewDiagsClient(conn)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &DiagsService{
|
|
DiagsClient: client,
|
|
}, nil
|
|
}
|
|
|
|
func (s *ServicesHandler) GetDiagsDiags() ([]DiagsDiag, error) {
|
|
resp, err := s.GRPC.Diags.GetDiags(context.TODO(), &diags.GetDiagsRequest{
|
|
Namespaces: []string{"parcoursmob_beneficiaires", "parcoursmob_diagnostiques"},
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
diags := []DiagsDiag{}
|
|
|
|
for _, e := range resp.Diags {
|
|
newDiag := DiagsDiag{
|
|
Diag: e.ToStorageType(),
|
|
}
|
|
diags = append(diags, newDiag)
|
|
}
|
|
|
|
return diags, nil
|
|
}
|
|
|
|
// Enriched types
|
|
|
|
type DiagsDiag struct {
|
|
OwnersGroups []GroupsManagementGroup
|
|
storage.Diag
|
|
}
|