diff --git a/api/apemanager/grpc/service_grpc.pb.go b/api/apemanager/grpc/service_grpc.pb.go index eb11f3f..bf76cc4 100644 Binary files a/api/apemanager/grpc/service_grpc.pb.go and b/api/apemanager/grpc/service_grpc.pb.go differ diff --git a/api/container/convert.go b/api/container/convert.go index c91bdfd..5a9a805 100644 --- a/api/container/convert.go +++ b/api/container/convert.go @@ -762,3 +762,138 @@ func (r *ListResponse) FromGRPCMessage(m grpc.Message) error { return r.ResponseHeaders.FromMessage(v) } + +func (r *ListStreamRequestBody) ToGRPCMessage() grpc.Message { + var m *container.ListStreamRequest_Body + + if r != nil { + m = new(container.ListStreamRequest_Body) + + m.SetOwnerId(r.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) + } + + return m +} + +func (r *ListStreamRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + ownerID := v.GetOwnerId() + if ownerID == nil { + r.ownerID = nil + } else { + if r.ownerID == nil { + r.ownerID = new(refs.OwnerID) + } + + err = r.ownerID.FromGRPCMessage(ownerID) + } + + return err +} + +func (r *ListStreamRequest) ToGRPCMessage() grpc.Message { + var m *container.ListStreamRequest + + if r != nil { + m = new(container.ListStreamRequest) + + m.SetBody(r.body.ToGRPCMessage().(*container.ListStreamRequest_Body)) + r.RequestHeaders.ToMessage(m) + } + + return m +} + +func (r *ListStreamRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamRequest) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + r.body = nil + } else { + if r.body == nil { + r.body = new(ListStreamRequestBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.RequestHeaders.FromMessage(v) +} + +func (r *ListStreamResponseBody) ToGRPCMessage() grpc.Message { + var m *container.ListStreamResponse_Body + + if r != nil { + m = new(container.ListStreamResponse_Body) + + m.SetContainerIds(refs.ContainerIDsToGRPCMessage(r.cidList)) + } + + return m +} + +func (r *ListStreamResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + r.cidList, err = refs.ContainerIDsFromGRPCMessage(v.GetContainerIds()) + + return err +} + +func (r *ListStreamResponse) ToGRPCMessage() grpc.Message { + var m *container.ListStreamResponse + + if r != nil { + m = new(container.ListStreamResponse) + + m.SetBody(r.body.ToGRPCMessage().(*container.ListStreamResponse_Body)) + r.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (r *ListStreamResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamResponse) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + r.body = nil + } else { + if r.body == nil { + r.body = new(ListStreamResponseBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.ResponseHeaders.FromMessage(v) +} diff --git a/api/container/grpc/service_frostfs.pb.go b/api/container/grpc/service_frostfs.pb.go index 0743824..0388293 100644 Binary files a/api/container/grpc/service_frostfs.pb.go and b/api/container/grpc/service_frostfs.pb.go differ diff --git a/api/container/grpc/service_frostfs_fuzz.go b/api/container/grpc/service_frostfs_fuzz.go index 7e6d6e6..024b237 100644 --- a/api/container/grpc/service_frostfs_fuzz.go +++ b/api/container/grpc/service_frostfs_fuzz.go @@ -157,3 +157,41 @@ func DoFuzzJSONListResponse(data []byte) int { } return 1 } +func DoFuzzProtoListStreamRequest(data []byte) int { + msg := new(ListStreamRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONListStreamRequest(data []byte) int { + msg := new(ListStreamRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoListStreamResponse(data []byte) int { + msg := new(ListStreamResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONListStreamResponse(data []byte) int { + msg := new(ListStreamResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/api/container/grpc/service_frostfs_test.go b/api/container/grpc/service_frostfs_test.go index 804b89c..2844996 100644 --- a/api/container/grpc/service_frostfs_test.go +++ b/api/container/grpc/service_frostfs_test.go @@ -89,3 +89,23 @@ func FuzzJSONListResponse(f *testing.F) { DoFuzzJSONListResponse(data) }) } +func FuzzProtoListStreamRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoListStreamRequest(data) + }) +} +func FuzzJSONListStreamRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONListStreamRequest(data) + }) +} +func FuzzProtoListStreamResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoListStreamResponse(data) + }) +} +func FuzzJSONListStreamResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONListStreamResponse(data) + }) +} diff --git a/api/container/grpc/service_grpc.pb.go b/api/container/grpc/service_grpc.pb.go index ea22604..5991e81 100644 Binary files a/api/container/grpc/service_grpc.pb.go and b/api/container/grpc/service_grpc.pb.go differ diff --git a/api/container/marshal.go b/api/container/marshal.go index 2b16669..89a6661 100644 --- a/api/container/marshal.go +++ b/api/container/marshal.go @@ -343,3 +343,65 @@ func (r *ListResponseBody) StableSize() (size int) { func (r *ListResponseBody) Unmarshal(data []byte) error { return message.Unmarshal(r, data, new(container.ListResponse_Body)) } + +func (r *ListStreamRequestBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + protoutil.NestedStructureMarshal(listReqBodyOwnerField, buf, r.ownerID) + + return buf +} + +func (r *ListStreamRequestBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(listReqBodyOwnerField, r.ownerID) + + return size +} + +func (r *ListStreamRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.ListStreamRequest_Body)) +} + +func (r *ListStreamResponseBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + var offset int + + for i := range r.cidList { + offset += protoutil.NestedStructureMarshal(listRespBodyIDsField, buf[offset:], &r.cidList[i]) + } + + return buf +} + +func (r *ListStreamResponseBody) StableSize() (size int) { + if r == nil { + return 0 + } + + for i := range r.cidList { + size += protoutil.NestedStructureSize(listRespBodyIDsField, &r.cidList[i]) + } + + return size +} + +func (r *ListStreamResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.ListStreamResponse_Body)) +} diff --git a/api/container/types.go b/api/container/types.go index 92c4706..4da3f87 100644 --- a/api/container/types.go +++ b/api/container/types.go @@ -109,6 +109,26 @@ type ListResponse struct { session.ResponseHeaders } +type ListStreamRequestBody struct { + ownerID *refs.OwnerID +} + +type ListStreamRequest struct { + body *ListStreamRequestBody + + session.RequestHeaders +} + +type ListStreamResponseBody struct { + cidList []refs.ContainerID +} + +type ListStreamResponse struct { + body *ListStreamResponseBody + + session.ResponseHeaders +} + func (a *Attribute) GetKey() string { if a != nil { return a.key @@ -444,3 +464,51 @@ func (r *ListResponse) GetBody() *ListResponseBody { func (r *ListResponse) SetBody(v *ListResponseBody) { r.body = v } + +func (r *ListStreamRequestBody) GetOwnerID() *refs.OwnerID { + if r != nil { + return r.ownerID + } + + return nil +} + +func (r *ListStreamRequestBody) SetOwnerID(v *refs.OwnerID) { + r.ownerID = v +} + +func (r *ListStreamRequest) GetBody() *ListStreamRequestBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *ListStreamRequest) SetBody(v *ListStreamRequestBody) { + r.body = v +} + +func (r *ListStreamResponseBody) GetContainerIDs() []refs.ContainerID { + if r != nil { + return r.cidList + } + + return nil +} + +func (r *ListStreamResponseBody) SetContainerIDs(v []refs.ContainerID) { + r.cidList = v +} + +func (r *ListStreamResponse) GetBody() *ListStreamResponseBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *ListStreamResponse) SetBody(v *ListStreamResponseBody) { + r.body = v +} diff --git a/api/object/grpc/service_grpc.pb.go b/api/object/grpc/service_grpc.pb.go index eb53afe..2054f89 100644 Binary files a/api/object/grpc/service_grpc.pb.go and b/api/object/grpc/service_grpc.pb.go differ diff --git a/api/rpc/container.go b/api/rpc/container.go index 9ba5c99..0e3af82 100644 --- a/api/rpc/container.go +++ b/api/rpc/container.go @@ -13,6 +13,7 @@ const ( rpcContainerGet = "Get" rpcContainerDel = "Delete" rpcContainerList = "List" + rpcContainerStream = "ListStream" rpcContainerGetEACL = "GetExtendedACL" rpcContainerUsedSpace = "AnnounceUsedSpace" ) @@ -80,3 +81,27 @@ func ListContainers( return resp, nil } + +type ListStreamResponseReader struct { + r client.MessageReader +} + +func (r *ListStreamResponseReader) Read(resp *container.ListStreamResponse) error { + return r.r.ReadMessage(resp) +} + +// ListContainersStream executes ContainerService.ListStream RPC. +func ListContainersStream( + cli *client.Client, + req *container.ListStreamRequest, + opts ...client.CallOption, +) (*ListStreamResponseReader, error) { + wc, err := client.OpenServerStream(cli, common.CallMethodInfoServerStream(serviceContainer, rpcContainerList), req, opts...) + if err != nil { + return nil, err + } + + return &ListStreamResponseReader{ + r: wc, + }, nil +} diff --git a/api/signature/body.go b/api/signature/body.go index 50a09e9..2467dc0 100644 --- a/api/signature/body.go +++ b/api/signature/body.go @@ -46,6 +46,10 @@ func serviceMessageBody(req any) stableMarshaler { return v.GetBody() case *container.ListResponse: return v.GetBody() + case *container.ListStreamRequest: + return v.GetBody() + case *container.ListStreamResponse: + return v.GetBody() /* Object */ case *object.PutRequest: