Merge pull request #63 from spotify/get-entity
feat: get single entity with facts
This commit is contained in:
@@ -3,6 +3,7 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spotify/backstage/inventory/storage"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -18,24 +19,41 @@ type Server struct {
|
||||
func (s *Server) CreateEntity(ctx context.Context, req *pb.CreateEntityRequest) (*pb.CreateEntityReply, error) {
|
||||
err := s.Storage.CreateEntity(req.GetEntity().GetUri())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "could not create entity")
|
||||
return nil, status.Error(codes.Internal, "could not create entity")
|
||||
}
|
||||
return &pb.CreateEntityReply{Entity: req.GetEntity()} , nil
|
||||
return &pb.CreateEntityReply{Entity: req.GetEntity()}, nil
|
||||
}
|
||||
|
||||
// GetEntity returns an inventory Entity with the selected facts
|
||||
func (s *Server) GetEntity(ctx context.Context, req *pb.GetEntityRequest) (*pb.GetEntityReply, error) {
|
||||
var facts []*pb.Fact
|
||||
entityUri, err := s.Storage.GetEntity(req.GetEntity().GetUri())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("could not get entity %v", err))
|
||||
}
|
||||
return &pb.GetEntityReply{Entity: &pb.Entity{Uri: entityUri}}, nil
|
||||
for _, factName := range req.GetIncludeFacts() {
|
||||
value, err := s.Storage.GetFact(entityUri, factName)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("could not get fact %v for %v" , factName, entityUri))
|
||||
}
|
||||
facts = append(facts, &pb.Fact{Name: factName, Value: value})
|
||||
}
|
||||
|
||||
return &pb.GetEntityReply{Entity: &pb.Entity{Uri: entityUri}, Facts: facts}, nil
|
||||
}
|
||||
|
||||
func (s *Server) SetFact(ctx context.Context, req *pb.SetFactRequest) (*pb.SetFactReply, error) {
|
||||
factUri, err := s.Storage.SetFact(req.EntityUri, req.Name, req.Value)
|
||||
err := s.Storage.SetFact(req.EntityUri, req.Name, req.Value)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "could not set fact")
|
||||
}
|
||||
return &pb.SetFactReply{FactUri: factUri} , nil
|
||||
return &pb.SetFactReply{Fact: &pb.Fact{Name: req.GetName(), Value: req.GetValue()}}, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetFact(ctx context.Context, req *pb.GetFactRequest) (*pb.GetFactReply, error) {
|
||||
val, err := s.Storage.GetFact(req.EntityUri, req.Name)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "could not set fact")
|
||||
}
|
||||
return &pb.GetFactReply{Fact: &pb.Fact{Name: req.GetName(), Value: val}}, nil
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/spotify/backstage/inventory/storage"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/spotify/backstage/inventory/storage"
|
||||
|
||||
pb "github.com/spotify/backstage/proto/inventory/v1"
|
||||
)
|
||||
|
||||
@@ -22,7 +24,7 @@ func TestServerCreateEntity(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("ServerTest(CreateEntity) got unexpected error %v", err)
|
||||
}
|
||||
if resp.GetEntity().GetUri() != entity.GetUri() {
|
||||
if resp.GetEntity().GetUri() != entity.GetUri() {
|
||||
t.Errorf("ServerTest(CreateEntity) expected %v, but got %v", entity.GetUri(), resp.GetEntity().GetUri())
|
||||
}
|
||||
}
|
||||
@@ -49,6 +51,31 @@ func TestServerGetEntity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerGetEntityWithIncludedFacts(t *testing.T) {
|
||||
testStorage := NewTestStorage()
|
||||
defer testStorage.Close()
|
||||
s := Server{Storage: testStorage.Storage}
|
||||
|
||||
entityUri := "boss://test/test"
|
||||
setFactReq := &pb.SetFactRequest{EntityUri: entityUri, Name: "test-name", Value: "test-value"}
|
||||
s.SetFact(context.Background(), setFactReq)
|
||||
|
||||
entity := &pb.Entity{Uri: entityUri}
|
||||
req := &pb.GetEntityRequest{Entity: entity, IncludeFacts: []string{"test-name"}}
|
||||
|
||||
resp, err := s.GetEntity(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Errorf("ServerTest(GetEntity) got unexpected error %v", err)
|
||||
}
|
||||
if resp == nil {
|
||||
t.Errorf("ServerTest(GetEntity) returned nil")
|
||||
}
|
||||
expectedFacts := []*pb.Fact{{Name: "test-name", Value: "test-value"}}
|
||||
if !reflect.DeepEqual(resp.GetFacts(), expectedFacts) {
|
||||
t.Errorf("ServerTest(GetEntity) got %v, wanted %v", resp.GetFacts(), expectedFacts)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerSetFactForExistingEntity(t *testing.T) {
|
||||
testStorage := NewTestStorage()
|
||||
defer testStorage.Close()
|
||||
@@ -66,8 +93,9 @@ func TestServerSetFactForExistingEntity(t *testing.T) {
|
||||
if resp == nil {
|
||||
t.Errorf("ServerTest(SetFact) returned nil")
|
||||
}
|
||||
if resp.GetFactUri() != entity.GetUri() + "/" + req.Name {
|
||||
t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFactUri(), entity.GetUri() + "/" + req.Name)
|
||||
fact := &pb.Fact{Name: req.GetName(), Value: req.GetValue()}
|
||||
if !reflect.DeepEqual(resp.GetFact(), fact) {
|
||||
t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFact(), fact)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,14 +113,16 @@ func TestServerSetFactForNonExistingEntity(t *testing.T) {
|
||||
if resp == nil {
|
||||
t.Errorf("ServerTest(SetFact) returned nil")
|
||||
}
|
||||
if resp.GetFactUri() != entityUri + "/" + req.Name {
|
||||
t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFactUri(), entityUri + "/" + req.Name)
|
||||
|
||||
fact := &pb.Fact{Name: req.GetName(), Value: req.GetValue()}
|
||||
if !reflect.DeepEqual(resp.GetFact(), fact) {
|
||||
t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFact(), fact)
|
||||
}
|
||||
}
|
||||
|
||||
type TestStorage struct {
|
||||
Storage *storage.Storage
|
||||
Path string
|
||||
Path string
|
||||
}
|
||||
|
||||
// NewTestStorage returns a TestStorage using a temporary path.
|
||||
@@ -114,4 +144,3 @@ func (db *TestStorage) Close() {
|
||||
defer os.Remove(db.Path)
|
||||
db.Storage.Close()
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
func (s *Storage) SetFact(entityUri, name, value string) (factUri string, err error) {
|
||||
err = s.db.Update(func(tx *bbolt.Tx) error {
|
||||
func (s *Storage) SetFact(entityUri, name, value string) (err error) {
|
||||
return s.db.Update(func(tx *bbolt.Tx) error {
|
||||
b, err := tx.CreateBucketIfNotExists([]byte(entityUri))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -49,11 +49,6 @@ func (s *Storage) SetFact(entityUri, name, value string) (factUri string, err er
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return entityUri + "/" + name, nil
|
||||
}
|
||||
|
||||
func (s *Storage) GetFact(entityUri, name string) (string, error) {
|
||||
|
||||
@@ -252,7 +252,7 @@ func (m *SetFactRequest) GetValue() string {
|
||||
}
|
||||
|
||||
type SetFactReply struct {
|
||||
FactUri string `protobuf:"bytes,1,opt,name=factUri,proto3" json:"factUri,omitempty"`
|
||||
Fact *Fact `protobuf:"bytes,1,opt,name=fact,proto3" json:"fact,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
@@ -283,13 +283,99 @@ func (m *SetFactReply) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_SetFactReply proto.InternalMessageInfo
|
||||
|
||||
func (m *SetFactReply) GetFactUri() string {
|
||||
func (m *SetFactReply) GetFact() *Fact {
|
||||
if m != nil {
|
||||
return m.FactUri
|
||||
return m.Fact
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetFactRequest struct {
|
||||
EntityUri string `protobuf:"bytes,1,opt,name=entityUri,proto3" json:"entityUri,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetFactRequest) Reset() { *m = GetFactRequest{} }
|
||||
func (m *GetFactRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetFactRequest) ProtoMessage() {}
|
||||
func (*GetFactRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70be9028e322f9d8, []int{6}
|
||||
}
|
||||
|
||||
func (m *GetFactRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetFactRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetFactRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetFactRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetFactRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetFactRequest.Merge(m, src)
|
||||
}
|
||||
func (m *GetFactRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_GetFactRequest.Size(m)
|
||||
}
|
||||
func (m *GetFactRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetFactRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetFactRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *GetFactRequest) GetEntityUri() string {
|
||||
if m != nil {
|
||||
return m.EntityUri
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetFactRequest) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetFactReply struct {
|
||||
Fact *Fact `protobuf:"bytes,1,opt,name=fact,proto3" json:"fact,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetFactReply) Reset() { *m = GetFactReply{} }
|
||||
func (m *GetFactReply) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetFactReply) ProtoMessage() {}
|
||||
func (*GetFactReply) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70be9028e322f9d8, []int{7}
|
||||
}
|
||||
|
||||
func (m *GetFactReply) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetFactReply.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetFactReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetFactReply.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetFactReply) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetFactReply.Merge(m, src)
|
||||
}
|
||||
func (m *GetFactReply) XXX_Size() int {
|
||||
return xxx_messageInfo_GetFactReply.Size(m)
|
||||
}
|
||||
func (m *GetFactReply) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetFactReply.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetFactReply proto.InternalMessageInfo
|
||||
|
||||
func (m *GetFactReply) GetFact() *Fact {
|
||||
if m != nil {
|
||||
return m.Fact
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Entity struct {
|
||||
Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
@@ -301,7 +387,7 @@ func (m *Entity) Reset() { *m = Entity{} }
|
||||
func (m *Entity) String() string { return proto.CompactTextString(m) }
|
||||
func (*Entity) ProtoMessage() {}
|
||||
func (*Entity) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70be9028e322f9d8, []int{6}
|
||||
return fileDescriptor_70be9028e322f9d8, []int{8}
|
||||
}
|
||||
|
||||
func (m *Entity) XXX_Unmarshal(b []byte) error {
|
||||
@@ -330,9 +416,8 @@ func (m *Entity) GetUri() string {
|
||||
}
|
||||
|
||||
type Fact struct {
|
||||
EntityUri string `protobuf:"bytes,1,opt,name=entityUri,proto3" json:"entityUri,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
@@ -342,7 +427,7 @@ func (m *Fact) Reset() { *m = Fact{} }
|
||||
func (m *Fact) String() string { return proto.CompactTextString(m) }
|
||||
func (*Fact) ProtoMessage() {}
|
||||
func (*Fact) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70be9028e322f9d8, []int{7}
|
||||
return fileDescriptor_70be9028e322f9d8, []int{9}
|
||||
}
|
||||
|
||||
func (m *Fact) XXX_Unmarshal(b []byte) error {
|
||||
@@ -363,13 +448,6 @@ func (m *Fact) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Fact proto.InternalMessageInfo
|
||||
|
||||
func (m *Fact) GetEntityUri() string {
|
||||
if m != nil {
|
||||
return m.EntityUri
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Fact) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
@@ -391,6 +469,8 @@ func init() {
|
||||
proto.RegisterType((*CreateEntityReply)(nil), "spotify.backstage.inventory.v1.CreateEntityReply")
|
||||
proto.RegisterType((*SetFactRequest)(nil), "spotify.backstage.inventory.v1.SetFactRequest")
|
||||
proto.RegisterType((*SetFactReply)(nil), "spotify.backstage.inventory.v1.SetFactReply")
|
||||
proto.RegisterType((*GetFactRequest)(nil), "spotify.backstage.inventory.v1.GetFactRequest")
|
||||
proto.RegisterType((*GetFactReply)(nil), "spotify.backstage.inventory.v1.GetFactReply")
|
||||
proto.RegisterType((*Entity)(nil), "spotify.backstage.inventory.v1.Entity")
|
||||
proto.RegisterType((*Fact)(nil), "spotify.backstage.inventory.v1.Fact")
|
||||
}
|
||||
@@ -398,29 +478,32 @@ func init() {
|
||||
func init() { proto.RegisterFile("inventory/v1/inventory.proto", fileDescriptor_70be9028e322f9d8) }
|
||||
|
||||
var fileDescriptor_70be9028e322f9d8 = []byte{
|
||||
// 346 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x4d, 0x4b, 0xc3, 0x40,
|
||||
0x10, 0x25, 0xfd, 0x92, 0x4c, 0x3f, 0xa8, 0xab, 0x87, 0x50, 0x8a, 0x94, 0x55, 0xa4, 0xa7, 0xd4,
|
||||
0xb4, 0x37, 0x0f, 0x1e, 0x14, 0x15, 0x2f, 0x1e, 0x52, 0x0a, 0xe2, 0x45, 0xb6, 0x75, 0x2a, 0xc1,
|
||||
0x34, 0x89, 0xc9, 0x66, 0x25, 0xff, 0xc1, 0x5f, 0xeb, 0x2f, 0x90, 0xdd, 0xa4, 0x49, 0x15, 0xb1,
|
||||
0x14, 0x73, 0xdb, 0x79, 0xb3, 0xef, 0xcd, 0xcb, 0xcb, 0x2c, 0xf4, 0x1d, 0x4f, 0xa0, 0xc7, 0xfd,
|
||||
0x30, 0x19, 0x09, 0x6b, 0x94, 0x17, 0x66, 0x10, 0xfa, 0xdc, 0x27, 0x47, 0x51, 0xe0, 0x73, 0x67,
|
||||
0x99, 0x98, 0x73, 0xb6, 0x78, 0x8d, 0x38, 0x7b, 0x41, 0xb3, 0xb8, 0x22, 0x2c, 0xfa, 0x0e, 0xdd,
|
||||
0x5b, 0xe4, 0xd7, 0x1e, 0x77, 0x78, 0x62, 0xe3, 0x5b, 0x8c, 0x11, 0x27, 0x17, 0xd0, 0x40, 0x05,
|
||||
0x18, 0xda, 0x40, 0x1b, 0x36, 0xc7, 0xa7, 0xe6, 0xdf, 0x22, 0x66, 0x46, 0xcf, 0x58, 0xe4, 0x18,
|
||||
0xda, 0x8e, 0xb7, 0x70, 0xe3, 0x67, 0x7c, 0x5a, 0xb2, 0x05, 0x8f, 0x8c, 0xca, 0xa0, 0x3a, 0xd4,
|
||||
0xed, 0x56, 0x06, 0xde, 0x48, 0x8c, 0x7e, 0x68, 0xd0, 0xd9, 0x98, 0x1c, 0xb8, 0xc9, 0xbf, 0xe7,
|
||||
0x9e, 0x43, 0xbd, 0x98, 0xd7, 0x1c, 0x9f, 0x6c, 0xa3, 0x4b, 0x23, 0x76, 0x4a, 0xa1, 0x33, 0x38,
|
||||
0xb8, 0x0a, 0x91, 0x71, 0x2c, 0x35, 0x0a, 0x3a, 0x85, 0xfd, 0xef, 0xb2, 0x25, 0x7c, 0x27, 0x7d,
|
||||
0x80, 0xce, 0x14, 0xb9, 0x72, 0x9f, 0xd9, 0xec, 0x83, 0x9e, 0xf6, 0x66, 0xa1, 0xa3, 0x44, 0x75,
|
||||
0xbb, 0x00, 0x08, 0x81, 0x9a, 0xc7, 0x56, 0x68, 0x54, 0x54, 0x43, 0x9d, 0xc9, 0x21, 0xd4, 0x05,
|
||||
0x73, 0x63, 0x34, 0xaa, 0x0a, 0x4c, 0x0b, 0x3a, 0x84, 0x56, 0xae, 0x2c, 0x9d, 0x1a, 0xb0, 0x27,
|
||||
0xe3, 0x29, 0x54, 0xd7, 0x25, 0xed, 0x41, 0x23, 0x75, 0x45, 0xba, 0x50, 0x8d, 0xf3, 0xbe, 0x3c,
|
||||
0xd2, 0x7b, 0xa8, 0x49, 0x89, 0xb2, 0x5c, 0x8d, 0x3f, 0x35, 0xd0, 0xef, 0xd6, 0x79, 0x90, 0x15,
|
||||
0xe8, 0xf9, 0xde, 0x90, 0xb3, 0x6d, 0xd1, 0xfd, 0x5c, 0xee, 0x9e, 0xb9, 0x03, 0x43, 0x46, 0x20,
|
||||
0xa0, 0xb5, 0xf9, 0x07, 0xc9, 0x64, 0x1b, 0xff, 0x97, 0x35, 0xea, 0x59, 0xbb, 0x91, 0x02, 0x37,
|
||||
0xb9, 0x6c, 0x3f, 0x36, 0xf3, 0x1b, 0xc2, 0x9a, 0x37, 0xd4, 0x73, 0x9e, 0x7c, 0x05, 0x00, 0x00,
|
||||
0xff, 0xff, 0xae, 0xd9, 0x2b, 0x51, 0xee, 0x03, 0x00, 0x00,
|
||||
// 390 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x4f, 0xc2, 0x40,
|
||||
0x10, 0x4d, 0x29, 0x60, 0x3a, 0x7c, 0x04, 0x57, 0x0f, 0x4d, 0x43, 0x0c, 0x59, 0x8d, 0xe1, 0x60,
|
||||
0x0a, 0x85, 0x8b, 0xf1, 0xe0, 0x01, 0xa3, 0xd5, 0x6b, 0x09, 0x89, 0xf1, 0x62, 0x0a, 0x2e, 0xa4,
|
||||
0x11, 0x5a, 0x6c, 0xb7, 0x35, 0xfd, 0x0f, 0xfe, 0x2c, 0x7f, 0x98, 0xd9, 0xed, 0x5a, 0x8a, 0x21,
|
||||
0x16, 0x02, 0xb7, 0xdd, 0x99, 0x79, 0xf3, 0x5e, 0x5f, 0x5f, 0x0b, 0x4d, 0xc7, 0x8d, 0x88, 0x4b,
|
||||
0x3d, 0x3f, 0xee, 0x44, 0x46, 0x27, 0xbd, 0xe8, 0x4b, 0xdf, 0xa3, 0x1e, 0x3a, 0x0b, 0x96, 0x1e,
|
||||
0x75, 0xa6, 0xb1, 0x3e, 0xb6, 0x27, 0xef, 0x01, 0xb5, 0x67, 0x44, 0x5f, 0x8d, 0x44, 0x06, 0xfe,
|
||||
0x84, 0x86, 0x49, 0xe8, 0xbd, 0x4b, 0x1d, 0x1a, 0x5b, 0xe4, 0x23, 0x24, 0x01, 0x45, 0xb7, 0x50,
|
||||
0x26, 0xbc, 0xa0, 0x4a, 0x2d, 0xa9, 0x5d, 0xe9, 0x5d, 0xea, 0xff, 0x2f, 0xd1, 0x05, 0x5c, 0xa0,
|
||||
0xd0, 0x39, 0xd4, 0x1c, 0x77, 0x32, 0x0f, 0xdf, 0xc8, 0xeb, 0xd4, 0x9e, 0xd0, 0x40, 0x2d, 0xb4,
|
||||
0xe4, 0xb6, 0x62, 0x55, 0x45, 0xf1, 0x81, 0xd5, 0xf0, 0x97, 0x04, 0xf5, 0x0c, 0xf3, 0x72, 0x1e,
|
||||
0xef, 0xcd, 0x7b, 0x03, 0xa5, 0x15, 0x5f, 0xa5, 0x77, 0x91, 0x07, 0x67, 0x42, 0xac, 0x04, 0x82,
|
||||
0x47, 0x70, 0x72, 0xe7, 0x13, 0x9b, 0x92, 0x83, 0x5a, 0x81, 0x87, 0x70, 0xbc, 0xbe, 0xf6, 0x00,
|
||||
0xcf, 0x89, 0x9f, 0xa1, 0x3e, 0x24, 0x94, 0xab, 0x17, 0x32, 0x9b, 0xa0, 0x24, 0xbd, 0x91, 0xef,
|
||||
0xf0, 0xa5, 0x8a, 0xb5, 0x2a, 0x20, 0x04, 0x45, 0xd7, 0x5e, 0x10, 0xb5, 0xc0, 0x1b, 0xfc, 0x8c,
|
||||
0x4e, 0xa1, 0x14, 0xd9, 0xf3, 0x90, 0xa8, 0x32, 0x2f, 0x26, 0x17, 0xfc, 0x08, 0xd5, 0x74, 0x33,
|
||||
0x53, 0x7a, 0x0d, 0x45, 0x66, 0x8f, 0xd0, 0xb9, 0x9d, 0xa1, 0x1c, 0x81, 0x07, 0xfc, 0xed, 0xee,
|
||||
0xa5, 0x91, 0xa9, 0x31, 0x0f, 0xa3, 0x46, 0x83, 0x72, 0xe2, 0x21, 0x6a, 0x80, 0x1c, 0xa6, 0xfc,
|
||||
0xec, 0x88, 0xbb, 0x50, 0x64, 0x93, 0xa9, 0x02, 0x69, 0x93, 0x4b, 0x85, 0x8c, 0x4b, 0xbd, 0x6f,
|
||||
0x19, 0x94, 0xa7, 0x5f, 0x26, 0xb4, 0x00, 0x25, 0xcd, 0x31, 0xea, 0xe6, 0x89, 0xfa, 0xfb, 0xb1,
|
||||
0x69, 0xfa, 0x0e, 0x08, 0x66, 0x42, 0x04, 0xd5, 0x6c, 0xa2, 0x50, 0x3f, 0x0f, 0xbf, 0x21, 0xd6,
|
||||
0x9a, 0xb1, 0x1b, 0x88, 0xf1, 0xce, 0xe0, 0x48, 0x44, 0x03, 0xe5, 0x4a, 0x5e, 0x4f, 0xa7, 0x76,
|
||||
0xb5, 0xf5, 0xbc, 0x20, 0x32, 0xb7, 0x25, 0x32, 0x77, 0x24, 0xca, 0xc6, 0x69, 0x50, 0x7b, 0xa9,
|
||||
0xa4, 0xcd, 0xc8, 0x18, 0x97, 0xf9, 0x0f, 0xb3, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xab,
|
||||
0xd5, 0x54, 0x50, 0x05, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@@ -437,6 +520,8 @@ const _ = grpc.SupportPackageIsVersion6
|
||||
type InventoryClient interface {
|
||||
GetEntity(ctx context.Context, in *GetEntityRequest, opts ...grpc.CallOption) (*GetEntityReply, error)
|
||||
CreateEntity(ctx context.Context, in *CreateEntityRequest, opts ...grpc.CallOption) (*CreateEntityReply, error)
|
||||
SetFact(ctx context.Context, in *SetFactRequest, opts ...grpc.CallOption) (*SetFactReply, error)
|
||||
GetFact(ctx context.Context, in *GetFactRequest, opts ...grpc.CallOption) (*GetFactReply, error)
|
||||
}
|
||||
|
||||
type inventoryClient struct {
|
||||
@@ -465,10 +550,30 @@ func (c *inventoryClient) CreateEntity(ctx context.Context, in *CreateEntityRequ
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *inventoryClient) SetFact(ctx context.Context, in *SetFactRequest, opts ...grpc.CallOption) (*SetFactReply, error) {
|
||||
out := new(SetFactReply)
|
||||
err := c.cc.Invoke(ctx, "/spotify.backstage.inventory.v1.Inventory/SetFact", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *inventoryClient) GetFact(ctx context.Context, in *GetFactRequest, opts ...grpc.CallOption) (*GetFactReply, error) {
|
||||
out := new(GetFactReply)
|
||||
err := c.cc.Invoke(ctx, "/spotify.backstage.inventory.v1.Inventory/GetFact", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// InventoryServer is the server API for Inventory service.
|
||||
type InventoryServer interface {
|
||||
GetEntity(context.Context, *GetEntityRequest) (*GetEntityReply, error)
|
||||
CreateEntity(context.Context, *CreateEntityRequest) (*CreateEntityReply, error)
|
||||
SetFact(context.Context, *SetFactRequest) (*SetFactReply, error)
|
||||
GetFact(context.Context, *GetFactRequest) (*GetFactReply, error)
|
||||
}
|
||||
|
||||
// UnimplementedInventoryServer can be embedded to have forward compatible implementations.
|
||||
@@ -481,6 +586,12 @@ func (*UnimplementedInventoryServer) GetEntity(ctx context.Context, req *GetEnti
|
||||
func (*UnimplementedInventoryServer) CreateEntity(ctx context.Context, req *CreateEntityRequest) (*CreateEntityReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateEntity not implemented")
|
||||
}
|
||||
func (*UnimplementedInventoryServer) SetFact(ctx context.Context, req *SetFactRequest) (*SetFactReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetFact not implemented")
|
||||
}
|
||||
func (*UnimplementedInventoryServer) GetFact(ctx context.Context, req *GetFactRequest) (*GetFactReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetFact not implemented")
|
||||
}
|
||||
|
||||
func RegisterInventoryServer(s *grpc.Server, srv InventoryServer) {
|
||||
s.RegisterService(&_Inventory_serviceDesc, srv)
|
||||
@@ -522,6 +633,42 @@ func _Inventory_CreateEntity_Handler(srv interface{}, ctx context.Context, dec f
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Inventory_SetFact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetFactRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InventoryServer).SetFact(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/spotify.backstage.inventory.v1.Inventory/SetFact",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InventoryServer).SetFact(ctx, req.(*SetFactRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Inventory_GetFact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetFactRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InventoryServer).GetFact(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/spotify.backstage.inventory.v1.Inventory/GetFact",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InventoryServer).GetFact(ctx, req.(*GetFactRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Inventory_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "spotify.backstage.inventory.v1.Inventory",
|
||||
HandlerType: (*InventoryServer)(nil),
|
||||
@@ -534,6 +681,14 @@ var _Inventory_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "CreateEntity",
|
||||
Handler: _Inventory_CreateEntity_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetFact",
|
||||
Handler: _Inventory_SetFact_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetFact",
|
||||
Handler: _Inventory_GetFact_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "inventory/v1/inventory.proto",
|
||||
|
||||
Generated
+1892
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ option go_package = "inventoryv1";
|
||||
service Inventory {
|
||||
rpc GetEntity(GetEntityRequest) returns (GetEntityReply);
|
||||
rpc CreateEntity(CreateEntityRequest) returns (CreateEntityReply);
|
||||
rpc SetFact(SetFactRequest) returns (SetFactReply);
|
||||
rpc GetFact(GetFactRequest) returns (GetFactReply);
|
||||
}
|
||||
|
||||
message GetEntityRequest {
|
||||
@@ -34,7 +36,16 @@ message SetFactRequest {
|
||||
}
|
||||
|
||||
message SetFactReply {
|
||||
string factUri = 1;
|
||||
Fact fact = 1;
|
||||
}
|
||||
|
||||
message GetFactRequest {
|
||||
string entityUri = 1;
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
message GetFactReply {
|
||||
Fact fact = 1;
|
||||
}
|
||||
|
||||
message Entity {
|
||||
@@ -42,7 +53,6 @@ message Entity {
|
||||
}
|
||||
|
||||
message Fact {
|
||||
string entityUri = 1;
|
||||
string name = 2;
|
||||
string value = 3;
|
||||
string name = 1;
|
||||
string value = 2;
|
||||
}
|
||||
Reference in New Issue
Block a user