Merge pull request #77 from spotify/include-facts

feat: include facts when listing entities
This commit is contained in:
Jefferson Girão
2020-02-07 11:26:57 +01:00
committed by GitHub
10 changed files with 199 additions and 253 deletions
+3
View File
@@ -7,5 +7,8 @@ replace github.com/spotify/backstage/proto => ../proto
require (
github.com/golang/mock v1.1.1
github.com/spotify/backstage/proto v0.0.0-00010101000000-000000000000
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect
google.golang.org/grpc v1.27.0
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
)
+19 -9
View File
@@ -23,8 +23,16 @@ func (s *Server) ListEntities(ctx context.Context, req *pb.ListEntitiesRequest)
}
var result []*pb.Entity
for _, v := range entities {
result = append(result, &pb.Entity{Uri: v})
for _, entity := range entities {
var facts []*pb.Fact
factTuples, err := s.Storage.GetFacts(entity)
if err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("could not get facts for %v", entity))
}
for key, value := range factTuples {
facts = append(facts, &pb.Fact{Name: key, Value: value})
}
result = append(result, &pb.Entity{Uri: entity, Facts: facts})
}
return &pb.ListEntitiesReply{Entities: result}, nil
@@ -41,19 +49,21 @@ func (s *Server) CreateEntity(ctx context.Context, req *pb.CreateEntityRequest)
// 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))
}
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})
factTuples, err := s.Storage.GetFacts(entityUri)
if err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("could not get facts for %v", entityUri))
}
return &pb.GetEntityReply{Entity: &pb.Entity{Uri: entityUri}, Facts: facts}, nil
for key, value := range factTuples {
facts = append(facts, &pb.Fact{Name: key, 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) {
+39 -71
View File
@@ -15,86 +15,65 @@ import (
var entityURI = "boss://test/test"
func TestServerListEntities(t *testing.T) {
func TestServer(t *testing.T) {
testStorage := NewTestStorage()
defer testStorage.Close()
s := Server{Storage: testStorage.Storage}
entity := &pb.Entity{Uri: entityURI}
t.Run("Listing Entities matching prefix", func(t *testing.T) {
entity := &pb.Entity{Uri: entityURI}
_, err := s.CreateEntity(context.Background(), &pb.CreateEntityRequest{Entity: entity})
if err != nil {
t.Errorf("ServerTest(TestServerListEntities) could not create: %v", err)
}
s.CreateEntity(context.Background(), &pb.CreateEntityRequest{Entity: entity})
setFactReq := &pb.SetFactRequest{EntityUri: entityURI, Name: "test-name", Value: "test-value"}
s.SetFact(context.Background(), setFactReq)
list, err := s.ListEntities(context.Background(), &pb.ListEntitiesRequest{UriPrefix: ""})
if err != nil {
t.Errorf("ServerTest(TestServerListEntities) could not list: %v", err)
}
if len(list.GetEntities()) != 1 {
t.Errorf("ServerTest(TestServerListEntities) expected %v items, got %v", 1, len(list.GetEntities()))
}
if list.GetEntities()[0].GetUri() != entityURI {
t.Errorf("ServerTest(TestServerListEntities) expected uri %v, got %v", "boss://test/test", list.GetEntities()[0].GetUri())
}
list, err := s.ListEntities(context.Background(), &pb.ListEntitiesRequest{UriPrefix: ""})
if err != nil {
t.Errorf("ServerTest(ListEntities) could not list: %v", err)
}
if len(list.GetEntities()) != 1 {
t.Errorf("ServerTest(ListEntities) expected %v items, got %v", 1, len(list.GetEntities()))
}
if list.GetEntities()[0].GetUri() != entityURI {
t.Errorf("ServerTest(ListEntities) expected uri %v, got %v", "boss://test/test", list.GetEntities()[0].GetUri())
}
expectedFacts := []*pb.Fact{{Name: "test-name", Value: "test-value"}}
if !reflect.DeepEqual(list.GetEntities()[0].GetFacts(), expectedFacts) {
t.Errorf("ServerTest(ListEntities) got %v, wanted %v", list.GetEntities()[0].GetFacts(), expectedFacts)
}
})
list, err = s.ListEntities(context.Background(), &pb.ListEntitiesRequest{UriPrefix: "boss://test2"})
if err != nil {
t.Errorf("ServerTest(TestServerListEntities) could not list: %v", err)
}
if len(list.GetEntities()) != 0 {
t.Errorf("ServerTest(TestServerListEntities) expected %v items, got %v", 0, len(list.GetEntities()))
}
}
t.Run("Listing Entities not matching prefix", func(t *testing.T) {
entity := &pb.Entity{Uri: entityURI}
func TestServerCreateEntity(t *testing.T) {
testStorage := NewTestStorage()
defer testStorage.Close()
s := Server{Storage: testStorage.Storage}
entity := &pb.Entity{Uri: entityURI}
createReq := &pb.CreateEntityRequest{Entity: entity}
resp, err := s.CreateEntity(context.Background(), createReq)
if err != nil {
t.Errorf("ServerTest(CreateEntity) got unexpected error %v", err)
}
if resp.GetEntity().GetUri() != entity.GetUri() {
t.Errorf("ServerTest(CreateEntity) expected %v, but got %v", entity.GetUri(), resp.GetEntity().GetUri())
}
}
func TestServerGetEntity(t *testing.T) {
t.Run("Get entity", func(t *testing.T) {
testStorage := NewTestStorage()
defer testStorage.Close()
s := Server{Storage: testStorage.Storage}
s.CreateEntity(context.Background(), &pb.CreateEntityRequest{Entity: entity})
list, err := s.ListEntities(context.Background(), &pb.ListEntitiesRequest{UriPrefix: "boss://test2"})
if err != nil {
t.Errorf("ServerTest(TestServerListEntities) could not list: %v", err)
}
if len(list.GetEntities()) != 0 {
t.Errorf("ServerTest(TestServerListEntities) expected %v items, got %v", 0, len(list.GetEntities()))
}
})
t.Run("Creating entity", func(t *testing.T) {
entity := &pb.Entity{Uri: entityURI}
createReq := &pb.CreateEntityRequest{Entity: entity}
s.CreateEntity(context.Background(), createReq)
req := &pb.GetEntityRequest{Entity: entity}
resp, err := s.GetEntity(context.Background(), req)
resp, err := s.CreateEntity(context.Background(), createReq)
if err != nil {
t.Errorf("ServerTest(GetEntity) got unexpected error %v", err)
}
if resp == nil {
t.Errorf("ServerTest(GetEntity) returned nil")
t.Errorf("ServerTest(CreateEntity) got unexpected error %v", err)
}
if resp.GetEntity().GetUri() != entity.GetUri() {
t.Errorf("ServerTest(GetEntity) got %v, wanted %v", resp.GetEntity().GetUri(), entity.GetUri())
t.Errorf("ServerTest(CreateEntity) expected %v, but got %v", entity.GetUri(), resp.GetEntity().GetUri())
}
})
t.Run("Get entity with included facts", func(t *testing.T) {
testStorage := NewTestStorage()
defer testStorage.Close()
s := Server{Storage: testStorage.Storage}
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"}}
req := &pb.GetEntityRequest{Entity: entity}
resp, err := s.GetEntity(context.Background(), req)
if err != nil {
@@ -104,18 +83,11 @@ func TestServerGetEntity(t *testing.T) {
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)
if !reflect.DeepEqual(resp.GetEntity().GetFacts(), expectedFacts) {
t.Errorf("ServerTest(GetEntity) got %v, wanted %v", resp.GetEntity().GetFacts(), expectedFacts)
}
})
}
func TestServerSetFactForExistingEntity(t *testing.T) {
t.Run("Set fact for existing entity", func(t *testing.T) {
testStorage := NewTestStorage()
defer testStorage.Close()
s := Server{Storage: testStorage.Storage}
entity := &pb.Entity{Uri: entityURI}
createReq := &pb.CreateEntityRequest{Entity: entity}
s.CreateEntity(context.Background(), createReq)
@@ -134,10 +106,6 @@ func TestServerSetFactForExistingEntity(t *testing.T) {
})
t.Run("Set fact for non-existing entity", func(t *testing.T) {
testStorage := NewTestStorage()
defer testStorage.Close()
s := Server{Storage: testStorage.Storage}
req := &pb.SetFactRequest{EntityUri: entityURI, Name: "test-name", Value: "test-value"}
resp, err := s.SetFact(context.Background(), req)
if err != nil {
+3
View File
@@ -8,5 +8,8 @@ require (
github.com/golang/protobuf v1.3.3
github.com/spotify/backstage/proto v0.0.0-00010101000000-000000000000
go.etcd.io/bbolt v1.3.3
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135
google.golang.org/grpc v1.27.0
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc
)
+22
View File
@@ -121,3 +121,25 @@ func (s *Storage) GetEntity(entityUri string) (string, error) {
return entityUri, nil
}
func (s *Storage) GetFacts(entityUri string) (map[string]string, error) {
facts := make(map[string]string)
err := s.db.View(func(tx *bbolt.Tx) error {
entityBucket := tx.Bucket([]byte(entityUri))
if entityBucket == nil {
return fmt.Errorf("bucket '%s' does not exist", entityUri)
}
c := entityBucket.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
facts[string(k)] = string(v)
}
return nil
})
if err != nil {
return nil, err
}
return facts, nil
}
+36 -46
View File
@@ -104,7 +104,6 @@ func (m *ListEntitiesReply) GetEntities() []*Entity {
type GetEntityRequest struct {
Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"`
IncludeFacts []string `protobuf:"bytes,2,rep,name=include_facts,json=includeFacts,proto3" json:"include_facts,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -142,16 +141,8 @@ func (m *GetEntityRequest) GetEntity() *Entity {
return nil
}
func (m *GetEntityRequest) GetIncludeFacts() []string {
if m != nil {
return m.IncludeFacts
}
return nil
}
type GetEntityReply struct {
Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"`
Facts []*Fact `protobuf:"bytes,2,rep,name=facts,proto3" json:"facts,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -189,13 +180,6 @@ func (m *GetEntityReply) GetEntity() *Entity {
return nil
}
func (m *GetEntityReply) GetFacts() []*Fact {
if m != nil {
return m.Facts
}
return nil
}
type CreateEntityRequest struct {
Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -456,6 +440,7 @@ func (m *GetFactReply) GetFact() *Fact {
type Entity struct {
Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"`
Facts []*Fact `protobuf:"bytes,2,rep,name=facts,proto3" json:"facts,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -493,6 +478,13 @@ func (m *Entity) GetUri() string {
return ""
}
func (m *Entity) GetFacts() []*Fact {
if m != nil {
return m.Facts
}
return nil
}
type Fact struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
@@ -558,36 +550,34 @@ func init() {
func init() { proto.RegisterFile("inventory/v1/inventory.proto", fileDescriptor_70be9028e322f9d8) }
var fileDescriptor_70be9028e322f9d8 = []byte{
// 457 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x41, 0x8f, 0x93, 0x40,
0x14, 0x0e, 0x85, 0xad, 0xf2, 0xca, 0x6e, 0x76, 0x67, 0x3d, 0x10, 0xb2, 0x31, 0xcd, 0x68, 0x4c,
0x0f, 0x86, 0x5d, 0xda, 0x8b, 0xf1, 0xe0, 0xa1, 0x46, 0xd1, 0xc4, 0x83, 0xa1, 0x69, 0x34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b,
0x0a, 0xe7, 0x79, 0xeb, 0xf7, 0x92, 0xc8, 0x6f, 0x4b, 0xe4, 0x1f, 0x48, 0x54, 0x5f, 0xe3, 0xf1,
0xf9, 0x97, 0x9e, 0x4a, 0xe6, 0xde, 0xac, 0x2b, 0x7e, 0x1b, 0xa3, 0xbf, 0x01, 0x00, 0x00, 0xff,
0xff, 0x0f, 0x08, 0x7c, 0x37, 0x56, 0x06, 0x00, 0x00,
// 428 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x6b, 0xe2, 0x40,
0x14, 0x27, 0x1a, 0xdd, 0xcd, 0xd3, 0x15, 0x1d, 0xf7, 0x10, 0x44, 0x16, 0x09, 0xcb, 0xe2, 0x61,
0x89, 0x46, 0x2f, 0xcb, 0x1e, 0x7a, 0xb0, 0xb4, 0x69, 0xa1, 0x07, 0x89, 0xd8, 0x96, 0xde, 0xa2,
0x8c, 0x32, 0x54, 0x13, 0x9b, 0x4c, 0x42, 0xf3, 0xdd, 0xfa, 0xe1, 0xca, 0x4c, 0xe2, 0x18, 0x5b,
0x69, 0x22, 0x7a, 0xcb, 0xbc, 0x37, 0xbf, 0x3f, 0xf3, 0x66, 0x7e, 0x04, 0xda, 0xc4, 0x09, 0xb1,
0x43, 0x5d, 0x2f, 0xea, 0x85, 0x46, 0x4f, 0x2c, 0xf4, 0x8d, 0xe7, 0x52, 0x17, 0xfd, 0xf2, 0x37,
0x2e, 0x25, 0x8b, 0x48, 0x9f, 0xd9, 0xf3, 0x67, 0x9f, 0xda, 0x4b, 0xac, 0xef, 0xb6, 0x84, 0x86,
0x36, 0x84, 0xe6, 0x1d, 0xf1, 0xe9, 0x95, 0x43, 0x09, 0x25, 0xd8, 0xb7, 0xf0, 0x4b, 0x80, 0x7d,
0x8a, 0xda, 0xa0, 0x04, 0x1e, 0x19, 0x7b, 0x78, 0x41, 0x5e, 0x55, 0xa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, 0xc2, 0x83, 0x37, 0x19, 0x94, 0xdb, 0x2d, 0x1d, 0x0a, 0xa1, 0x9a, 0x0e,
0x1d, 0x1a, 0x66, 0x89, 0x1f, 0xc8, 0x75, 0xcb, 0x38, 0x0e, 0xc4, 0x26, 0xb9, 0x06, 0x45, 0xe4,
0x07, 0xf5, 0xb3, 0xf0, 0x1f, 0xe3, 0xdb, 0xd2, 0x8f, 0x40, 0x30, 0xb9, 0x10, 0xaa, 0xe9, 0x14,
0x64, 0x1f, 0xf3, 0x40, 0x14, 0xb3, 0x8f, 0xf9, 0x39, 0x68, 0x4b, 0xf8, 0x96, 0x3c, 0x67, 0x94,
0x69, 0x79, 0x3f, 0x51, 0xad, 0xbf, 0xb9, 0xf7, 0x27, 0x42, 0x66, 0x5e, 0x21, 0xf3, 0x48, 0xa1,
0x74, 0x04, 0x46, 0x3f, 0x9e, 0x2a, 0xa2, 0x19, 0x1a, 0xb3, 0x32, 0xff, 0x21, 0x0c, 0xdf, 0x03,
0x00, 0x00, 0xff, 0xff, 0xce, 0x45, 0x7f, 0xc5, 0x30, 0x06, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
+8
View File
@@ -21,6 +21,14 @@ services:
volumes:
- ./backend/identity/identity-data.json:/app/identity-data.json
inventory:
container_name: boss-inventory
build:
context: backend
args:
service: inventory
restart: unless-stopped
builds:
container_name: boss-builds
build:
@@ -44,11 +44,6 @@ export class GetEntityRequest extends jspb.Message {
hasEntity(): boolean;
clearEntity(): void;
getIncludeFactsList(): Array<string>;
setIncludeFactsList(value: Array<string>): void;
clearIncludeFactsList(): void;
addIncludeFacts(value: string, index?: number): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetEntityRequest.AsObject;
static toObject(includeInstance: boolean, msg: GetEntityRequest): GetEntityRequest.AsObject;
@@ -60,7 +55,6 @@ export class GetEntityRequest extends jspb.Message {
export namespace GetEntityRequest {
export type AsObject = {
entity?: Entity.AsObject,
includeFactsList: Array<string>,
}
}
@@ -70,11 +64,6 @@ export class GetEntityReply extends jspb.Message {
hasEntity(): boolean;
clearEntity(): void;
getFactsList(): Array<Fact>;
setFactsList(value: Array<Fact>): void;
clearFactsList(): void;
addFacts(value?: Fact, index?: number): Fact;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetEntityReply.AsObject;
static toObject(includeInstance: boolean, msg: GetEntityReply): GetEntityReply.AsObject;
@@ -86,7 +75,6 @@ export class GetEntityReply extends jspb.Message {
export namespace GetEntityReply {
export type AsObject = {
entity?: Entity.AsObject,
factsList: Array<Fact.AsObject>,
}
}
@@ -222,6 +210,11 @@ export class Entity extends jspb.Message {
getUri(): string;
setUri(value: string): void;
getFactsList(): Array<Fact>;
setFactsList(value: Array<Fact>): void;
clearFactsList(): void;
addFacts(value?: Fact, index?: number): Fact;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Entity.AsObject;
static toObject(includeInstance: boolean, msg: Entity): Entity.AsObject;
@@ -233,6 +226,7 @@ export class Entity extends jspb.Message {
export namespace Entity {
export type AsObject = {
uri: string,
factsList: Array<Fact.AsObject>,
}
}
@@ -76,7 +76,7 @@ if (goog.DEBUG && !COMPILED) {
* @constructor
*/
proto.spotify.backstage.inventory.v1.GetEntityRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.spotify.backstage.inventory.v1.GetEntityRequest.repeatedFields_, null);
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.spotify.backstage.inventory.v1.GetEntityRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
@@ -97,7 +97,7 @@ if (goog.DEBUG && !COMPILED) {
* @constructor
*/
proto.spotify.backstage.inventory.v1.GetEntityReply = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, proto.spotify.backstage.inventory.v1.GetEntityReply.repeatedFields_, null);
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.spotify.backstage.inventory.v1.GetEntityReply, jspb.Message);
if (goog.DEBUG && !COMPILED) {
@@ -244,7 +244,7 @@ if (goog.DEBUG && !COMPILED) {
* @constructor
*/
proto.spotify.backstage.inventory.v1.Entity = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
jspb.Message.initialize(this, opt_data, 0, -1, proto.spotify.backstage.inventory.v1.Entity.repeatedFields_, null);
};
goog.inherits(proto.spotify.backstage.inventory.v1.Entity, jspb.Message);
if (goog.DEBUG && !COMPILED) {
@@ -559,13 +559,6 @@ proto.spotify.backstage.inventory.v1.ListEntitiesReply.prototype.clearEntitiesLi
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.spotify.backstage.inventory.v1.GetEntityRequest.repeatedFields_ = [2];
if (jspb.Message.GENERATE_TO_OBJECT) {
@@ -597,8 +590,7 @@ proto.spotify.backstage.inventory.v1.GetEntityRequest.prototype.toObject = funct
*/
proto.spotify.backstage.inventory.v1.GetEntityRequest.toObject = function(includeInstance, msg) {
var f, obj = {
entity: (f = msg.getEntity()) && proto.spotify.backstage.inventory.v1.Entity.toObject(includeInstance, f),
includeFactsList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f
entity: (f = msg.getEntity()) && proto.spotify.backstage.inventory.v1.Entity.toObject(includeInstance, f)
};
if (includeInstance) {
@@ -640,10 +632,6 @@ proto.spotify.backstage.inventory.v1.GetEntityRequest.deserializeBinaryFromReade
reader.readMessage(value,proto.spotify.backstage.inventory.v1.Entity.deserializeBinaryFromReader);
msg.setEntity(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.addIncludeFacts(value);
break;
default:
reader.skipField();
break;
@@ -681,13 +669,6 @@ proto.spotify.backstage.inventory.v1.GetEntityRequest.serializeBinaryToWriter =
proto.spotify.backstage.inventory.v1.Entity.serializeBinaryToWriter
);
}
f = message.getIncludeFactsList();
if (f.length > 0) {
writer.writeRepeatedString(
2,
f
);
}
};
@@ -724,45 +705,6 @@ proto.spotify.backstage.inventory.v1.GetEntityRequest.prototype.hasEntity = func
};
/**
* repeated string include_facts = 2;
* @return {!Array<string>}
*/
proto.spotify.backstage.inventory.v1.GetEntityRequest.prototype.getIncludeFactsList = function() {
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 2));
};
/** @param {!Array<string>} value */
proto.spotify.backstage.inventory.v1.GetEntityRequest.prototype.setIncludeFactsList = function(value) {
jspb.Message.setField(this, 2, value || []);
};
/**
* @param {string} value
* @param {number=} opt_index
*/
proto.spotify.backstage.inventory.v1.GetEntityRequest.prototype.addIncludeFacts = function(value, opt_index) {
jspb.Message.addToRepeatedField(this, 2, value, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.spotify.backstage.inventory.v1.GetEntityRequest.prototype.clearIncludeFactsList = function() {
this.setIncludeFactsList([]);
};
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.spotify.backstage.inventory.v1.GetEntityReply.repeatedFields_ = [2];
@@ -795,9 +737,7 @@ proto.spotify.backstage.inventory.v1.GetEntityReply.prototype.toObject = functio
*/
proto.spotify.backstage.inventory.v1.GetEntityReply.toObject = function(includeInstance, msg) {
var f, obj = {
entity: (f = msg.getEntity()) && proto.spotify.backstage.inventory.v1.Entity.toObject(includeInstance, f),
factsList: jspb.Message.toObjectList(msg.getFactsList(),
proto.spotify.backstage.inventory.v1.Fact.toObject, includeInstance)
entity: (f = msg.getEntity()) && proto.spotify.backstage.inventory.v1.Entity.toObject(includeInstance, f)
};
if (includeInstance) {
@@ -839,11 +779,6 @@ proto.spotify.backstage.inventory.v1.GetEntityReply.deserializeBinaryFromReader
reader.readMessage(value,proto.spotify.backstage.inventory.v1.Entity.deserializeBinaryFromReader);
msg.setEntity(value);
break;
case 2:
var value = new proto.spotify.backstage.inventory.v1.Fact;
reader.readMessage(value,proto.spotify.backstage.inventory.v1.Fact.deserializeBinaryFromReader);
msg.addFacts(value);
break;
default:
reader.skipField();
break;
@@ -881,14 +816,6 @@ proto.spotify.backstage.inventory.v1.GetEntityReply.serializeBinaryToWriter = fu
proto.spotify.backstage.inventory.v1.Entity.serializeBinaryToWriter
);
}
f = message.getFactsList();
if (f.length > 0) {
writer.writeRepeatedMessage(
2,
f,
proto.spotify.backstage.inventory.v1.Fact.serializeBinaryToWriter
);
}
};
@@ -925,40 +852,6 @@ proto.spotify.backstage.inventory.v1.GetEntityReply.prototype.hasEntity = functi
};
/**
* repeated Fact facts = 2;
* @return {!Array<!proto.spotify.backstage.inventory.v1.Fact>}
*/
proto.spotify.backstage.inventory.v1.GetEntityReply.prototype.getFactsList = function() {
return /** @type{!Array<!proto.spotify.backstage.inventory.v1.Fact>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.spotify.backstage.inventory.v1.Fact, 2));
};
/** @param {!Array<!proto.spotify.backstage.inventory.v1.Fact>} value */
proto.spotify.backstage.inventory.v1.GetEntityReply.prototype.setFactsList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 2, value);
};
/**
* @param {!proto.spotify.backstage.inventory.v1.Fact=} opt_value
* @param {number=} opt_index
* @return {!proto.spotify.backstage.inventory.v1.Fact}
*/
proto.spotify.backstage.inventory.v1.GetEntityReply.prototype.addFacts = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.spotify.backstage.inventory.v1.Fact, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.spotify.backstage.inventory.v1.GetEntityReply.prototype.clearFactsList = function() {
this.setFactsList([]);
};
@@ -1883,6 +1776,13 @@ proto.spotify.backstage.inventory.v1.GetFactReply.prototype.hasFact = function()
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.spotify.backstage.inventory.v1.Entity.repeatedFields_ = [2];
if (jspb.Message.GENERATE_TO_OBJECT) {
@@ -1914,7 +1814,9 @@ proto.spotify.backstage.inventory.v1.Entity.prototype.toObject = function(opt_in
*/
proto.spotify.backstage.inventory.v1.Entity.toObject = function(includeInstance, msg) {
var f, obj = {
uri: jspb.Message.getFieldWithDefault(msg, 1, "")
uri: jspb.Message.getFieldWithDefault(msg, 1, ""),
factsList: jspb.Message.toObjectList(msg.getFactsList(),
proto.spotify.backstage.inventory.v1.Fact.toObject, includeInstance)
};
if (includeInstance) {
@@ -1955,6 +1857,11 @@ proto.spotify.backstage.inventory.v1.Entity.deserializeBinaryFromReader = functi
var value = /** @type {string} */ (reader.readString());
msg.setUri(value);
break;
case 2:
var value = new proto.spotify.backstage.inventory.v1.Fact;
reader.readMessage(value,proto.spotify.backstage.inventory.v1.Fact.deserializeBinaryFromReader);
msg.addFacts(value);
break;
default:
reader.skipField();
break;
@@ -1991,6 +1898,14 @@ proto.spotify.backstage.inventory.v1.Entity.serializeBinaryToWriter = function(m
f
);
}
f = message.getFactsList();
if (f.length > 0) {
writer.writeRepeatedMessage(
2,
f,
proto.spotify.backstage.inventory.v1.Fact.serializeBinaryToWriter
);
}
};
@@ -2009,6 +1924,40 @@ proto.spotify.backstage.inventory.v1.Entity.prototype.setUri = function(value) {
};
/**
* repeated Fact facts = 2;
* @return {!Array<!proto.spotify.backstage.inventory.v1.Fact>}
*/
proto.spotify.backstage.inventory.v1.Entity.prototype.getFactsList = function() {
return /** @type{!Array<!proto.spotify.backstage.inventory.v1.Fact>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.spotify.backstage.inventory.v1.Fact, 2));
};
/** @param {!Array<!proto.spotify.backstage.inventory.v1.Fact>} value */
proto.spotify.backstage.inventory.v1.Entity.prototype.setFactsList = function(value) {
jspb.Message.setRepeatedWrapperField(this, 2, value);
};
/**
* @param {!proto.spotify.backstage.inventory.v1.Fact=} opt_value
* @param {number=} opt_index
* @return {!proto.spotify.backstage.inventory.v1.Fact}
*/
proto.spotify.backstage.inventory.v1.Entity.prototype.addFacts = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.spotify.backstage.inventory.v1.Fact, opt_index);
};
/**
* Clears the list making it empty but non-null.
*/
proto.spotify.backstage.inventory.v1.Entity.prototype.clearFactsList = function() {
this.setFactsList([]);
};
+1 -2
View File
@@ -22,12 +22,10 @@ message ListEntitiesReply {
message GetEntityRequest {
Entity entity = 1;
repeated string include_facts = 2;
}
message GetEntityReply {
Entity entity = 1;
repeated Fact facts = 2;
}
message CreateEntityRequest {
@@ -59,6 +57,7 @@ message GetFactReply {
message Entity {
string uri = 1;
repeated Fact facts = 2;
}
message Fact {