-
Notifications
You must be signed in to change notification settings - Fork 23
/
policy-service.go
31 lines (26 loc) · 956 Bytes
/
policy-service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package controlplane
import (
"context"
policylangv1 "github.com/fluxninja/aperture/api/gen/proto/go/aperture/policy/language/v1"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
)
// PolicyService is the implementation of policylangv1.PolicyService interface.
type PolicyService struct {
policylangv1.UnimplementedPolicyServiceServer
policyFactory *PolicyFactory
}
// RegisterPolicyService registers a service for policy.
func RegisterPolicyService(server *grpc.Server, policyFactory *PolicyFactory) {
svc := &PolicyService{
policyFactory: policyFactory,
}
policylangv1.RegisterPolicyServiceServer(server, svc)
}
// GetPolicies returns all the policies running in the system.
func (s *PolicyService) GetPolicies(ctx context.Context, _ *emptypb.Empty) (*policylangv1.GetPoliciesResponse, error) {
policies := s.policyFactory.GetPolicies()
return &policylangv1.GetPoliciesResponse{
Policies: policies,
}, nil
}