diff --git a/e2e/instance_test.go b/e2e/instance_test.go index 3a96bb349..eeda8287a 100644 --- a/e2e/instance_test.go +++ b/e2e/instance_test.go @@ -45,7 +45,11 @@ func testInstance(t *testing.T) { }) t.Run("list", func(t *testing.T) { - resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{ServiceHash: testServiceHash}) + resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{ + Filter: &pb.ListInstanceRequest_Filter{ + ServiceHash: testServiceHash, + }, + }) require.NoError(t, err) require.Len(t, resp.Instances, 1) require.Equal(t, testServiceHash, resp.Instances[0].ServiceHash) @@ -58,7 +62,11 @@ func testDeleteInstance(t *testing.T) { _, err := client.InstanceClient.Delete(ctx, &pb.DeleteInstanceRequest{Hash: testInstanceHash}) require.NoError(t, err) - resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{ServiceHash: testServiceHash}) + resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{ + Filter: &pb.ListInstanceRequest_Filter{ + ServiceHash: testServiceHash, + }, + }) require.NoError(t, err) require.Len(t, resp.Instances, 0) } diff --git a/protobuf/api/instance.pb.go b/protobuf/api/instance.pb.go index d13004777..ecaaecc19 100644 --- a/protobuf/api/instance.pb.go +++ b/protobuf/api/instance.pb.go @@ -6,6 +6,8 @@ package api import ( context "context" fmt "fmt" + math "math" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" @@ -13,7 +15,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -61,11 +62,11 @@ var xxx_messageInfo_GetInstanceRequest proto.InternalMessageInfo // The request's data for the `List` API. type ListInstanceRequest struct { - // Filter by Services' hash. - ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + // Filter used to filter a stream of executions. + Filter *ListInstanceRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ListInstanceRequest) Reset() { *m = ListInstanceRequest{} } @@ -92,6 +93,46 @@ func (m *ListInstanceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_ListInstanceRequest proto.InternalMessageInfo +func (m *ListInstanceRequest) GetFilter() *ListInstanceRequest_Filter { + if m != nil { + return m.Filter + } + return nil +} + +// Filter contains filtering criteria. +type ListInstanceRequest_Filter struct { + // Service hash to filter executions. + ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListInstanceRequest_Filter) Reset() { *m = ListInstanceRequest_Filter{} } +func (m *ListInstanceRequest_Filter) String() string { return proto.CompactTextString(m) } +func (*ListInstanceRequest_Filter) ProtoMessage() {} +func (*ListInstanceRequest_Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_71d44b8f4a870f63, []int{1, 0} +} +func (m *ListInstanceRequest_Filter) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListInstanceRequest_Filter.Unmarshal(m, b) +} +func (m *ListInstanceRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListInstanceRequest_Filter.Marshal(b, m, deterministic) +} +func (m *ListInstanceRequest_Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListInstanceRequest_Filter.Merge(m, src) +} +func (m *ListInstanceRequest_Filter) XXX_Size() int { + return xxx_messageInfo_ListInstanceRequest_Filter.Size(m) +} +func (m *ListInstanceRequest_Filter) XXX_DiscardUnknown() { + xxx_messageInfo_ListInstanceRequest_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_ListInstanceRequest_Filter proto.InternalMessageInfo + // The response's data for the `List` API. type ListInstanceResponse struct { // List of instances that match the request's filters. @@ -283,6 +324,7 @@ var xxx_messageInfo_DeleteInstanceResponse proto.InternalMessageInfo func init() { proto.RegisterType((*GetInstanceRequest)(nil), "mesg.api.GetInstanceRequest") proto.RegisterType((*ListInstanceRequest)(nil), "mesg.api.ListInstanceRequest") + proto.RegisterType((*ListInstanceRequest_Filter)(nil), "mesg.api.ListInstanceRequest.Filter") proto.RegisterType((*ListInstanceResponse)(nil), "mesg.api.ListInstanceResponse") proto.RegisterType((*CreateInstanceRequest)(nil), "mesg.api.CreateInstanceRequest") proto.RegisterType((*CreateInstanceResponse)(nil), "mesg.api.CreateInstanceResponse") @@ -293,32 +335,34 @@ func init() { func init() { proto.RegisterFile("protobuf/api/instance.proto", fileDescriptor_71d44b8f4a870f63) } var fileDescriptor_71d44b8f4a870f63 = []byte{ - // 400 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x53, 0xcd, 0x8e, 0xd3, 0x30, - 0x10, 0x4e, 0x1a, 0x58, 0x75, 0x67, 0x39, 0x20, 0xb3, 0xac, 0xa2, 0x40, 0xdb, 0xc8, 0xa7, 0x48, - 0x08, 0x47, 0x6a, 0x8f, 0xdc, 0x4a, 0xa5, 0x16, 0x04, 0x97, 0x48, 0x5c, 0x90, 0x38, 0xb8, 0xed, - 0x34, 0xb1, 0xd4, 0xda, 0xa1, 0x76, 0x2a, 0x71, 0xe3, 0x89, 0x78, 0x0e, 0x9e, 0x81, 0x43, 0x9f, - 0x05, 0xc5, 0xe9, 0x4f, 0x68, 0xd3,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x8f, 0x43, 0x9e, 0x3c, 0x07, - 0x0f, 0xe5, 0xc6, 0x6f, 0x85, 0x5e, 0x74, 0x9b, 0x94, 0x47, 0xca, 0xe1, 0xe1, 0x94, 0xc1, 0x4e, - 0xd0, 0xd5, 0xf6, 0x53, 0xaa, 0x1c, 0xe1, 0x12, 0xcf, 0x55, 0x5e, 0xab, 0x05, 0xe9, 0x02, 0xcc, - 0x6d, 0x87, 0x11, 0x37, 0xdc, 0x6f, 0x85, 0x6e, 0xd4, 0x4e, 0x6a, 0x11, 0xea, 0xc3, 0xc3, 0x29, - 0x83, 0x4a, 0x65, 0xff, 0x57, 0x0b, 0xda, 0xfb, 0x20, 0x79, 0x07, 0xde, 0x18, 0x0d, 0x79, 0xcd, - 0xf6, 0xee, 0x67, 0xe7, 0xbe, 0x0d, 0x1a, 0xb7, 0x4a, 0x9d, 0x52, 0x4c, 0x69, 0x0c, 0xd2, 0x39, - 0x56, 0x37, 0xd8, 0x32, 0xe8, 0x5e, 0x7a, 0xae, 0x08, 0x51, 0x87, 0x7c, 0x86, 0x9b, 0x6a, 0x25, - 0xa4, 0x77, 0xcc, 0x6d, 0xb4, 0x49, 0x10, 0x5e, 0x4e, 0xa8, 0xc3, 0x55, 0xda, 0xeb, 0x70, 0x8d, - 0xfb, 0xa8, 0xc3, 0x35, 0x8f, 0x8b, 0x3a, 0xc3, 0xa7, 0x5f, 0x3d, 0x9e, 0x8b, 0xe9, 0x8d, 0xfd, - 0xda, 0x83, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x4a, 0xfe, 0x8c, 0x46, 0x04, 0x00, 0x00, + // 432 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xcd, 0x6e, 0xd4, 0x30, + 0x10, 0x4e, 0x36, 0x10, 0x6d, 0x67, 0x39, 0x20, 0x53, 0xaa, 0x28, 0xd0, 0x6e, 0x64, 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5, 0xde, 0xbb, 0x74, 0x83, + 0xf3, 0xe8, 0xd2, 0x0d, 0xb7, 0x8b, 0x3a, 0x27, 0xf7, 0x3f, 0x79, 0xbc, 0x14, 0x73, 0xdf, 0xfe, + 0x23, 0x8e, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x91, 0xfe, 0x6f, 0x14, 0x8f, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/protobuf/api/instance.proto b/protobuf/api/instance.proto index e802e677b..2238f52c8 100644 --- a/protobuf/api/instance.proto +++ b/protobuf/api/instance.proto @@ -37,11 +37,17 @@ message GetInstanceRequest { // The request's data for the `List` API. message ListInstanceRequest { - // Filter by Services' hash. - bytes serviceHash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; + // Filter contains filtering criteria. + message Filter { + // Service hash to filter executions. + bytes serviceHash = 1 [ + (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", + (gogoproto.nullable) = false + ]; + } + + // Filter used to filter a list of instance. + Filter filter = 1; } // The response's data for the `List` API. diff --git a/server/grpc/api/instance.go b/server/grpc/api/instance.go index 05b62ac6c..128b91fc0 100644 --- a/server/grpc/api/instance.go +++ b/server/grpc/api/instance.go @@ -21,7 +21,7 @@ func NewInstanceServer(sdk *sdk.SDK) *InstanceServer { // List instances. func (s *InstanceServer) List(ctx context.Context, request *protobuf_api.ListInstanceRequest) (*protobuf_api.ListInstanceResponse, error) { - instances, err := s.sdk.Instance.List(&instancesdk.Filter{ServiceHash: request.ServiceHash}) + instances, err := s.sdk.Instance.List(&instancesdk.Filter{ServiceHash: request.Filter.ServiceHash}) if err != nil { return nil, err }