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|Mc&F5kV> zHrSFI8mWLu=*cTwdF4&!uc_u&ssOs7s}{>Xc|pK`33~Z3IEts*JIx+Xoh{J{Ir* z7I#~i;yKRMMt~yUZ5?1J5*5xdqe4r8%hci;D@0Moa|3@lbh%pC%t1ibigUwnxxmka zl{!V ^9yUbp5z+?Y$T0m{gp>|f2Rzzwhf!(LGbm}tdoBmofTeUokwPs}%Jt%) zK6@RSEV+al+ALYKiAME}*VfBDrt380Q`#txmTTBvyNRZ59&mL 8G+^7w#wUc&3bay$eE6!rWYvg{3 zNUyuYz2m(q1Q5--jCO$71;lId7qU%XZ&*7u_O>A44&qvk?d%-gQoeC}9W*5B;TjC- zvy7!QHg6A~ZM*L@lH}}d8$3xlhwhR6LP| ZHYU=IzIuUsYR9uEjlJrOcl$kKmsYkc zzs=53xnV_%RZpXsRH%*Ws*kuwZ0x_oYM9ZUsoUzay0x)(x$m}a(ru}L>}V!*{%AA} zCa0)}HKOYHfKxIdi#Fld-U=bR*S=u=7>W}?wt}XAY&3_Wh@JM#u-IY{Me%62TSkMK zgTs7E-*Us2r6${|TUj8piDKz6iZX*H`*M4f`*9R^qJh4>z_T8w_v0wtU&e5()isWy zqyFojM=_hclLIM6`LCsOzaL3agPv>PgwHaPVq(kQj$ad!unmX+#C`t=0{s$!OHnF1 z>tA%!ms)gX`c^8BFq+Iu8$bdW)b*`()s9evyD^ob>{A!KEhE*h_H3# SbGQqb78xHx^}YKA+-j%Z(9tKt(NS2ieLEy3DrRqD$J|WLuBVGNWSb^o0SA_fskc zl+<70Q{S+o{P%x5rD8(W)_u1NpWe@@P(g@U1p9@;7ACoyIThu1t}aPpdr-w$zy-qo zCRLQA`mSo|V@6dL7j2?b&C;F!P%|_$7s~AZx+9HpDzWWrWQC6H#hd8LROXw3&cx3S HQR%+`xH>=} literal 0 HcmV?d00001 diff --git a/apiv2/accounting/grpc/service_frostfs_fuzz.go b/apiv2/accounting/grpc/service_frostfs_fuzz.go new file mode 100644 index 0000000..69e7174 --- /dev/null +++ b/apiv2/accounting/grpc/service_frostfs_fuzz.go @@ -0,0 +1,45 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package accounting + +func DoFuzzProtoBalanceRequest(data []byte) int { + msg := new(BalanceRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONBalanceRequest(data []byte) int { + msg := new(BalanceRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoBalanceResponse(data []byte) int { + msg := new(BalanceResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONBalanceResponse(data []byte) int { + msg := new(BalanceResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/accounting/grpc/service_frostfs_test.go b/apiv2/accounting/grpc/service_frostfs_test.go new file mode 100644 index 0000000..b97a13e --- /dev/null +++ b/apiv2/accounting/grpc/service_frostfs_test.go @@ -0,0 +1,31 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package accounting + +import ( + testing "testing" +) + +func FuzzProtoBalanceRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoBalanceRequest(data) + }) +} +func FuzzJSONBalanceRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONBalanceRequest(data) + }) +} +func FuzzProtoBalanceResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoBalanceResponse(data) + }) +} +func FuzzJSONBalanceResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONBalanceResponse(data) + }) +} diff --git a/apiv2/accounting/grpc/service_grpc.pb.go b/apiv2/accounting/grpc/service_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..63207fe396288297a3e146f2b61b25065774d6a2 GIT binary patch literal 4321 zcmd^DQE%He5Pr6P#mxgcIdJGM!%)CQFl27h8C#PgPWCbk21C(~P+8PS%4tyKzwbLz zvYje!vpwu(MH5)&@p$)rci&MNjc8&rO-o&BE4|L>=AJ5Ryitev?r>=im$p)Z-dxc6 z#TA{tnO=!xG@`Y(E;pqc^TXj2TWI~g_(8nfU8dcC>mS9@D{;i@&eT@vF-fINUHZIS zj`+}#({`OJEkZm=Qc3keF7=LClH{w(SWjuvQ>OI#qo;oJp`Y~F3H6u8EDJ4`rjX@Q z7#p2qSs`(^Z+#S2VdcE^^?tLs+)oAxXL5C$JHmfS%B-rq(1$)>A!3JAJm4a4NSCg* zn*6Qw_yyxF_6zJ_H~5nGOP}8qn(lIc3rmp1`LrnHp3QDF&}t9MNG@ewIv*Ii)PL2v zMTX1E_mji7CJ=HYUXrm?fNCoeK;=Bm={UF+v$|q5-$$IM?)S*?tE4dm$|oC&W|5rv z&l0#QJwL09;+^)lCOel%`I!2nQX8>wVtpjG%!-bOQRAV-uwyVOa$SaO83YxdPTo&x zflNBq)K(3EWGv5M 47eIfG#mF_5Q9iE*`f4jasolh>_y}LLcAee^xlnH4XR{$vP p3q5A5Jpa+S5PF#GwO`ot*MKQ^y&u9 zc3p0kb++eZ4vM7 epF6NNd2@$%Woi?X;5jm=}+bg@|*9hY|Kv6Esr{9m?Iw zS3vHWYm8wGy>MsBH;n)zj>~Ga5xNrG4RPNhnK6qo0W`YVD+70VQLuLms=7daWpkSf z `h;E&X_k#Z?sdv<2J5&*SL}X`7gLc722j8!3Kj*55sWD>df>^E55d< zbjNfMVP@q=>PlB0>KO98E~UNasI;AK*U S%SUK2UFCE%?QCVLcspP>*tIV z44&PfjynSgS&Os-P7HY {VZP|5xG+ef7k7`t+Y V8H#!n-*@1yWH&uxRsE9kT!gaoy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-pT&DV%_#el CTd#}es-eA9(>HP^D<)Gm>FX9ZH*K!~n5lN*3?+fuW?6V?>A@=lnBY)p zyIM~8-e4yv)-G<#seN9lBP^fDs;qqx@e%aIM)0dp!bZ83cb?5v(~3g6a{)KNq!3jr zISSl9h{hbNN;Njj7P4# SIT38P*VEn7qNl)6JLmb>zAfG?}`aa@~+T9N9vFc_X zFAfUSJnw-AtAkxRJ_ 0 { + apeChains := make([]apeGRPC.Chain, len(c.chains)) + for i := range c.chains { + apeChains[i] = *c.chains[i].ToGRPCMessage().(*apeGRPC.Chain) + } + m.SetChains(apeChains) + } + } + + return m +} + +func (c *APEOverride) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*acl.BearerToken_Body_APEOverride) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + if targetGRPC := v.GetTarget(); targetGRPC != nil { + if c.target == nil { + c.target = new(ape.ChainTarget) + } + if err := c.target.FromGRPCMessage(v.GetTarget()); err != nil { + return err + } + } + + if apeChains := v.GetChains(); len(apeChains) > 0 { + c.chains = make([]*ape.Chain, len(apeChains)) + for i := range apeChains { + c.chains[i] = new(ape.Chain) + if err := c.chains[i].FromGRPCMessage(&apeChains[i]); err != nil { + return err + } + } + } + + return nil +} + +func (bt *BearerTokenBody) ToGRPCMessage() grpc.Message { + var m *acl.BearerToken_Body + + if bt != nil { + m = new(acl.BearerToken_Body) + + m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) + m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime)) + m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable)) + m.SetAllowImpersonate(bt.impersonate) + m.SetApeOverride(bt.apeOverride.ToGRPCMessage().(*acl.BearerToken_Body_APEOverride)) + } + + return m +} + +func (bt *BearerTokenBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*acl.BearerToken_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + ownerID := v.GetOwnerId() + if ownerID == nil { + bt.ownerID = nil + } else { + if bt.ownerID == nil { + bt.ownerID = new(refs.OwnerID) + } + + err = bt.ownerID.FromGRPCMessage(ownerID) + if err != nil { + return err + } + } + + lifetime := v.GetLifetime() + if lifetime == nil { + bt.lifetime = nil + } else { + if bt.lifetime == nil { + bt.lifetime = new(TokenLifetime) + } + + err = bt.lifetime.FromGRPCMessage(lifetime) + if err != nil { + return err + } + } + + eacl := v.GetEaclTable() + if eacl == nil { + bt.eacl = nil + } else { + if bt.eacl == nil { + bt.eacl = new(Table) + } + + if err = bt.eacl.FromGRPCMessage(eacl); err != nil { + return err + } + } + + if apeOverrideGRPC := v.GetApeOverride(); apeOverrideGRPC != nil { + if bt.apeOverride == nil { + bt.apeOverride = new(APEOverride) + } + err = bt.apeOverride.FromGRPCMessage(apeOverrideGRPC) + if err != nil { + return err + } + } + + bt.impersonate = v.GetAllowImpersonate() + + return err +} + +func (bt *BearerToken) ToGRPCMessage() grpc.Message { + var m *acl.BearerToken + + if bt != nil { + m = new(acl.BearerToken) + + m.SetBody(bt.body.ToGRPCMessage().(*acl.BearerToken_Body)) + m.SetSignature(bt.sig.ToGRPCMessage().(*refsGRPC.Signature)) + } + + return m +} + +func (bt *BearerToken) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*acl.BearerToken) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + bt.body = nil + } else { + if bt.body == nil { + bt.body = new(BearerTokenBody) + } + + err = bt.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + sig := v.GetSignature() + if sig == nil { + bt.sig = nil + } else { + if bt.sig == nil { + bt.sig = new(refs.Signature) + } + + err = bt.sig.FromGRPCMessage(sig) + } + + return err +} diff --git a/apiv2/acl/filters.go b/apiv2/acl/filters.go new file mode 100644 index 0000000..c1d8afe --- /dev/null +++ b/apiv2/acl/filters.go @@ -0,0 +1,33 @@ +package acl + +// ObjectFilterPrefix is a prefix of key to object header value or property. +const ObjectFilterPrefix = "$Object:" + +const ( + // FilterObjectVersion is a filter key to "version" field of the object header. + FilterObjectVersion = ObjectFilterPrefix + "version" + + // FilterObjectID is a filter key to "object_id" field of the object. + FilterObjectID = ObjectFilterPrefix + "objectID" + + // FilterObjectContainerID is a filter key to "container_id" field of the object header. + FilterObjectContainerID = ObjectFilterPrefix + "containerID" + + // FilterObjectOwnerID is a filter key to "owner_id" field of the object header. + FilterObjectOwnerID = ObjectFilterPrefix + "ownerID" + + // FilterObjectCreationEpoch is a filter key to "creation_epoch" field of the object header. + FilterObjectCreationEpoch = ObjectFilterPrefix + "creationEpoch" + + // FilterObjectPayloadLength is a filter key to "payload_length" field of the object header. + FilterObjectPayloadLength = ObjectFilterPrefix + "payloadLength" + + // FilterObjectPayloadHash is a filter key to "payload_hash" field of the object header. + FilterObjectPayloadHash = ObjectFilterPrefix + "payloadHash" + + // FilterObjectType is a filter key to "object_type" field of the object header. + FilterObjectType = ObjectFilterPrefix + "objectType" + + // FilterObjectHomomorphicHash is a filter key to "homomorphic_hash" field of the object header. + FilterObjectHomomorphicHash = ObjectFilterPrefix + "homomorphicHash" +) diff --git a/apiv2/acl/grpc/types_frostfs.pb.go b/apiv2/acl/grpc/types_frostfs.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..e34267e940e8552717c5acda5361f8a2a9cf5dfc GIT binary patch literal 45158 zcmeHQYi}Dlvi)rTiXH FV8gAY6OxV5>_=})39{DmJsj4oRbqOA|zNyBpP4m!h~v(Yr!>kX&v*YU-U)cibd ze}W1-@nv`R5Pv5-)LNJ<#bcCo#+J$DaM)Xl$#l}~?NDoI!ejLfTxh7l#tzswa@w(c zh-Ezf; K{t|(b=o!$!WI! z5$QIIM`X<`Xb|_4=y}wSFW<4E@6id^_FtPD8~2|@TWLMFwo&l_6{H|PJj8?1h94i{ z(Fmu NSQSPk^LGaa;| z+7*v R|F?W+F%?^Hz!kCMrBG>B&0J$V2Z zvVq3S;iw-^4hEAN`uFr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^hr4#Nd@0Fz2{K;KBJbRb<@ts`!k=T4Nj#tWy(Tkn3q zO72zo3!q-p+{yA(uswB3OD9*KHK}JVhH-D=Bb#ZfRgDxYyutg2#5%Bon*nzPp}uh0 zS5$`v2P+UpJCGjWmKD xbfYO@@jzB4S)H){Y z45^C~aUwZ#>2||LRe@-~!bm9kJfHfXtZeI9a)hV-d>9-B>J*b!QP4WBtcGcql+~1C z4OItMNbHg9xTpP6jsWL{vb?h~nz!w%Py!<|W8e{1838Zc@O6X}U0Xh{cbi0S2AhkP zOpoma$puL0g5|XP0e3XhQ6e8JanE{}GPWek-lVuojmnoOu1V$llT;JMMGCG?ZuPCn z+AmDVN?^+s?@H7#(B!)AB{UdykPZKiw+noSoRXL5Upg@K=~r-E!g1JOA{iai6SBAH zH-)s54vZkD{&+g6^+5oK-tSISNWUTIha`g}qZ&cebRF_MLZ$hYOEo;ZvA_deGv*zw zR{i^puHX}~zJu!nDoJ%B{ab{BI|!Z4kc}3X@VchlST7vX$+_bwJ;PtL4U~WTj^>m$ zrL|)7BqV_3*tYVqI9U5e0L-)1siV~?T0JJOcDeTPP)Wg{Xek_kO|@xgVP;&k#s!h9 z9vqku{*=Dw%g7#0Qy%V8h_z6osxp8Yv5XuPOu!VX#@NkEQ)M-E)JRv3iM6CqQ>9u! zU2Q{PP$)|@RtiyjrQnZlY_|dTQDyX?bAyo21q`JCK5%FcS(M$1eZ{dDu`nnBbpCs> zV;j*HNTNl3<<|IoQP%-ecpKr(ArzhxI^f^Ii6y`ZvhfOsQ`+kko=6`^dCw{NIF~rx s6hNWIpQA$P2?GVfsw(1r52`v)=z~*zFls1sxuTRqO+iMt^tT@WKZYA*Q~&?~ literal 0 HcmV?d00001 diff --git a/apiv2/acl/grpc/types_frostfs_fuzz.go b/apiv2/acl/grpc/types_frostfs_fuzz.go new file mode 100644 index 0000000..5d5b763 --- /dev/null +++ b/apiv2/acl/grpc/types_frostfs_fuzz.go @@ -0,0 +1,64 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package acl + +func DoFuzzProtoEACLRecord(data []byte) int { + msg := new(EACLRecord) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONEACLRecord(data []byte) int { + msg := new(EACLRecord) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoEACLTable(data []byte) int { + msg := new(EACLTable) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONEACLTable(data []byte) int { + msg := new(EACLTable) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoBearerToken(data []byte) int { + msg := new(BearerToken) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONBearerToken(data []byte) int { + msg := new(BearerToken) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/acl/grpc/types_frostfs_test.go b/apiv2/acl/grpc/types_frostfs_test.go new file mode 100644 index 0000000..c6d1c43 --- /dev/null +++ b/apiv2/acl/grpc/types_frostfs_test.go @@ -0,0 +1,41 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package acl + +import ( + testing "testing" +) + +func FuzzProtoEACLRecord(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoEACLRecord(data) + }) +} +func FuzzJSONEACLRecord(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONEACLRecord(data) + }) +} +func FuzzProtoEACLTable(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoEACLTable(data) + }) +} +func FuzzJSONEACLTable(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONEACLTable(data) + }) +} +func FuzzProtoBearerToken(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoBearerToken(data) + }) +} +func FuzzJSONBearerToken(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONBearerToken(data) + }) +} diff --git a/apiv2/acl/json.go b/apiv2/acl/json.go new file mode 100644 index 0000000..64f9cbe --- /dev/null +++ b/apiv2/acl/json.go @@ -0,0 +1,70 @@ +package acl + +import ( + acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/acl/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" +) + +func (f *HeaderFilter) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(f) +} + +func (f *HeaderFilter) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(f, data, new(acl.EACLRecord_Filter)) +} + +func (t *Target) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(t) +} + +func (t *Target) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(t, data, new(acl.EACLRecord_Target)) +} + +func (a *APEOverride) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(a) +} + +func (a *APEOverride) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(a, data, new(acl.BearerToken_Body_APEOverride)) +} + +func (r *Record) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(r) +} + +func (r *Record) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(r, data, new(acl.EACLRecord)) +} + +func (t *Table) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(t) +} + +func (t *Table) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(t, data, new(acl.EACLTable)) +} + +func (l *TokenLifetime) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(l) +} + +func (l *TokenLifetime) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(l, data, new(acl.BearerToken_Body_TokenLifetime)) +} + +func (bt *BearerTokenBody) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(bt) +} + +func (bt *BearerTokenBody) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(bt, data, new(acl.BearerToken_Body)) +} + +func (bt *BearerToken) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(bt) +} + +func (bt *BearerToken) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(bt, data, new(acl.BearerToken)) +} diff --git a/apiv2/acl/marshal.go b/apiv2/acl/marshal.go new file mode 100644 index 0000000..e05c475 --- /dev/null +++ b/apiv2/acl/marshal.go @@ -0,0 +1,350 @@ +package acl + +import ( + acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/acl/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + protoutil "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/util/proto" +) + +const ( + filterHeaderTypeField = 1 + filterMatchTypeField = 2 + filterNameField = 3 + filterValueField = 4 + + targetTypeField = 1 + targetKeysField = 2 + + recordOperationField = 1 + recordActionField = 2 + recordFiltersField = 3 + recordTargetsField = 4 + + tableVersionField = 1 + tableContainerIDField = 2 + tableRecordsField = 3 + + lifetimeExpirationField = 1 + lifetimeNotValidBeforeField = 2 + lifetimeIssuedAtField = 3 + + tokenAPEChainsTargetField = 1 + tokenAPEChainsChainsField = 2 + + bearerTokenBodyACLField = 1 + bearerTokenBodyOwnerField = 2 + bearerTokenBodyLifetimeField = 3 + bearerTokenBodyImpersonate = 4 + bearerTokenTokenAPEChainsField = 5 + + bearerTokenBodyField = 1 + bearerTokenSignatureField = 2 +) + +// StableMarshal marshals unified acl table structure in a protobuf +// compatible way without field order shuffle. +func (t *Table) StableMarshal(buf []byte) []byte { + if t == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, t.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(tableVersionField, buf[offset:], t.version) + offset += protoutil.NestedStructureMarshal(tableContainerIDField, buf[offset:], t.cid) + + for i := range t.records { + offset += protoutil.NestedStructureMarshal(tableRecordsField, buf[offset:], &t.records[i]) + } + + return buf +} + +// StableSize of acl table structure marshalled by StableMarshal function. +func (t *Table) StableSize() (size int) { + if t == nil { + return 0 + } + + size += protoutil.NestedStructureSize(tableVersionField, t.version) + size += protoutil.NestedStructureSize(tableContainerIDField, t.cid) + + for i := range t.records { + size += protoutil.NestedStructureSize(tableRecordsField, &t.records[i]) + } + + return size +} + +func (t *Table) Unmarshal(data []byte) error { + return message.Unmarshal(t, data, new(acl.EACLTable)) +} + +// StableMarshal marshals unified acl record structure in a protobuf +// compatible way without field order shuffle. +func (r *Record) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + var offset int + + offset += protoutil.EnumMarshal(recordOperationField, buf[offset:], int32(r.op)) + offset += protoutil.EnumMarshal(recordActionField, buf[offset:], int32(r.action)) + + for i := range r.filters { + offset += protoutil.NestedStructureMarshal(recordFiltersField, buf[offset:], &r.filters[i]) + } + + for i := range r.targets { + offset += protoutil.NestedStructureMarshal(recordTargetsField, buf[offset:], &r.targets[i]) + } + + return buf +} + +// StableSize of acl record structure marshalled by StableMarshal function. +func (r *Record) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.EnumSize(recordOperationField, int32(r.op)) + size += protoutil.EnumSize(recordActionField, int32(r.action)) + + for i := range r.filters { + size += protoutil.NestedStructureSize(recordFiltersField, &r.filters[i]) + } + + for i := range r.targets { + size += protoutil.NestedStructureSize(recordTargetsField, &r.targets[i]) + } + + return size +} + +func (r *Record) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(acl.EACLRecord)) +} + +// StableMarshal marshals unified header filter structure in a protobuf +// compatible way without field order shuffle. +func (f *HeaderFilter) StableMarshal(buf []byte) []byte { + if f == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, f.StableSize()) + } + + var offset int + + offset += protoutil.EnumMarshal(filterHeaderTypeField, buf[offset:], int32(f.hdrType)) + offset += protoutil.EnumMarshal(filterMatchTypeField, buf[offset:], int32(f.matchType)) + offset += protoutil.StringMarshal(filterNameField, buf[offset:], f.key) + protoutil.StringMarshal(filterValueField, buf[offset:], f.value) + + return buf +} + +// StableSize of header filter structure marshalled by StableMarshal function. +func (f *HeaderFilter) StableSize() (size int) { + if f == nil { + return 0 + } + + size += protoutil.EnumSize(filterHeaderTypeField, int32(f.hdrType)) + size += protoutil.EnumSize(filterMatchTypeField, int32(f.matchType)) + size += protoutil.StringSize(filterNameField, f.key) + size += protoutil.StringSize(filterValueField, f.value) + + return size +} + +func (f *HeaderFilter) Unmarshal(data []byte) error { + return message.Unmarshal(f, data, new(acl.EACLRecord_Filter)) +} + +// StableMarshal marshals unified role info structure in a protobuf +// compatible way without field order shuffle. +func (t *Target) StableMarshal(buf []byte) []byte { + if t == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, t.StableSize()) + } + + var offset int + + offset += protoutil.EnumMarshal(targetTypeField, buf[offset:], int32(t.role)) + protoutil.RepeatedBytesMarshal(targetKeysField, buf[offset:], t.keys) + + return buf +} + +// StableSize of role info structure marshalled by StableMarshal function. +func (t *Target) StableSize() (size int) { + if t == nil { + return 0 + } + + size += protoutil.EnumSize(targetTypeField, int32(t.role)) + size += protoutil.RepeatedBytesSize(targetKeysField, t.keys) + + return size +} + +func (t *Target) Unmarshal(data []byte) error { + return message.Unmarshal(t, data, new(acl.EACLRecord_Target)) +} + +func (l *TokenLifetime) StableMarshal(buf []byte) []byte { + if l == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, l.StableSize()) + } + + var offset int + + offset += protoutil.UInt64Marshal(lifetimeExpirationField, buf[offset:], l.exp) + offset += protoutil.UInt64Marshal(lifetimeNotValidBeforeField, buf[offset:], l.nbf) + protoutil.UInt64Marshal(lifetimeIssuedAtField, buf[offset:], l.iat) + + return buf +} + +func (l *TokenLifetime) StableSize() (size int) { + if l == nil { + return 0 + } + + size += protoutil.UInt64Size(lifetimeExpirationField, l.exp) + size += protoutil.UInt64Size(lifetimeNotValidBeforeField, l.nbf) + size += protoutil.UInt64Size(lifetimeIssuedAtField, l.iat) + + return size +} + +func (l *TokenLifetime) Unmarshal(data []byte) error { + return message.Unmarshal(l, data, new(acl.BearerToken_Body_TokenLifetime)) +} + +func (c *APEOverride) StableMarshal(buf []byte) []byte { + if c == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, c.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(tokenAPEChainsTargetField, buf[offset:], c.target) + for i := range c.chains { + offset += protoutil.NestedStructureMarshal(tokenAPEChainsChainsField, buf[offset:], c.chains[i]) + } + + return buf +} + +func (c *APEOverride) StableSize() (size int) { + if c == nil { + return 0 + } + + size += protoutil.NestedStructureSize(tokenAPEChainsTargetField, c.target) + for i := range c.chains { + size += protoutil.NestedStructureSize(tokenAPEChainsChainsField, c.chains[i]) + } + + return size +} + +func (c *APEOverride) Unmarshal(data []byte) error { + return message.Unmarshal(c, data, new(acl.BearerToken_Body_APEOverride)) +} + +func (bt *BearerTokenBody) StableMarshal(buf []byte) []byte { + if bt == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, bt.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(bearerTokenBodyACLField, buf[offset:], bt.eacl) + offset += protoutil.NestedStructureMarshal(bearerTokenBodyOwnerField, buf[offset:], bt.ownerID) + offset += protoutil.NestedStructureMarshal(bearerTokenBodyLifetimeField, buf[offset:], bt.lifetime) + offset += protoutil.BoolMarshal(bearerTokenBodyImpersonate, buf[offset:], bt.impersonate) + protoutil.NestedStructureMarshal(bearerTokenTokenAPEChainsField, buf[offset:], bt.apeOverride) + + return buf +} + +func (bt *BearerTokenBody) StableSize() (size int) { + if bt == nil { + return 0 + } + + size += protoutil.NestedStructureSize(bearerTokenBodyACLField, bt.eacl) + size += protoutil.NestedStructureSize(bearerTokenBodyOwnerField, bt.ownerID) + size += protoutil.NestedStructureSize(bearerTokenBodyLifetimeField, bt.lifetime) + size += protoutil.BoolSize(bearerTokenBodyImpersonate, bt.impersonate) + size += protoutil.NestedStructureSize(bearerTokenTokenAPEChainsField, bt.apeOverride) + + return size +} + +func (bt *BearerTokenBody) Unmarshal(data []byte) error { + return message.Unmarshal(bt, data, new(acl.BearerToken_Body)) +} + +func (bt *BearerToken) StableMarshal(buf []byte) []byte { + if bt == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, bt.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(bearerTokenBodyField, buf[offset:], bt.body) + protoutil.NestedStructureMarshal(bearerTokenSignatureField, buf[offset:], bt.sig) + + return buf +} + +func (bt *BearerToken) StableSize() (size int) { + if bt == nil { + return 0 + } + + size += protoutil.NestedStructureSize(bearerTokenBodyField, bt.body) + size += protoutil.NestedStructureSize(bearerTokenSignatureField, bt.sig) + + return size +} + +func (bt *BearerToken) Unmarshal(data []byte) error { + return message.Unmarshal(bt, data, new(acl.BearerToken)) +} diff --git a/apiv2/acl/message_test.go b/apiv2/acl/message_test.go new file mode 100644 index 0000000..bc16637 --- /dev/null +++ b/apiv2/acl/message_test.go @@ -0,0 +1,21 @@ +package acl_test + +import ( + "testing" + + acltest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/acl/test" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + messagetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message/test" +) + +func TestMessageConvert(t *testing.T) { + messagetest.TestRPCMessage(t, + func(empty bool) message.Message { return acltest.GenerateFilter(empty) }, + func(empty bool) message.Message { return acltest.GenerateTarget(empty) }, + func(empty bool) message.Message { return acltest.GenerateRecord(empty) }, + func(empty bool) message.Message { return acltest.GenerateTable(empty) }, + func(empty bool) message.Message { return acltest.GenerateTokenLifetime(empty) }, + func(empty bool) message.Message { return acltest.GenerateBearerTokenBody(empty) }, + func(empty bool) message.Message { return acltest.GenerateBearerToken(empty) }, + ) +} diff --git a/apiv2/acl/string.go b/apiv2/acl/string.go new file mode 100644 index 0000000..65801b0 --- /dev/null +++ b/apiv2/acl/string.go @@ -0,0 +1,110 @@ +package acl + +import ( + acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/acl/grpc" +) + +// String returns string representation of Action. +func (x Action) String() string { + return ActionToGRPCField(x).String() +} + +// FromString parses Action from a string representation. +// It is a reverse action to String(). +// +// Returns true if s was parsed successfully. +func (x *Action) FromString(s string) bool { + var g acl.Action + + ok := g.FromString(s) + + if ok { + *x = ActionFromGRPCField(g) + } + + return ok +} + +// String returns string representation of Role. +func (x Role) String() string { + return RoleToGRPCField(x).String() +} + +// FromString parses Role from a string representation. +// It is a reverse action to String(). +// +// Returns true if s was parsed successfully. +func (x *Role) FromString(s string) bool { + var g acl.Role + + ok := g.FromString(s) + + if ok { + *x = RoleFromGRPCField(g) + } + + return ok +} + +// String returns string representation of Operation. +func (x Operation) String() string { + return OperationToGRPCField(x).String() +} + +// FromString parses Operation from a string representation. +// It is a reverse action to String(). +// +// Returns true if s was parsed successfully. +func (x *Operation) FromString(s string) bool { + var g acl.Operation + + ok := g.FromString(s) + + if ok { + *x = OperationFromGRPCField(g) + } + + return ok +} + +// String returns string representation of MatchType. +func (x MatchType) String() string { + return MatchTypeToGRPCField(x).String() +} + +// FromString parses MatchType from a string representation. +// It is a reverse action to String(). +// +// Returns true if s was parsed successfully. +func (x *MatchType) FromString(s string) bool { + var g acl.MatchType + + ok := g.FromString(s) + + if ok { + *x = MatchTypeFromGRPCField(g) + } + + return ok +} + +// String returns string representation of HeaderType. +func (x HeaderType) String() string { + return HeaderTypeToGRPCField(x).String() +} + +// FromString parses HeaderType from a string representation. +// It is a reverse action to String(). +// +// Returns true if s was parsed successfully. +func (x *HeaderType) FromString(s string) bool { + var g acl.HeaderType + + ok := g.FromString(s) + + if ok { + *x = HeaderTypeFromGRPCField(g) + } + + return ok +} diff --git a/apiv2/acl/test/generate.go b/apiv2/acl/test/generate.go new file mode 100644 index 0000000..1e07c8f --- /dev/null +++ b/apiv2/acl/test/generate.go @@ -0,0 +1,144 @@ +package acltest + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/acl" + apetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/ape/test" + accountingtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs/test" +) + +func GenerateBearerToken(empty bool) *acl.BearerToken { + m := new(acl.BearerToken) + + if !empty { + m.SetBody(GenerateBearerTokenBody(false)) + } + + m.SetSignature(accountingtest.GenerateSignature(empty)) + + return m +} + +func GenerateBearerTokenBody(empty bool) *acl.BearerTokenBody { + m := new(acl.BearerTokenBody) + + if !empty { + m.SetOwnerID(accountingtest.GenerateOwnerID(false)) + m.SetLifetime(GenerateTokenLifetime(false)) + m.SetAPEOverride(GenerateAPEOverride(empty)) + } + + return m +} + +func GenerateAPEOverride(empty bool) *acl.APEOverride { + var m *acl.APEOverride + + if !empty { + m = new(acl.APEOverride) + m.SetTarget(apetest.GenerateChainTarget(empty)) + m.SetChains(apetest.GenerateRawChains(false, 3)) + } + + return m +} + +func GenerateTable(empty bool) *acl.Table { + m := new(acl.Table) + + if !empty { + m.SetRecords(GenerateRecords(false)) + m.SetContainerID(accountingtest.GenerateContainerID(false)) + } + + m.SetVersion(accountingtest.GenerateVersion(empty)) + + return m +} + +func GenerateRecords(empty bool) []acl.Record { + var rs []acl.Record + + if !empty { + rs = append(rs, + *GenerateRecord(false), + *GenerateRecord(false), + ) + } + + return rs +} + +func GenerateRecord(empty bool) *acl.Record { + m := new(acl.Record) + + if !empty { + m.SetAction(acl.ActionAllow) + m.SetOperation(acl.OperationGet) + m.SetFilters(GenerateFilters(false)) + m.SetTargets(GenerateTargets(false)) + } + + return m +} + +func GenerateFilters(empty bool) []acl.HeaderFilter { + var fs []acl.HeaderFilter + + if !empty { + fs = append(fs, + *GenerateFilter(false), + *GenerateFilter(false), + ) + } + + return fs +} + +func GenerateFilter(empty bool) *acl.HeaderFilter { + m := new(acl.HeaderFilter) + + if !empty { + m.SetKey("key") + m.SetValue("val") + m.SetHeaderType(acl.HeaderTypeRequest) + m.SetMatchType(acl.MatchTypeStringEqual) + } + + return m +} + +func GenerateTargets(empty bool) []acl.Target { + var ts []acl.Target + + if !empty { + ts = append(ts, + *GenerateTarget(false), + *GenerateTarget(false), + ) + } + + return ts +} + +func GenerateTarget(empty bool) *acl.Target { + m := new(acl.Target) + + if !empty { + m.SetRole(acl.RoleSystem) + m.SetKeys([][]byte{{1}, {2}}) + } + + return m +} + +func GenerateTokenLifetime(empty bool) *acl.TokenLifetime { + m := new(acl.TokenLifetime) + + if !empty { + m.SetExp(1) + m.SetIat(2) + m.SetExp(3) + } + + return m +} diff --git a/apiv2/acl/types.go b/apiv2/acl/types.go new file mode 100644 index 0000000..06eb2f0 --- /dev/null +++ b/apiv2/acl/types.go @@ -0,0 +1,426 @@ +package acl + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/ape" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs" +) + +// HeaderFilter is a unified structure of FilterInfo +// message from proto definition. +type HeaderFilter struct { + hdrType HeaderType + + matchType MatchType + + key, value string +} + +// Target is a unified structure of Target +// message from proto definition. +type Target struct { + role Role + + keys [][]byte +} + +// Record is a unified structure of EACLRecord +// message from proto definition. +type Record struct { + op Operation + + action Action + + filters []HeaderFilter + + targets []Target +} + +// Table is a unified structure of EACLTable +// message from proto definition. +type Table struct { + version *refs.Version + + cid *refs.ContainerID + + records []Record +} + +type TokenLifetime struct { + exp, nbf, iat uint64 +} + +type APEOverride struct { + target *ape.ChainTarget + + chains []*ape.Chain +} + +type BearerTokenBody struct { + eacl *Table + + ownerID *refs.OwnerID + + lifetime *TokenLifetime + + apeOverride *APEOverride + + impersonate bool +} + +type BearerToken struct { + body *BearerTokenBody + + sig *refs.Signature +} + +// Target is a unified enum of MatchType enum from proto definition. +type MatchType uint32 + +// HeaderType is a unified enum of HeaderType enum from proto definition. +type HeaderType uint32 + +// Action is a unified enum of Action enum from proto definition. +type Action uint32 + +// Operation is a unified enum of Operation enum from proto definition. +type Operation uint32 + +// Role is a unified enum of Role enum from proto definition. +type Role uint32 + +const ( + MatchTypeUnknown MatchType = iota + MatchTypeStringEqual + MatchTypeStringNotEqual +) + +const ( + HeaderTypeUnknown HeaderType = iota + HeaderTypeRequest + HeaderTypeObject + HeaderTypeService +) + +const ( + ActionUnknown Action = iota + ActionAllow + ActionDeny +) + +const ( + OperationUnknown Operation = iota + OperationGet + OperationHead + OperationPut + OperationDelete + OperationSearch + OperationRange + OperationRangeHash +) + +const ( + RoleUnknown Role = iota + RoleUser + RoleSystem + RoleOthers +) + +func (f *HeaderFilter) GetHeaderType() HeaderType { + if f != nil { + return f.hdrType + } + + return HeaderTypeUnknown +} + +func (f *HeaderFilter) SetHeaderType(v HeaderType) { + f.hdrType = v +} + +func (f *HeaderFilter) GetMatchType() MatchType { + if f != nil { + return f.matchType + } + + return MatchTypeUnknown +} + +func (f *HeaderFilter) SetMatchType(v MatchType) { + f.matchType = v +} + +func (f *HeaderFilter) GetKey() string { + if f != nil { + return f.key + } + + return "" +} + +func (f *HeaderFilter) SetKey(v string) { + f.key = v +} + +func (f *HeaderFilter) GetValue() string { + if f != nil { + return f.value + } + + return "" +} + +func (f *HeaderFilter) SetValue(v string) { + f.value = v +} + +func (t *Target) GetRole() Role { + if t != nil { + return t.role + } + + return RoleUnknown +} + +func (t *Target) SetRole(v Role) { + t.role = v +} + +func (t *Target) GetKeys() [][]byte { + if t != nil { + return t.keys + } + + return nil +} + +func (t *Target) SetKeys(v [][]byte) { + t.keys = v +} + +func (r *Record) GetOperation() Operation { + if r != nil { + return r.op + } + + return OperationUnknown +} + +func (r *Record) SetOperation(v Operation) { + r.op = v +} + +func (r *Record) GetAction() Action { + if r != nil { + return r.action + } + + return ActionUnknown +} + +func (r *Record) SetAction(v Action) { + r.action = v +} + +func (r *Record) GetFilters() []HeaderFilter { + if r != nil { + return r.filters + } + + return nil +} + +func (r *Record) SetFilters(v []HeaderFilter) { + r.filters = v +} + +func (r *Record) GetTargets() []Target { + if r != nil { + return r.targets + } + + return nil +} + +func (r *Record) SetTargets(v []Target) { + r.targets = v +} + +func (t *Table) GetVersion() *refs.Version { + if t != nil { + return t.version + } + + return nil +} + +func (t *Table) SetVersion(v *refs.Version) { + t.version = v +} + +func (t *Table) GetContainerID() *refs.ContainerID { + if t != nil { + return t.cid + } + + return nil +} + +func (t *Table) SetContainerID(v *refs.ContainerID) { + t.cid = v +} + +func (t *Table) GetRecords() []Record { + if t != nil { + return t.records + } + + return nil +} + +func (t *Table) SetRecords(v []Record) { + t.records = v +} + +func (l *TokenLifetime) GetExp() uint64 { + if l != nil { + return l.exp + } + + return 0 +} + +func (l *TokenLifetime) SetExp(v uint64) { + l.exp = v +} + +func (l *TokenLifetime) GetNbf() uint64 { + if l != nil { + return l.nbf + } + + return 0 +} + +func (l *TokenLifetime) SetNbf(v uint64) { + l.nbf = v +} + +func (l *TokenLifetime) GetIat() uint64 { + if l != nil { + return l.iat + } + + return 0 +} + +func (l *TokenLifetime) SetIat(v uint64) { + l.iat = v +} + +func (bt *BearerTokenBody) GetEACL() *Table { + if bt != nil { + return bt.eacl + } + + return nil +} + +func (bt *BearerTokenBody) SetEACL(v *Table) { + bt.eacl = v +} + +func (t *APEOverride) GetTarget() *ape.ChainTarget { + if t == nil { + return nil + } + + return t.target +} + +func (t *APEOverride) GetChains() []*ape.Chain { + if t == nil { + return nil + } + + return t.chains +} + +func (t *APEOverride) SetTarget(v *ape.ChainTarget) { + t.target = v +} + +func (t *APEOverride) SetChains(v []*ape.Chain) { + t.chains = v +} + +func (bt *BearerTokenBody) GetAPEOverride() *APEOverride { + if bt != nil { + return bt.apeOverride + } + + return nil +} + +func (bt *BearerTokenBody) SetAPEOverride(v *APEOverride) { + bt.apeOverride = v +} + +func (bt *BearerTokenBody) GetOwnerID() *refs.OwnerID { + if bt != nil { + return bt.ownerID + } + + return nil +} + +func (bt *BearerTokenBody) SetOwnerID(v *refs.OwnerID) { + bt.ownerID = v +} + +func (bt *BearerTokenBody) GetLifetime() *TokenLifetime { + if bt != nil { + return bt.lifetime + } + + return nil +} + +func (bt *BearerTokenBody) SetLifetime(v *TokenLifetime) { + bt.lifetime = v +} + +func (bt *BearerTokenBody) GetImpersonate() bool { + if bt != nil { + return bt.impersonate + } + + return false +} + +func (bt *BearerTokenBody) SetImpersonate(v bool) { + bt.impersonate = v +} + +func (bt *BearerToken) GetBody() *BearerTokenBody { + if bt != nil { + return bt.body + } + + return nil +} + +func (bt *BearerToken) SetBody(v *BearerTokenBody) { + bt.body = v +} + +func (bt *BearerToken) GetSignature() *refs.Signature { + if bt != nil { + return bt.sig + } + + return nil +} + +func (bt *BearerToken) SetSignature(v *refs.Signature) { + bt.sig = v +} diff --git a/apiv2/ape/convert.go b/apiv2/ape/convert.go new file mode 100644 index 0000000..f70acf3 --- /dev/null +++ b/apiv2/ape/convert.go @@ -0,0 +1,132 @@ +package ape + +import ( + "fmt" + + ape "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/ape/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" +) + +func TargetTypeToGRPCField(typ TargetType) ape.TargetType { + switch typ { + case TargetTypeNamespace: + return ape.TargetType_NAMESPACE + case TargetTypeContainer: + return ape.TargetType_CONTAINER + case TargetTypeUser: + return ape.TargetType_USER + case TargetTypeGroup: + return ape.TargetType_GROUP + default: + return ape.TargetType_UNDEFINED + } +} + +func TargetTypeFromGRPCField(typ ape.TargetType) TargetType { + switch typ { + case ape.TargetType_NAMESPACE: + return TargetTypeNamespace + case ape.TargetType_CONTAINER: + return TargetTypeContainer + case ape.TargetType_USER: + return TargetTypeUser + case ape.TargetType_GROUP: + return TargetTypeGroup + default: + return TargetTypeUndefined + } +} + +func TargetTypeToGRPC(typ TargetType) ape.TargetType { + return ape.TargetType(typ) +} + +func TargetTypeFromGRPC(typ ape.TargetType) TargetType { + return TargetType(typ) +} + +func (v2 *ChainTarget) ToGRPCMessage() grpc.Message { + var mgrpc *ape.ChainTarget + + if v2 != nil { + mgrpc = new(ape.ChainTarget) + + mgrpc.SetType(TargetTypeToGRPC(v2.GetTargetType())) + mgrpc.SetName(v2.GetName()) + } + + return mgrpc +} + +func (v2 *ChainTarget) FromGRPCMessage(m grpc.Message) error { + mgrpc, ok := m.(*ape.ChainTarget) + if !ok { + return message.NewUnexpectedMessageType(m, mgrpc) + } + + v2.SetTargetType(TargetTypeFromGRPC(mgrpc.GetType())) + v2.SetName(mgrpc.GetName()) + + return nil +} + +func (v2 *ChainRaw) ToGRPCMessage() grpc.Message { + var mgrpc *ape.Chain_Raw + + if v2 != nil { + mgrpc = new(ape.Chain_Raw) + + mgrpc.SetRaw(v2.GetRaw()) + } + + return mgrpc +} + +func (v2 *ChainRaw) FromGRPCMessage(m grpc.Message) error { + mgrpc, ok := m.(*ape.Chain_Raw) + if !ok { + return message.NewUnexpectedMessageType(m, mgrpc) + } + + v2.SetRaw(mgrpc.GetRaw()) + + return nil +} + +func (v2 *Chain) ToGRPCMessage() grpc.Message { + var mgrpc *ape.Chain + + if v2 != nil { + mgrpc = new(ape.Chain) + + switch chainKind := v2.GetKind().(type) { + default: + panic(fmt.Sprintf("unsupported chain kind: %T", chainKind)) + case *ChainRaw: + mgrpc.SetKind(chainKind.ToGRPCMessage().(*ape.Chain_Raw)) + } + } + + return mgrpc +} + +func (v2 *Chain) FromGRPCMessage(m grpc.Message) error { + mgrpc, ok := m.(*ape.Chain) + if !ok { + return message.NewUnexpectedMessageType(m, mgrpc) + } + + switch chainKind := mgrpc.GetKind().(type) { + default: + return fmt.Errorf("unsupported chain kind: %T", chainKind) + case *ape.Chain_Raw: + chainRaw := new(ChainRaw) + if err := chainRaw.FromGRPCMessage(chainKind); err != nil { + return err + } + v2.SetKind(chainRaw) + } + + return nil +} diff --git a/apiv2/ape/grpc/types_frostfs.pb.go b/apiv2/ape/grpc/types_frostfs.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..fe31b5a8e8935a27f887aea1623f8faf762b45fd GIT binary patch literal 8237 zcmeHMZExE~68 AkqzKK4=|NWks zT`oyQvg=ENUV$^3#9YqKJUcTxGY>l)ilbyM#f^+*>g94SruSlzCV4V@i?z2m$y+~7 zvfR&HaeOK!rx#*;d~)IT`wMS&=iNx*Eo8qRM2jTNh28J{o+YucWIRjeL3}f$N2}lS zqg+_{3%@RsBox+7kh`_wAoi2tMOw(CFe&CAyy;NCd7I7efMDn?f^v6Q V-i z5T*r7kpqWHgk+a#kUuA^WFVd8=`4v$Vd-D2zSHmL_X{a5y!1xq7xZfo=X<;TJ_Iuk zVDswwa&kO=e=->#x8)DScE8sWnjC%{pPwBbjk`iS9igMs$;BZwed-GBc7!g^@t%Jg z_2NM6b%cKWbb5LArO-Ydt@Kh#!Djb$>_rkPB5(1T&v^w;AT1yIz25dnSmuD%04qCK zF{j~`U91@Bys}5TfRi8g@xXZK>9J$D^unUHtZZH}0J7XNI}+Puxn*`Fc6g;RI}*FR z!e&RxL3_NSY^$YxtUQtv{34zSyJ|Vw5$Akr+Yt(i0E)mD K3l3=}ZoN`AuckrlrT47fZL+8BwH6|zv&}$| zc8*RSq{V@NW7|oKa)rCel7Bx?Xx(vKM06^9XP^q8UAdG44kFT(RH@3cy8}_VlnM~4 z?*MdA{NXAc4vsr{11&L>k&JWYvQ3Er@G|wincQ^X6}|QxW%~2g^gfr4{+A9L(LJW- z*rdf7J^d(i8*t~+M-r}ie^%sn1cAyOM?qeLw HL@YUys9bQ`-fkT-@d_=810F^0;bI}<`3b*Y6I&z#wudst zW{%{V&AK?Xqy4C3Z0=9(sHdZB#NqpA<7|X$-F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9*yW!FG9BY)z9^i+2yY(XfJ bCYYep1UYE*v54)l@p*A%ti`Z3~5JKK^Ubig4$eI_uCU36?Ky@ znpKELeZNO21^(pdkBA=ER6OpX>;aZpv#xN(AR{c7qyL2T@HF@ED?BV@MPk<%7iDt1 z?Bv^ZHMWFXj5u>fZUwSR+sB xmMxmqCuU0jOTCUQckHYPyjM})5Q#&W+*`4bIfk%QoLbj8I-}Y zP>mvPlMt7%gvcQ-Yl4h>2!qJr&hme8~x%fzYEv}O=3!_WQ zu|YRjjN;jRDl<8~B@y32@=bCbrt-+9 rnMZm?eYm%mmUYIu4;;~&%TCbf)7%9%<;VyHi2w;@fyxN_Q{3TG)+u($ zv|;_@0Bt(pHE2iZM{X3YK_)q@hOAc|fAaffpMK; G+3RMx!VqJ(X&g5ko{6OD_bsosnY^;@4dv8+ zQ+-i%lR24g^d?YToBFdu0IrqE;xhn2il={II3knbuk;V82`1Sa!LC%)P$dK^5DE2r z(PBEK1x}4LAIQFB7+Qc!EF_FF#6MFwvIN-0XL(D|X6>at{>oLKk;K y+XKQ-<&6xV4Min+BO&X{f9q*^&dJ)!z}STH|VDELnwG=&!Iu KS!ve@bN@fzVgFhH literal 0 HcmV?d00001 diff --git a/apiv2/apemanager/grpc/service_frostfs_fuzz.go b/apiv2/apemanager/grpc/service_frostfs_fuzz.go new file mode 100644 index 0000000..08af63e --- /dev/null +++ b/apiv2/apemanager/grpc/service_frostfs_fuzz.go @@ -0,0 +1,121 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package apemanager + +func DoFuzzProtoAddChainRequest(data []byte) int { + msg := new(AddChainRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONAddChainRequest(data []byte) int { + msg := new(AddChainRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoAddChainResponse(data []byte) int { + msg := new(AddChainResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONAddChainResponse(data []byte) int { + msg := new(AddChainResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoRemoveChainRequest(data []byte) int { + msg := new(RemoveChainRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONRemoveChainRequest(data []byte) int { + msg := new(RemoveChainRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoRemoveChainResponse(data []byte) int { + msg := new(RemoveChainResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONRemoveChainResponse(data []byte) int { + msg := new(RemoveChainResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoListChainsRequest(data []byte) int { + msg := new(ListChainsRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONListChainsRequest(data []byte) int { + msg := new(ListChainsRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoListChainsResponse(data []byte) int { + msg := new(ListChainsResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONListChainsResponse(data []byte) int { + msg := new(ListChainsResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/apemanager/grpc/service_frostfs_test.go b/apiv2/apemanager/grpc/service_frostfs_test.go new file mode 100644 index 0000000..5c4653c --- /dev/null +++ b/apiv2/apemanager/grpc/service_frostfs_test.go @@ -0,0 +1,71 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package apemanager + +import ( + testing "testing" +) + +func FuzzProtoAddChainRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoAddChainRequest(data) + }) +} +func FuzzJSONAddChainRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONAddChainRequest(data) + }) +} +func FuzzProtoAddChainResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoAddChainResponse(data) + }) +} +func FuzzJSONAddChainResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONAddChainResponse(data) + }) +} +func FuzzProtoRemoveChainRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoRemoveChainRequest(data) + }) +} +func FuzzJSONRemoveChainRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONRemoveChainRequest(data) + }) +} +func FuzzProtoRemoveChainResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoRemoveChainResponse(data) + }) +} +func FuzzJSONRemoveChainResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONRemoveChainResponse(data) + }) +} +func FuzzProtoListChainsRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoListChainsRequest(data) + }) +} +func FuzzJSONListChainsRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONListChainsRequest(data) + }) +} +func FuzzProtoListChainsResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoListChainsResponse(data) + }) +} +func FuzzJSONListChainsResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONListChainsResponse(data) + }) +} diff --git a/apiv2/apemanager/grpc/service_grpc.pb.go b/apiv2/apemanager/grpc/service_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..47814272fe891c0b1e467544d451c40630017f37 GIT binary patch literal 9993 zcmeHNYj5MY75yCl3f2Xtw&BRLSu6(dA}9jKvo*T0gFO1BExe3G+rr4AmZY6A2Knzj zmy|5pvQlSfXJ=X@m`QB$lJ~)Lc^_1-#|APIY%WrvxDgS1*sx4VBg0cXJDtnZxyr(T zT~63|a>s_3qr0Hd>#?;^I+m&K)0fi&Q`q{u;QQdMKg|4}^$)?>yWot*wOpxC^cl~@ zlBawwRF9bUv{36f6oHke(a3oC0fQb{qY*DNsSIm1PC}U)@zJnm{-N18p+#78F6BHC z!CWRhod;6Q?cx{?p}4La@7YmMX~WH`p3Dt58|?;Za<_;z!#~bKxy<53oSJwEi8WL) zFc&kDiBzwYU}nJ$eu22O{R}f`89b!<+{6!wV2`m`fD)TT`V>}(4Us*FIGq>FBF5)D zPPMT+bR&LU#R?kEZ>|TYKS{eGXTe)06-%(yDrmq|+OR1*w@U}NtBkC9?d&|#|8RT! zu8|YM$`{weE4M|rZgZv=Q8ZY9>-7C9Nv?!h$Y{)=Gk(rlvo}*xo0$&QXF<8WL1md< zu?#F;8JymTrCf`HY+k~{Tjn5}pJQz-6J1f}C2Y!N3RqM$8YHnu?FQ1mhVI+N^@z=| zITdPFI0CRi@OTd*O|D|%5Li=kl}0QyAK6L+YxFsh8o20*G$MFtqXb{lCm=z0S(XS6 zN+o7O5h54HWV+w$Wgq5nlOPi7-eITd{nhY?^GJq&b_xt+ng(O>cxxF14YSEaRs2F( z_@|ojP_R#p6KH`Qho7hw5FQeMtnQrYOoZ_)4w>Om0<95}7TrT0nGae^!Va-~_+V3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DAX48NpGBBF+M8B%*dS}~FOMCRiY4yzNB|48 XWo1}Mdoxo&; c&D;ZPGa82pdBhFJzLl>Y9eA@0qC7SJ1D?O@ssI20 literal 0 HcmV?d00001 diff --git a/apiv2/apemanager/marshal.go b/apiv2/apemanager/marshal.go new file mode 100644 index 0000000..b742248 --- /dev/null +++ b/apiv2/apemanager/marshal.go @@ -0,0 +1,205 @@ +package apemanager + +import ( + apemanager "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/apemanager/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/util/proto" +) + +const ( + addChainReqBodyTargetField = 1 + addChainReqBodyChainField = 2 + + addChainRespBodyChainIDField = 1 + + removeChainReqBodyTargetField = 1 + removeChainReqBodyChainField = 2 + + /* + Fields for RemoveResponseBody are missed since RemoveResponseBody is empty. + */ + + listChainsReqBodyTargetField = 1 + + listChainsRespBodyChainsField = 1 +) + +func (rb *AddChainRequestBody) StableSize() (size int) { + if rb == nil { + return 0 + } + + size += proto.NestedStructureSize(addChainReqBodyTargetField, rb.target) + size += proto.NestedStructureSize(addChainReqBodyChainField, rb.chain) + + return size +} + +func (rb *AddChainRequestBody) StableMarshal(buf []byte) []byte { + if rb == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, rb.StableSize()) + } + + var offset int + + offset += proto.NestedStructureMarshal(addChainReqBodyTargetField, buf[offset:], rb.target) + proto.NestedStructureMarshal(addChainReqBodyChainField, buf[offset:], rb.chain) + + return buf +} + +func (rb *AddChainRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(rb, data, new(apemanager.AddChainRequest_Body)) +} + +func (rb *AddChainResponseBody) StableSize() (size int) { + if rb == nil { + return 0 + } + + size += proto.BytesSize(addChainRespBodyChainIDField, rb.chainID) + + return size +} + +func (rb *AddChainResponseBody) StableMarshal(buf []byte) []byte { + if rb == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, rb.StableSize()) + } + + var offset int + + proto.BytesMarshal(addChainRespBodyChainIDField, buf[offset:], rb.chainID) + + return buf +} + +func (rb *AddChainResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(rb, data, new(apemanager.AddChainResponse_Body)) +} + +func (rb *RemoveChainRequestBody) StableSize() (size int) { + if rb == nil { + return 0 + } + + size += proto.NestedStructureSize(addChainReqBodyTargetField, rb.target) + size += proto.BytesSize(addChainReqBodyChainField, rb.chainID) + + return size +} + +func (rb *RemoveChainRequestBody) StableMarshal(buf []byte) []byte { + if rb == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, rb.StableSize()) + } + + var offset int + + offset += proto.NestedStructureMarshal(removeChainReqBodyTargetField, buf[offset:], rb.target) + proto.BytesMarshal(removeChainReqBodyChainField, buf[offset:], rb.chainID) + + return buf +} + +func (rb *RemoveChainRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(rb, data, new(apemanager.RemoveChainRequest_Body)) +} + +func (rb *RemoveChainResponseBody) StableSize() (size int) { + if rb == nil { + return 0 + } + + return size +} + +func (rb *RemoveChainResponseBody) StableMarshal(buf []byte) []byte { + if rb == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, rb.StableSize()) + } + + return buf +} + +func (rb *RemoveChainResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(rb, data, new(apemanager.RemoveChainResponse_Body)) +} + +func (rb *ListChainsRequestBody) StableSize() (size int) { + if rb == nil { + return 0 + } + + size += proto.NestedStructureSize(listChainsReqBodyTargetField, rb.target) + + return size +} + +func (rb *ListChainsRequestBody) StableMarshal(buf []byte) []byte { + if rb == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, rb.StableSize()) + } + + var offset int + proto.NestedStructureMarshal(addChainReqBodyTargetField, buf[offset:], rb.target) + + return buf +} + +func (rb *ListChainsRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(rb, data, new(apemanager.ListChainsRequest_Body)) +} + +func (rb *ListChainsResponseBody) StableSize() (size int) { + if rb == nil { + return 0 + } + + for _, chain := range rb.GetChains() { + size += proto.NestedStructureSize(listChainsRespBodyChainsField, chain) + } + + return size +} + +func (rb *ListChainsResponseBody) StableMarshal(buf []byte) []byte { + if rb == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, rb.StableSize()) + } + + var offset int + for _, chain := range rb.GetChains() { + offset += proto.NestedStructureMarshal(listChainsRespBodyChainsField, buf[offset:], chain) + } + + return buf +} + +func (rb *ListChainsResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(rb, data, new(apemanager.ListChainsResponse_Body)) +} diff --git a/apiv2/apemanager/message_test.go b/apiv2/apemanager/message_test.go new file mode 100644 index 0000000..caac5ee --- /dev/null +++ b/apiv2/apemanager/message_test.go @@ -0,0 +1,26 @@ +package apemanager_test + +import ( + "testing" + + apemanagertest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/apemanager/test" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + messagetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message/test" +) + +func TestMessageConvert(t *testing.T) { + messagetest.TestRPCMessage(t, + func(empty bool) message.Message { return apemanagertest.GenerateAddChainRequestBody(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateAddChainRequest(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateAddChainResponseBody(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateAddChainResponse(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateRemoveChainRequestBody(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateRemoveChainRequest(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateRemoveChainResponseBody(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateRemoveChainResponse(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateListChainsRequestBody(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateListChainsRequest(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateListChainsResponseBody(empty) }, + func(empty bool) message.Message { return apemanagertest.GenerateListChainsResponse(empty) }, + ) +} diff --git a/apiv2/apemanager/status.go b/apiv2/apemanager/status.go new file mode 100644 index 0000000..bf1ffa0 --- /dev/null +++ b/apiv2/apemanager/status.go @@ -0,0 +1,76 @@ +package apemanager + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status" + statusgrpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status/grpc" +) + +// LocalizeFailStatus checks if passed global status.Code is related to ape manager failure and: +// +// then localizes the code and returns true, +// else leaves the code unchanged and returns false. +// +// Arg must be non-nil. +func LocalizeFailStatus(c *status.Code) bool { + return status.LocalizeIfInSection(c, uint32(statusgrpc.Section_SECTION_APE_MANAGER)) +} + +// GlobalizeFail globalizes local code of ape manager failure. +// +// Arg must be non-nil. +func GlobalizeFail(c *status.Code) { + c.GlobalizeSection(uint32(statusgrpc.Section_SECTION_APE_MANAGER)) +} + +const ( + // StatusAPEManagerAccessDenied is a local status.Code value for + // ACCESS_DENIED ape manager failure. + StatusAPEManagerAccessDenied status.Code = iota +) + +const ( + // detailAccessDeniedDesc is a StatusAccessDenied detail ID for + // human-readable description. + detailAccessDeniedDesc = iota +) + +// WriteAccessDeniedDesc writes human-readable description of StatusAccessDenied +// into status.Status as a detail. The status must not be nil. +// +// Existing details are expected to be ID-unique, otherwise undefined behavior. +func WriteAccessDeniedDesc(st *status.Status, desc string) { + var found bool + + st.IterateDetails(func(d *status.Detail) bool { + if d.ID() == detailAccessDeniedDesc { + found = true + d.SetValue([]byte(desc)) + } + + return found + }) + + if !found { + var d status.Detail + + d.SetID(detailAccessDeniedDesc) + d.SetValue([]byte(desc)) + + st.AppendDetails(d) + } +} + +// ReadAccessDeniedDesc looks up for status detail with human-readable description +// of StatusAccessDenied. Returns empty string if detail is missing. +func ReadAccessDeniedDesc(st status.Status) (desc string) { + st.IterateDetails(func(d *status.Detail) bool { + if d.ID() == detailAccessDeniedDesc { + desc = string(d.Value()) + return true + } + + return false + }) + + return +} diff --git a/apiv2/apemanager/status_test.go b/apiv2/apemanager/status_test.go new file mode 100644 index 0000000..3cccf16 --- /dev/null +++ b/apiv2/apemanager/status_test.go @@ -0,0 +1,30 @@ +package apemanager_test + +import ( + "testing" + + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/apemanager" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status" + statustest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status/test" + "github.com/stretchr/testify/require" +) + +func TestStatusCodes(t *testing.T) { + statustest.TestCodes(t, apemanager.LocalizeFailStatus, apemanager.GlobalizeFail, + apemanager.StatusAPEManagerAccessDenied, 5120, + ) +} + +func TestAccessDeniedDesc(t *testing.T) { + var st status.Status + + require.Empty(t, apemanager.ReadAccessDeniedDesc(st)) + + const desc = "some description" + + apemanager.WriteAccessDeniedDesc(&st, desc) + require.Equal(t, desc, apemanager.ReadAccessDeniedDesc(st)) + + apemanager.WriteAccessDeniedDesc(&st, desc+"1") + require.Equal(t, desc+"1", apemanager.ReadAccessDeniedDesc(st)) +} diff --git a/apiv2/apemanager/test/generate.go b/apiv2/apemanager/test/generate.go new file mode 100644 index 0000000..c9bc41b --- /dev/null +++ b/apiv2/apemanager/test/generate.go @@ -0,0 +1,143 @@ +package apemanagertest + +import ( + apetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/ape/test" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/apemanager" + sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/session/test" +) + +func generateChainID(empty bool) []byte { + if empty { + return []byte{} + } + + return []byte("616c6c6f774f626a476574436e72") +} + +func GenerateAddChainRequestBody(empty bool) *apemanager.AddChainRequestBody { + m := new(apemanager.AddChainRequestBody) + + if !empty { + m.SetTarget(apetest.GenerateChainTarget(empty)) + m.SetChain(apetest.GenerateRawChain(empty)) + } + + return m +} + +func GenerateAddChainRequest(empty bool) *apemanager.AddChainRequest { + m := new(apemanager.AddChainRequest) + + if !empty { + m.SetBody(GenerateAddChainRequestBody(empty)) + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + } + + return m +} + +func GenerateAddChainResponseBody(empty bool) *apemanager.AddChainResponseBody { + m := new(apemanager.AddChainResponseBody) + + if !empty { + m.SetChainID(generateChainID(empty)) + } + + return m +} + +func GenerateAddChainResponse(empty bool) *apemanager.AddChainResponse { + m := new(apemanager.AddChainResponse) + + if !empty { + m.SetBody(GenerateAddChainResponseBody(empty)) + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + } + + return m +} + +func GenerateRemoveChainRequestBody(empty bool) *apemanager.RemoveChainRequestBody { + m := new(apemanager.RemoveChainRequestBody) + + if !empty { + m.SetChainID(generateChainID(empty)) + m.SetTarget(apetest.GenerateChainTarget(empty)) + } + + return m +} + +func GenerateRemoveChainRequest(empty bool) *apemanager.RemoveChainRequest { + m := new(apemanager.RemoveChainRequest) + + if !empty { + m.SetBody(GenerateRemoveChainRequestBody(empty)) + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + } + + return m +} + +func GenerateRemoveChainResponseBody(_ bool) *apemanager.RemoveChainResponseBody { + return new(apemanager.RemoveChainResponseBody) +} + +func GenerateRemoveChainResponse(empty bool) *apemanager.RemoveChainResponse { + m := new(apemanager.RemoveChainResponse) + + if !empty { + m.SetBody(GenerateRemoveChainResponseBody(empty)) + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + } + + return m +} + +func GenerateListChainsRequestBody(empty bool) *apemanager.ListChainsRequestBody { + m := new(apemanager.ListChainsRequestBody) + + if !empty { + m.SetTarget(apetest.GenerateChainTarget(empty)) + } + + return m +} + +func GenerateListChainsRequest(empty bool) *apemanager.ListChainsRequest { + m := new(apemanager.ListChainsRequest) + + if !empty { + m.SetBody(GenerateListChainsRequestBody(empty)) + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + } + + return m +} + +func GenerateListChainsResponseBody(empty bool) *apemanager.ListChainsResponseBody { + m := new(apemanager.ListChainsResponseBody) + + if !empty { + m.SetChains(apetest.GenerateRawChains(empty, 10)) + } + + return m +} + +func GenerateListChainsResponse(empty bool) *apemanager.ListChainsResponse { + m := new(apemanager.ListChainsResponse) + + if !empty { + m.SetBody(GenerateListChainsResponseBody(empty)) + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + } + + return m +} diff --git a/apiv2/apemanager/types.go b/apiv2/apemanager/types.go new file mode 100644 index 0000000..74554aa --- /dev/null +++ b/apiv2/apemanager/types.go @@ -0,0 +1,226 @@ +package apemanager + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/ape" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/session" +) + +type AddChainRequest struct { + body *AddChainRequestBody + + session.RequestHeaders +} + +func (r *AddChainRequest) SetBody(body *AddChainRequestBody) { + r.body = body +} + +func (r *AddChainRequest) GetBody() *AddChainRequestBody { + if r == nil { + return nil + } + + return r.body +} + +type AddChainRequestBody struct { + target *ape.ChainTarget + + chain *ape.Chain +} + +func (rb *AddChainRequestBody) SetTarget(target *ape.ChainTarget) { + rb.target = target +} + +func (rb *AddChainRequestBody) GetTarget() *ape.ChainTarget { + if rb == nil { + return nil + } + + return rb.target +} + +func (rb *AddChainRequestBody) SetChain(chain *ape.Chain) { + rb.chain = chain +} + +func (rb *AddChainRequestBody) GetChain() *ape.Chain { + if rb == nil { + return nil + } + + return rb.chain +} + +type AddChainResponse struct { + body *AddChainResponseBody + + session.ResponseHeaders +} + +func (r *AddChainResponse) SetBody(body *AddChainResponseBody) { + r.body = body +} + +func (r *AddChainResponse) GetBody() *AddChainResponseBody { + if r == nil { + return nil + } + + return r.body +} + +type AddChainResponseBody struct { + chainID []byte +} + +func (rb *AddChainResponseBody) SetChainID(chainID []byte) { + rb.chainID = chainID +} + +func (rb *AddChainResponseBody) GetChainID() []byte { + if rb == nil { + return nil + } + + return rb.chainID +} + +type RemoveChainRequest struct { + body *RemoveChainRequestBody + + session.RequestHeaders +} + +func (r *RemoveChainRequest) SetBody(body *RemoveChainRequestBody) { + r.body = body +} + +func (r *RemoveChainRequest) GetBody() *RemoveChainRequestBody { + if r == nil { + return nil + } + + return r.body +} + +type RemoveChainRequestBody struct { + target *ape.ChainTarget + + chainID []byte +} + +func (rb *RemoveChainRequestBody) SetTarget(target *ape.ChainTarget) { + rb.target = target +} + +func (rb *RemoveChainRequestBody) GetTarget() *ape.ChainTarget { + if rb == nil { + return nil + } + + return rb.target +} + +func (rb *RemoveChainRequestBody) SetChainID(chainID []byte) { + rb.chainID = chainID +} + +func (rb *RemoveChainRequestBody) GetChainID() []byte { + if rb == nil { + return nil + } + + return rb.chainID +} + +type RemoveChainResponse struct { + body *RemoveChainResponseBody + + session.ResponseHeaders +} + +type RemoveChainResponseBody struct{} + +func (r *RemoveChainResponse) SetBody(body *RemoveChainResponseBody) { + r.body = body +} + +func (r *RemoveChainResponse) GetBody() *RemoveChainResponseBody { + if r == nil { + return nil + } + + return r.body +} + +type ListChainsRequest struct { + body *ListChainsRequestBody + + session.RequestHeaders +} + +func (r *ListChainsRequest) SetBody(body *ListChainsRequestBody) { + r.body = body +} + +func (r *ListChainsRequest) GetBody() *ListChainsRequestBody { + if r == nil { + return nil + } + + return r.body +} + +type ListChainsRequestBody struct { + target *ape.ChainTarget +} + +func (rb *ListChainsRequestBody) SetTarget(target *ape.ChainTarget) { + rb.target = target +} + +func (rb *ListChainsRequestBody) GetTarget() *ape.ChainTarget { + if rb == nil { + return nil + } + + return rb.target +} + +type ListChainsResponse struct { + body *ListChainsResponseBody + + session.ResponseHeaders +} + +func (r *ListChainsResponse) SetBody(body *ListChainsResponseBody) { + r.body = body +} + +func (r *ListChainsResponse) GetBody() *ListChainsResponseBody { + if r == nil { + return nil + } + + return r.body +} + +type ListChainsResponseBody struct { + chains []*ape.Chain + + session.RequestHeaders +} + +func (r *ListChainsResponseBody) SetChains(chains []*ape.Chain) { + r.chains = chains +} + +func (r *ListChainsResponseBody) GetChains() []*ape.Chain { + if r == nil { + return nil + } + + return r.chains +} diff --git a/apiv2/container/attributes.go b/apiv2/container/attributes.go new file mode 100644 index 0000000..288d048 --- /dev/null +++ b/apiv2/container/attributes.go @@ -0,0 +1,90 @@ +package container + +// SysAttributePrefix is a prefix of key to system attribute. +const SysAttributePrefix = "__SYSTEM__" + +const ( + // SysAttributeName is a string of human-friendly container name registered as the domain in NNS contract. + SysAttributeName = SysAttributePrefix + "NAME" + + // SysAttributeZone is a string of zone for container name. + SysAttributeZone = SysAttributePrefix + "ZONE" + + // SysAttributeHomomorphicHashing is a container's homomorphic hashing state. + SysAttributeHomomorphicHashing = SysAttributePrefix + "DISABLE_HOMOMORPHIC_HASHING" +) + +// SysAttributePrefixNeoFS is a prefix of key to system attribute. +// Deprecated: use SysAttributePrefix. +const SysAttributePrefixNeoFS = "__NEOFS__" + +const ( + // SysAttributeNameNeoFS is a string of human-friendly container name registered as the domain in NNS contract. + // Deprecated: use SysAttributeName. + SysAttributeNameNeoFS = SysAttributePrefixNeoFS + "NAME" + + // SysAttributeZoneNeoFS is a string of zone for container name. + // Deprecated: use SysAttributeZone. + SysAttributeZoneNeoFS = SysAttributePrefixNeoFS + "ZONE" + + // SysAttributeHomomorphicHashingNeoFS is a container's homomorphic hashing state. + // Deprecated: use SysAttributeHomomorphicHashing. + SysAttributeHomomorphicHashingNeoFS = SysAttributePrefixNeoFS + "DISABLE_HOMOMORPHIC_HASHING" +) + +// SysAttributeZoneDefault is a default value for SysAttributeZone attribute. +const SysAttributeZoneDefault = "container" + +const disabledHomomorphicHashingValue = "true" + +// HomomorphicHashingState returns container's homomorphic +// hashing state: +// - true if hashing is enabled; +// - false if hashing is disabled. +// +// All container's attributes must be unique, otherwise behavior +// is undefined. +// +// See also SetHomomorphicHashingState. +func (c Container) HomomorphicHashingState() bool { + for i := range c.attr { + if c.attr[i].GetKey() == SysAttributeHomomorphicHashing || c.attr[i].GetKey() == SysAttributeHomomorphicHashingNeoFS { + return c.attr[i].GetValue() != disabledHomomorphicHashingValue + } + } + + return true +} + +// SetHomomorphicHashingState sets homomorphic hashing state for +// container. +// +// All container's attributes must be unique, otherwise behavior +// is undefined. +// +// See also HomomorphicHashingState. +func (c *Container) SetHomomorphicHashingState(enable bool) { + for i := range c.attr { + if c.attr[i].GetKey() == SysAttributeHomomorphicHashing || c.attr[i].GetKey() == SysAttributeHomomorphicHashingNeoFS { + if enable { + // approach without allocation/waste + // coping works since the attributes + // order is not important + c.attr[i] = c.attr[len(c.attr)-1] + c.attr = c.attr[:len(c.attr)-1] + } else { + c.attr[i].SetValue(disabledHomomorphicHashingValue) + } + + return + } + } + + if !enable { + attr := Attribute{} + attr.SetKey(SysAttributeHomomorphicHashing) + attr.SetValue(disabledHomomorphicHashingValue) + + c.attr = append(c.attr, attr) + } +} diff --git a/apiv2/container/attributes_test.go b/apiv2/container/attributes_test.go new file mode 100644 index 0000000..3599b0f --- /dev/null +++ b/apiv2/container/attributes_test.go @@ -0,0 +1,59 @@ +package container_test + +import ( + "testing" + + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container" + containertest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container/test" + "github.com/stretchr/testify/require" +) + +func TestContainer_HomomorphicHashingDisabled(t *testing.T) { + cnr := containertest.GenerateContainer(false) + + t.Run("defaults", func(t *testing.T) { + require.True(t, cnr.HomomorphicHashingState()) + }) + + t.Run("disabled", func(t *testing.T) { + attr := container.Attribute{} + attr.SetKey(container.SysAttributeHomomorphicHashing) + attr.SetValue("NOT_true") + + cnr.SetAttributes(append(cnr.GetAttributes(), attr)) + require.True(t, cnr.HomomorphicHashingState()) + + attr.SetValue("true") + + cnr.SetAttributes([]container.Attribute{attr}) + require.False(t, cnr.HomomorphicHashingState()) + }) +} + +func TestContainer_SetHomomorphicHashingState(t *testing.T) { + cnr := containertest.GenerateContainer(false) + attrs := cnr.GetAttributes() + attrLen := len(attrs) + + cnr.SetHomomorphicHashingState(true) + + // enabling hashing should not add any new attributes + require.Equal(t, attrLen, len(cnr.GetAttributes())) + require.True(t, cnr.HomomorphicHashingState()) + + cnr.SetHomomorphicHashingState(false) + + // disabling hashing should add exactly one attribute + require.Equal(t, attrLen+1, len(cnr.GetAttributes())) + require.False(t, cnr.HomomorphicHashingState()) + + cnr.SetHomomorphicHashingState(true) + + // enabling hashing should remove 1 attribute if + // hashing was disabled before + require.Equal(t, attrLen, len(cnr.GetAttributes())) + require.True(t, cnr.HomomorphicHashingState()) + + // hashing operations should not change any other attributes + require.ElementsMatch(t, attrs, cnr.GetAttributes()) +} diff --git a/apiv2/container/convert.go b/apiv2/container/convert.go new file mode 100644 index 0000000..6f450fb --- /dev/null +++ b/apiv2/container/convert.go @@ -0,0 +1,764 @@ +package container + +import ( + container "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/netmap" + netmapGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/netmap/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs" + refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/session" + sessionGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/session/grpc" +) + +func (a *Attribute) ToGRPCMessage() grpc.Message { + var m *container.Container_Attribute + + if a != nil { + m = new(container.Container_Attribute) + + m.SetKey(a.key) + m.SetValue(a.val) + } + + return m +} + +func (a *Attribute) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.Container_Attribute) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + a.key = v.GetKey() + a.val = v.GetValue() + + return nil +} + +func AttributesToGRPC(xs []Attribute) (res []container.Container_Attribute) { + if xs != nil { + res = make([]container.Container_Attribute, 0, len(xs)) + + for i := range xs { + res = append(res, *xs[i].ToGRPCMessage().(*container.Container_Attribute)) + } + } + + return +} + +func AttributesFromGRPC(xs []container.Container_Attribute) (res []Attribute, err error) { + if xs != nil { + res = make([]Attribute, len(xs)) + + for i := range xs { + err = res[i].FromGRPCMessage(&xs[i]) + if err != nil { + return + } + } + } + + return +} + +func (c *Container) ToGRPCMessage() grpc.Message { + var m *container.Container + + if c != nil { + m = new(container.Container) + + m.SetVersion(c.version.ToGRPCMessage().(*refsGRPC.Version)) + m.SetOwnerId(c.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) + m.SetPlacementPolicy(c.policy.ToGRPCMessage().(*netmapGRPC.PlacementPolicy)) + m.SetAttributes(AttributesToGRPC(c.attr)) + m.SetBasicAcl(c.basicACL) + m.SetNonce(c.nonce) + } + + return m +} + +func (c *Container) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.Container) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + version := v.GetVersion() + if version == nil { + c.version = nil + } else { + if c.version == nil { + c.version = new(refs.Version) + } + + err = c.version.FromGRPCMessage(version) + if err != nil { + return err + } + } + + ownerID := v.GetOwnerId() + if ownerID == nil { + c.ownerID = nil + } else { + if c.ownerID == nil { + c.ownerID = new(refs.OwnerID) + } + + err = c.ownerID.FromGRPCMessage(ownerID) + if err != nil { + return err + } + } + + policy := v.GetPlacementPolicy() + if policy == nil { + c.policy = nil + } else { + if c.policy == nil { + c.policy = new(netmap.PlacementPolicy) + } + + err = c.policy.FromGRPCMessage(policy) + if err != nil { + return err + } + } + + c.attr, err = AttributesFromGRPC(v.GetAttributes()) + if err != nil { + return err + } + + c.basicACL = v.GetBasicAcl() + c.nonce = v.GetNonce() + + return nil +} + +func toSignatureRFC6979(s *refs.Signature) *refsGRPC.SignatureRFC6979 { + var res *refsGRPC.SignatureRFC6979 + + if s != nil { + res = new(refsGRPC.SignatureRFC6979) + res.SetKey(s.GetKey()) + res.SetSign(s.GetSign()) + } + + return res +} + +func (r *PutRequestBody) ToGRPCMessage() grpc.Message { + var m *container.PutRequest_Body + + if r != nil { + m = new(container.PutRequest_Body) + + m.SetContainer(r.cnr.ToGRPCMessage().(*container.Container)) + m.SetSignature(toSignatureRFC6979(r.sig)) + } + + return m +} + +func (r *PutRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.PutRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + cnr := v.GetContainer() + if cnr == nil { + r.cnr = nil + } else { + if r.cnr == nil { + r.cnr = new(Container) + } + + err = r.cnr.FromGRPCMessage(cnr) + if err != nil { + return err + } + } + + sig := v.GetSignature() + if sig == nil { + r.sig = nil + } else { + if r.sig == nil { + r.sig = new(refs.Signature) + } + + r.sig.SetKey(sig.GetKey()) + r.sig.SetSign(sig.GetSign()) + } + + return err +} + +func (r *PutRequest) ToGRPCMessage() grpc.Message { + var m *container.PutRequest + + if r != nil { + m = new(container.PutRequest) + + m.SetBody(r.body.ToGRPCMessage().(*container.PutRequest_Body)) + r.RequestHeaders.ToMessage(m) + } + + return m +} + +func (r *PutRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.PutRequest) + 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(PutRequestBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.RequestHeaders.FromMessage(v) +} + +func (r *PutResponseBody) ToGRPCMessage() grpc.Message { + var m *container.PutResponse_Body + + if r != nil { + m = new(container.PutResponse_Body) + + m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID)) + } + + return m +} + +func (r *PutResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.PutResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + cid := v.GetContainerId() + if cid == nil { + r.cid = nil + } else { + if r.cid == nil { + r.cid = new(refs.ContainerID) + } + + err = r.cid.FromGRPCMessage(cid) + } + + return err +} + +func (r *PutResponse) ToGRPCMessage() grpc.Message { + var m *container.PutResponse + + if r != nil { + m = new(container.PutResponse) + + m.SetBody(r.body.ToGRPCMessage().(*container.PutResponse_Body)) + r.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (r *PutResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.PutResponse) + 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(PutResponseBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.ResponseHeaders.FromMessage(v) +} + +func (r *GetRequestBody) ToGRPCMessage() grpc.Message { + var m *container.GetRequest_Body + + if r != nil { + m = new(container.GetRequest_Body) + + m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID)) + } + + return m +} + +func (r *GetRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.GetRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + cid := v.GetContainerId() + if cid == nil { + r.cid = nil + } else { + if r.cid == nil { + r.cid = new(refs.ContainerID) + } + + err = r.cid.FromGRPCMessage(cid) + } + + return err +} + +func (r *GetRequest) ToGRPCMessage() grpc.Message { + var m *container.GetRequest + + if r != nil { + m = new(container.GetRequest) + + m.SetBody(r.body.ToGRPCMessage().(*container.GetRequest_Body)) + r.RequestHeaders.ToMessage(m) + } + + return m +} + +func (r *GetRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.GetRequest) + 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(GetRequestBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.RequestHeaders.FromMessage(v) +} + +func (r *GetResponseBody) ToGRPCMessage() grpc.Message { + var m *container.GetResponse_Body + + if r != nil { + m = new(container.GetResponse_Body) + + m.SetContainer(r.cnr.ToGRPCMessage().(*container.Container)) + m.SetSessionToken(r.token.ToGRPCMessage().(*sessionGRPC.SessionToken)) + m.SetSignature(toSignatureRFC6979(r.sig)) + } + + return m +} + +func (r *GetResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.GetResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + cnr := v.GetContainer() + if cnr == nil { + r.cnr = nil + } else { + if r.cnr == nil { + r.cnr = new(Container) + } + + err = r.cnr.FromGRPCMessage(cnr) + } + + sig := v.GetSignature() + if sig == nil { + r.sig = nil + } else { + if r.sig == nil { + r.sig = new(refs.Signature) + } + + r.sig.SetKey(sig.GetKey()) + r.sig.SetSign(sig.GetSign()) + } + + token := v.GetSessionToken() + if token == nil { + r.token = nil + } else { + if r.token == nil { + r.token = new(session.Token) + } + + err = r.token.FromGRPCMessage(token) + } + + return err +} + +func (r *GetResponse) ToGRPCMessage() grpc.Message { + var m *container.GetResponse + + if r != nil { + m = new(container.GetResponse) + + m.SetBody(r.body.ToGRPCMessage().(*container.GetResponse_Body)) + r.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (r *GetResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.GetResponse) + 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(GetResponseBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.ResponseHeaders.FromMessage(v) +} + +func (r *DeleteRequestBody) ToGRPCMessage() grpc.Message { + var m *container.DeleteRequest_Body + + if r != nil { + m = new(container.DeleteRequest_Body) + + m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID)) + m.SetSignature(toSignatureRFC6979(r.sig)) + } + + return m +} + +func (r *DeleteRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.DeleteRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + cid := v.GetContainerId() + if cid == nil { + r.cid = nil + } else { + if r.cid == nil { + r.cid = new(refs.ContainerID) + } + + err = r.cid.FromGRPCMessage(cid) + if err != nil { + return err + } + } + + sig := v.GetSignature() + if sig == nil { + r.sig = nil + } else { + if r.sig == nil { + r.sig = new(refs.Signature) + } + + r.sig.SetKey(sig.GetKey()) + r.sig.SetSign(sig.GetSign()) + } + + return err +} + +func (r *DeleteRequest) ToGRPCMessage() grpc.Message { + var m *container.DeleteRequest + + if r != nil { + m = new(container.DeleteRequest) + + m.SetBody(r.body.ToGRPCMessage().(*container.DeleteRequest_Body)) + r.RequestHeaders.ToMessage(m) + } + + return m +} + +func (r *DeleteRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.DeleteRequest) + 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(DeleteRequestBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.RequestHeaders.FromMessage(v) +} + +func (r *DeleteResponseBody) ToGRPCMessage() grpc.Message { + var m *container.DeleteResponse_Body + + if r != nil { + m = new(container.DeleteResponse_Body) + } + + return m +} + +func (r *DeleteResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.DeleteResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + return nil +} + +func (r *DeleteResponse) ToGRPCMessage() grpc.Message { + var m *container.DeleteResponse + + if r != nil { + m = new(container.DeleteResponse) + + m.SetBody(r.body.ToGRPCMessage().(*container.DeleteResponse_Body)) + r.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (r *DeleteResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.DeleteResponse) + 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(DeleteResponseBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.ResponseHeaders.FromMessage(v) +} + +func (r *ListRequestBody) ToGRPCMessage() grpc.Message { + var m *container.ListRequest_Body + + if r != nil { + m = new(container.ListRequest_Body) + + m.SetOwnerId(r.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) + } + + return m +} + +func (r *ListRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListRequest_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 *ListRequest) ToGRPCMessage() grpc.Message { + var m *container.ListRequest + + if r != nil { + m = new(container.ListRequest) + + m.SetBody(r.body.ToGRPCMessage().(*container.ListRequest_Body)) + r.RequestHeaders.ToMessage(m) + } + + return m +} + +func (r *ListRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListRequest) + 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(ListRequestBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.RequestHeaders.FromMessage(v) +} + +func (r *ListResponseBody) ToGRPCMessage() grpc.Message { + var m *container.ListResponse_Body + + if r != nil { + m = new(container.ListResponse_Body) + + m.SetContainerIds(refs.ContainerIDsToGRPCMessage(r.cidList)) + } + + return m +} + +func (r *ListResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + r.cidList, err = refs.ContainerIDsFromGRPCMessage(v.GetContainerIds()) + + return err +} + +func (r *ListResponse) ToGRPCMessage() grpc.Message { + var m *container.ListResponse + + if r != nil { + m = new(container.ListResponse) + + m.SetBody(r.body.ToGRPCMessage().(*container.ListResponse_Body)) + r.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (r *ListResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListResponse) + 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(ListResponseBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.ResponseHeaders.FromMessage(v) +} diff --git a/apiv2/container/grpc/service_frostfs.pb.go b/apiv2/container/grpc/service_frostfs.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..1fa1b115b3a3a7a042229e137a35cf06b93bdb45 GIT binary patch literal 74362 zcmeHQZIjzJlK!mu706U2k-QU4oK)S_&X%|894B{k RNYcq%UM#8tK|mXojG z+E?$EU(K>*Ud-~bc=3~X_0t>i{fqNA lIGrq~N&4;-e;ywVW{W}`!~cVSzRRvA;`m)sj7{}PI$NH;$yV`q^W|##GP*p~ zcfQJ}A3%@O=qkDX<}{0E`6){4N}g_1OCINWvP?}ySIgymqk2|FGCxIW&_-JA9<`v+ zp&Dbfd)9Pn>cJ|b{LX6keswvXEElK$NG8QHOQIj+B1 ALpqmf@N>Aq-ZLv${Zh!j*g1Et62QJDqhF`w~F)P_vg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lR<5}jjsH27Uq e)ftVh5?A4jv^B<9Puujw7A`ku(IIIHysl4DT)CbTu4}FN)}LE@20l z }Sb}+Q&7S%LOE Q%@4A zA_*y9wZW{6^DPwRoE;GQ^OiuVLt+UjgN2cMU^rQ1rzgnp5m3StQa#xcQOL}BfZE9* zhL}RE6^+*EF |{~txx*E|3K literal 0 HcmV?d00001 diff --git a/apiv2/container/grpc/service_frostfs_fuzz.go b/apiv2/container/grpc/service_frostfs_fuzz.go new file mode 100644 index 0000000..7e6d6e6 --- /dev/null +++ b/apiv2/container/grpc/service_frostfs_fuzz.go @@ -0,0 +1,159 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package container + +func DoFuzzProtoPutRequest(data []byte) int { + msg := new(PutRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONPutRequest(data []byte) int { + msg := new(PutRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoPutResponse(data []byte) int { + msg := new(PutResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONPutResponse(data []byte) int { + msg := new(PutResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoDeleteRequest(data []byte) int { + msg := new(DeleteRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONDeleteRequest(data []byte) int { + msg := new(DeleteRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoDeleteResponse(data []byte) int { + msg := new(DeleteResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONDeleteResponse(data []byte) int { + msg := new(DeleteResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoGetRequest(data []byte) int { + msg := new(GetRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONGetRequest(data []byte) int { + msg := new(GetRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoGetResponse(data []byte) int { + msg := new(GetResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONGetResponse(data []byte) int { + msg := new(GetResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoListRequest(data []byte) int { + msg := new(ListRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONListRequest(data []byte) int { + msg := new(ListRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoListResponse(data []byte) int { + msg := new(ListResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONListResponse(data []byte) int { + msg := new(ListResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/container/grpc/service_frostfs_test.go b/apiv2/container/grpc/service_frostfs_test.go new file mode 100644 index 0000000..804b89c --- /dev/null +++ b/apiv2/container/grpc/service_frostfs_test.go @@ -0,0 +1,91 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package container + +import ( + testing "testing" +) + +func FuzzProtoPutRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoPutRequest(data) + }) +} +func FuzzJSONPutRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONPutRequest(data) + }) +} +func FuzzProtoPutResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoPutResponse(data) + }) +} +func FuzzJSONPutResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONPutResponse(data) + }) +} +func FuzzProtoDeleteRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoDeleteRequest(data) + }) +} +func FuzzJSONDeleteRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONDeleteRequest(data) + }) +} +func FuzzProtoDeleteResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoDeleteResponse(data) + }) +} +func FuzzJSONDeleteResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONDeleteResponse(data) + }) +} +func FuzzProtoGetRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoGetRequest(data) + }) +} +func FuzzJSONGetRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONGetRequest(data) + }) +} +func FuzzProtoGetResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoGetResponse(data) + }) +} +func FuzzJSONGetResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONGetResponse(data) + }) +} +func FuzzProtoListRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoListRequest(data) + }) +} +func FuzzJSONListRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONListRequest(data) + }) +} +func FuzzProtoListResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoListResponse(data) + }) +} +func FuzzJSONListResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONListResponse(data) + }) +} diff --git a/apiv2/container/grpc/service_grpc.pb.go b/apiv2/container/grpc/service_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..abb0fef28efa7bc1a88d27d920de117d4d04fafa GIT binary patch literal 11817 zcmeHNZExE+68;?h3Z4(>+JPhYvb!kYMQ{ilch|VBUF7Ay+#MW6qHLj(=oKkvgChU^ zo+0&SSx(h+eaS9Tv}tUT!{N-snP*5225cle&K5l8iKDp3?jG1G5lXlx`0ivOP8P|^ zwb{jtO=s6^d@;GUt-*k;c_IT5%OQO@X&A!Rf3v^0-&UJh_0Rf8`}CcCO6^jliOYw~ z6|r&xC^Dcq2a+f2z~#19$Ff$A`^j1GvX^BA(MlwWb*&>B%70g^ll{`Mjz|XUEQDBu z++K*#i5Ip=7Fsr%T`XJfY9HuU^peU^>F#c(xnuP#TF3P=kPLqv=oqbnke{d^;>?j) ziGs115{$<(O*m6aN8txLmzMW2g2doU8t LQM_753JLt-|X8ti%^Y>{Oe&A{;ys3lL;?EiD3}P;9U)t+an>?buYS)JkFdR0n ze?7n8Ay>RExV2O>yh-rSd@pq|yh-Y>fou@lT3s5RBdBhQQ5f)8yP6Q-nos8+C(MT% z>z!G?VE`h+(R=ifJaS?cxBz7$(%56J`kkc`prqeJApxKPk3GVXR0($?`VEkgeYOg@ zgPsZZc|y=#Dz%cs!C>`if&FBAd_8F1U4y?X=kClC?q7}mP&Bru{QgQ$U|Z^8#kaK2 zmx_Iy_>RljXX^-yxCKUTSrD(qCxH33So1BDk%PVO0$qvYs_)RKyG9y{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*O1s5Etessm8snR_XL+e& z&fGTSbYJw5eKm@n0-K5RFBETiR(np!869%V9td@r7fNK(vlw6%r^U|zyy}t-_BI{y z4dI7${X(% !84aQAfsqA&@H;Yw%Vv{x<|0ajX}Lwko-N9=MSP2gaMW{|f Z3e1p=W9$#)}9_^u)jQ7%u=LSNd6= ze(k9R*LY~3h&MgjBLWYKjw%5%5+PR@3OOKzk?_o$v@T!c1s4%}5cJhU&ssa%uLU<& zls^GA6$C8?d@JL*l)i?n)8;{E2Wc*2yVrQ*H^c#8-5weH>!Jehq4x* p{+~pFt+14%7J%Xlp*^4P{Y$}sPJh07lc=BVgLXD literal 0 HcmV?d00001 diff --git a/apiv2/container/grpc/types_frostfs.pb.go b/apiv2/container/grpc/types_frostfs.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..f562e15c94ed08dba9ce1d426c58a4d5bfee83d6 GIT binary patch literal 11447 zcmeHN>rWg<692sWSF~4(J 7pdg_SCDZs()Qoo!LyhPv=sc$wX#eA?M=sS}d}(Nd4zndw!Na53)2b zg4`8*U&Q{Guj0er$FJ^qyzu-B?@S6mO$sjr_jnw}i!>{QGamh(r-_)z#82m8ayFx% zlkq5s3o*gJ@SkVd!ru~;v#@ZD{4fd9+1IR;@1wMwfAUUe`pfftegQ*f-XdIX&k|Y0 z-eN`qw44Wt$z+flA&WGP9wekJ!e~a^u!NoV2c(eCA;$RZ4@#ODIV94{uPf`$%Tw1+ z 0AX%>5h3qHk4ZZ9*L zi_5S$SA1S9MG(qpF4(!bIQN#a`g9s5UUtpm-EmMRzHqKYuUBi9IaA@VL19u%Da;`m zw!16fc=|a~mWvnT(d~G|lz-V(R=bCs3$#CHYg1gg$PmQpPMU3^;Zy;Y7E8pGBJh@u z5T^z?1h^H+SSE$?+FiK=yJZ%5z8u )EF? zv@A4UB^zs){m;WM`|T6lx^>q+wi*&iB;8F4q4}KYqk2hMtm_;1XD)MYu(>M(rXNsP zG56C;WVjB}rTeZ70NwZ_jOOnE`nfaR6qo884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D%Vy|0!cdo SLKR&}wq1RwnuG?614`&!0XQJvyiyfnHMJSs#i<@Z zuAxDfdyQewpnT7cDc8_|M 5f=1 zZR3sRgk%ivanT&74s5jBllQ!vDYXq-9_78L){FnBSE8B;7D4|1Hl$vY?)5gLv9J52 z( kqez6AgxU>DJX }pnJp;d|3rds=4E9hD~F@V?=sA{^pz yMHxDD8TyzwEL>F-hGm%oNGW?Cw@=HjK0(nB6#)SgUqI=*;&~^Eny>aJhYrrZ>+2 E0xk6(s{jB1 literal 0 HcmV?d00001 diff --git a/apiv2/container/grpc/types_frostfs_fuzz.go b/apiv2/container/grpc/types_frostfs_fuzz.go new file mode 100644 index 0000000..5551978 --- /dev/null +++ b/apiv2/container/grpc/types_frostfs_fuzz.go @@ -0,0 +1,26 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package container + +func DoFuzzProtoContainer(data []byte) int { + msg := new(Container) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONContainer(data []byte) int { + msg := new(Container) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/container/grpc/types_frostfs_test.go b/apiv2/container/grpc/types_frostfs_test.go new file mode 100644 index 0000000..64d840e --- /dev/null +++ b/apiv2/container/grpc/types_frostfs_test.go @@ -0,0 +1,21 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package container + +import ( + testing "testing" +) + +func FuzzProtoContainer(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoContainer(data) + }) +} +func FuzzJSONContainer(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONContainer(data) + }) +} diff --git a/apiv2/container/json.go b/apiv2/container/json.go new file mode 100644 index 0000000..91c4c08 --- /dev/null +++ b/apiv2/container/json.go @@ -0,0 +1,22 @@ +package container + +import ( + container "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" +) + +func (a *Attribute) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(a) +} + +func (a *Attribute) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(a, data, new(container.Container_Attribute)) +} + +func (c *Container) MarshalJSON() ([]byte, error) { + return message.MarshalJSON(c) +} + +func (c *Container) UnmarshalJSON(data []byte) error { + return message.UnmarshalJSON(c, data, new(container.Container)) +} diff --git a/apiv2/container/marshal.go b/apiv2/container/marshal.go new file mode 100644 index 0000000..ae38bc5 --- /dev/null +++ b/apiv2/container/marshal.go @@ -0,0 +1,345 @@ +package container + +import ( + container "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + protoutil "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/util/proto" +) + +const ( + attributeKeyField = 1 + attributeValueField = 2 + + containerVersionField = 1 + containerOwnerField = 2 + containerNonceField = 3 + containerBasicACLField = 4 + containerAttributesField = 5 + containerPlacementField = 6 + + putReqBodyContainerField = 1 + putReqBodySignatureField = 2 + + putRespBodyIDField = 1 + + deleteReqBodyIDField = 1 + deleteReqBodySignatureField = 2 + + getReqBodyIDField = 1 + + getRespBodyContainerField = 1 + getRespBodySignatureField = 2 + getRespBodyTokenField = 3 + + listReqBodyOwnerField = 1 + + listRespBodyIDsField = 1 +) + +func (a *Attribute) StableMarshal(buf []byte) []byte { + if a == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, a.StableSize()) + } + + var offset int + + offset += protoutil.StringMarshal(attributeKeyField, buf[offset:], a.key) + protoutil.StringMarshal(attributeValueField, buf[offset:], a.val) + + return buf +} + +func (a *Attribute) StableSize() (size int) { + if a == nil { + return 0 + } + + size += protoutil.StringSize(attributeKeyField, a.key) + size += protoutil.StringSize(attributeValueField, a.val) + + return size +} + +func (a *Attribute) Unmarshal(data []byte) error { + return message.Unmarshal(a, data, new(container.Container_Attribute)) +} + +func (c *Container) StableMarshal(buf []byte) []byte { + if c == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, c.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(containerVersionField, buf[offset:], c.version) + offset += protoutil.NestedStructureMarshal(containerOwnerField, buf[offset:], c.ownerID) + offset += protoutil.BytesMarshal(containerNonceField, buf[offset:], c.nonce) + offset += protoutil.UInt32Marshal(containerBasicACLField, buf[offset:], c.basicACL) + + for i := range c.attr { + offset += protoutil.NestedStructureMarshal(containerAttributesField, buf[offset:], &c.attr[i]) + } + + protoutil.NestedStructureMarshal(containerPlacementField, buf[offset:], c.policy) + + return buf +} + +func (c *Container) StableSize() (size int) { + if c == nil { + return 0 + } + + size += protoutil.NestedStructureSize(containerVersionField, c.version) + size += protoutil.NestedStructureSize(containerOwnerField, c.ownerID) + size += protoutil.BytesSize(containerNonceField, c.nonce) + size += protoutil.UInt32Size(containerBasicACLField, c.basicACL) + + for i := range c.attr { + size += protoutil.NestedStructureSize(containerAttributesField, &c.attr[i]) + } + + size += protoutil.NestedStructureSize(containerPlacementField, c.policy) + + return size +} + +func (c *Container) Unmarshal(data []byte) error { + return message.Unmarshal(c, data, new(container.Container)) +} + +func (r *PutRequestBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(putReqBodyContainerField, buf[offset:], r.cnr) + protoutil.NestedStructureMarshal(putReqBodySignatureField, buf[offset:], r.sig) + + return buf +} + +func (r *PutRequestBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(putReqBodyContainerField, r.cnr) + size += protoutil.NestedStructureSize(putReqBodySignatureField, r.sig) + + return size +} + +func (r *PutRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.PutRequest_Body)) +} + +func (r *PutResponseBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + protoutil.NestedStructureMarshal(putRespBodyIDField, buf, r.cid) + + return buf +} + +func (r *PutResponseBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(putRespBodyIDField, r.cid) + + return size +} + +func (r *PutResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.PutResponse_Body)) +} + +func (r *DeleteRequestBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(deleteReqBodyIDField, buf[offset:], r.cid) + protoutil.NestedStructureMarshal(deleteReqBodySignatureField, buf[offset:], r.sig) + + return buf +} + +func (r *DeleteRequestBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(deleteReqBodyIDField, r.cid) + size += protoutil.NestedStructureSize(deleteReqBodySignatureField, r.sig) + + return size +} + +func (r *DeleteRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.DeleteRequest_Body)) +} + +func (r *DeleteResponseBody) StableMarshal(_ []byte) []byte { + return nil +} + +func (r *DeleteResponseBody) StableSize() (size int) { + return 0 +} + +func (r *DeleteResponseBody) Unmarshal([]byte) error { + return nil +} + +func (r *GetRequestBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + protoutil.NestedStructureMarshal(getReqBodyIDField, buf, r.cid) + + return buf +} + +func (r *GetRequestBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(getReqBodyIDField, r.cid) + + return size +} + +func (r *GetRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.GetRequest_Body)) +} + +func (r *GetResponseBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + var offset int + + offset += protoutil.NestedStructureMarshal(getRespBodyContainerField, buf, r.cnr) + offset += protoutil.NestedStructureMarshal(getRespBodySignatureField, buf[offset:], r.sig) + protoutil.NestedStructureMarshal(getRespBodyTokenField, buf[offset:], r.token) + + return buf +} + +func (r *GetResponseBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(getRespBodyContainerField, r.cnr) + size += protoutil.NestedStructureSize(getRespBodySignatureField, r.sig) + size += protoutil.NestedStructureSize(getRespBodyTokenField, r.token) + + return size +} + +func (r *GetResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.GetResponse_Body)) +} + +func (r *ListRequestBody) 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 *ListRequestBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(listReqBodyOwnerField, r.ownerID) + + return size +} + +func (r *ListRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.ListRequest_Body)) +} + +func (r *ListResponseBody) 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 *ListResponseBody) StableSize() (size int) { + if r == nil { + return 0 + } + + for i := range r.cidList { + size += protoutil.NestedStructureSize(listRespBodyIDsField, &r.cidList[i]) + } + + return size +} + +func (r *ListResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.ListResponse_Body)) +} diff --git a/apiv2/container/message_test.go b/apiv2/container/message_test.go new file mode 100644 index 0000000..2df5bdb --- /dev/null +++ b/apiv2/container/message_test.go @@ -0,0 +1,36 @@ +package container_test + +import ( + "testing" + + containertest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container/test" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" + messagetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message/test" +) + +func TestMessageConvert(t *testing.T) { + messagetest.TestRPCMessage(t, + func(empty bool) message.Message { return containertest.GenerateAttribute(empty) }, + func(empty bool) message.Message { return containertest.GenerateContainer(empty) }, + func(empty bool) message.Message { return containertest.GeneratePutRequestBody(empty) }, + func(empty bool) message.Message { return containertest.GeneratePutRequest(empty) }, + func(empty bool) message.Message { return containertest.GeneratePutResponseBody(empty) }, + func(empty bool) message.Message { return containertest.GeneratePutResponse(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetRequestBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetRequest(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetResponseBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetResponse(empty) }, + func(empty bool) message.Message { return containertest.GenerateDeleteRequestBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateDeleteRequest(empty) }, + func(empty bool) message.Message { return containertest.GenerateDeleteResponseBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateDeleteResponse(empty) }, + func(empty bool) message.Message { return containertest.GenerateListRequestBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateListRequest(empty) }, + func(empty bool) message.Message { return containertest.GenerateListResponseBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateListResponse(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetRequestBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetRequest(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetResponseBody(empty) }, + func(empty bool) message.Message { return containertest.GenerateGetResponse(empty) }, + ) +} diff --git a/apiv2/container/status.go b/apiv2/container/status.go new file mode 100644 index 0000000..94046f7 --- /dev/null +++ b/apiv2/container/status.go @@ -0,0 +1,33 @@ +package container + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status" + statusgrpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status/grpc" +) + +// LocalizeFailStatus checks if passed global status.Code is related to container failure and: +// +// then localizes the code and returns true, +// else leaves the code unchanged and returns false. +// +// Arg must not be nil. +func LocalizeFailStatus(c *status.Code) bool { + return status.LocalizeIfInSection(c, uint32(statusgrpc.Section_SECTION_CONTAINER)) +} + +// GlobalizeFail globalizes local code of container failure. +// +// Arg must not be nil. +func GlobalizeFail(c *status.Code) { + c.GlobalizeSection(uint32(statusgrpc.Section_SECTION_CONTAINER)) +} + +const ( + // StatusNotFound is a local status.Code value for + // CONTAINER_NOT_FOUND container failure. + StatusNotFound status.Code = iota + + // StatusEACLNotFound is a local status.Code value for + // EACL_NOT_FOUND failure. + StatusEACLNotFound +) diff --git a/apiv2/container/status_test.go b/apiv2/container/status_test.go new file mode 100644 index 0000000..f3f2483 --- /dev/null +++ b/apiv2/container/status_test.go @@ -0,0 +1,15 @@ +package container_test + +import ( + "testing" + + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container" + statustest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/status/test" +) + +func TestStatusCodes(t *testing.T) { + statustest.TestCodes(t, container.LocalizeFailStatus, container.GlobalizeFail, + container.StatusNotFound, 3072, + container.StatusEACLNotFound, 3073, + ) +} diff --git a/apiv2/container/test/generate.go b/apiv2/container/test/generate.go new file mode 100644 index 0000000..143aca3 --- /dev/null +++ b/apiv2/container/test/generate.go @@ -0,0 +1,240 @@ +package containertest + +import ( + "crypto/rand" + + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/container" + netmaptest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/netmap/test" + refstest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs/test" + sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/session/test" +) + +func GenerateAttribute(empty bool) *container.Attribute { + m := new(container.Attribute) + + if !empty { + m.SetKey("key") + m.SetValue("val") + } + + return m +} + +func GenerateAttributes(empty bool) []container.Attribute { + var res []container.Attribute + + if !empty { + res = append(res, + *GenerateAttribute(false), + *GenerateAttribute(false), + ) + } + + return res +} + +func GenerateContainer(empty bool) *container.Container { + m := new(container.Container) + + if !empty { + nonce := make([]byte, 16) + _, _ = rand.Read(nonce) + + m.SetBasicACL(12) + m.SetNonce(nonce) + m.SetOwnerID(refstest.GenerateOwnerID(false)) + m.SetAttributes(GenerateAttributes(false)) + m.SetPlacementPolicy(netmaptest.GeneratePlacementPolicy(false)) + } + + m.SetVersion(refstest.GenerateVersion(empty)) + + return m +} + +func GeneratePutRequestBody(empty bool) *container.PutRequestBody { + m := new(container.PutRequestBody) + + if !empty { + m.SetContainer(GenerateContainer(false)) + } + + m.SetSignature(refstest.GenerateSignature(empty)) + + return m +} + +func GeneratePutRequest(empty bool) *container.PutRequest { + m := new(container.PutRequest) + + if !empty { + m.SetBody(GeneratePutRequestBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + + return m +} + +func GeneratePutResponseBody(empty bool) *container.PutResponseBody { + m := new(container.PutResponseBody) + + if !empty { + m.SetContainerID(refstest.GenerateContainerID(false)) + } + + return m +} + +func GeneratePutResponse(empty bool) *container.PutResponse { + m := new(container.PutResponse) + + if !empty { + m.SetBody(GeneratePutResponseBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + + return m +} + +func GenerateGetRequestBody(empty bool) *container.GetRequestBody { + m := new(container.GetRequestBody) + + if !empty { + m.SetContainerID(refstest.GenerateContainerID(false)) + } + + return m +} + +func GenerateGetRequest(empty bool) *container.GetRequest { + m := new(container.GetRequest) + + if !empty { + m.SetBody(GenerateGetRequestBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + + return m +} + +func GenerateGetResponseBody(empty bool) *container.GetResponseBody { + m := new(container.GetResponseBody) + + if !empty { + m.SetContainer(GenerateContainer(false)) + } + + m.SetSignature(refstest.GenerateSignature(empty)) + m.SetSessionToken(sessiontest.GenerateSessionToken(empty)) + + return m +} + +func GenerateGetResponse(empty bool) *container.GetResponse { + m := new(container.GetResponse) + + if !empty { + m.SetBody(GenerateGetResponseBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + + return m +} + +func GenerateDeleteRequestBody(empty bool) *container.DeleteRequestBody { + m := new(container.DeleteRequestBody) + + if !empty { + m.SetContainerID(refstest.GenerateContainerID(false)) + } + + m.SetSignature(refstest.GenerateSignature(empty)) + + return m +} + +func GenerateDeleteRequest(empty bool) *container.DeleteRequest { + m := new(container.DeleteRequest) + + if !empty { + m.SetBody(GenerateDeleteRequestBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + + return m +} + +func GenerateDeleteResponseBody(_ bool) *container.DeleteResponseBody { + m := new(container.DeleteResponseBody) + + return m +} + +func GenerateDeleteResponse(empty bool) *container.DeleteResponse { + m := new(container.DeleteResponse) + + if !empty { + m.SetBody(GenerateDeleteResponseBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + + return m +} + +func GenerateListRequestBody(empty bool) *container.ListRequestBody { + m := new(container.ListRequestBody) + + if !empty { + m.SetOwnerID(refstest.GenerateOwnerID(false)) + } + + return m +} + +func GenerateListRequest(empty bool) *container.ListRequest { + m := new(container.ListRequest) + + if !empty { + m.SetBody(GenerateListRequestBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + + return m +} + +func GenerateListResponseBody(empty bool) *container.ListResponseBody { + m := new(container.ListResponseBody) + + if !empty { + m.SetContainerIDs(refstest.GenerateContainerIDs(false)) + } + + return m +} + +func GenerateListResponse(empty bool) *container.ListResponse { + m := new(container.ListResponse) + + if !empty { + m.SetBody(GenerateListResponseBody(false)) + } + + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + + return m +} diff --git a/apiv2/container/types.go b/apiv2/container/types.go new file mode 100644 index 0000000..453a1cc --- /dev/null +++ b/apiv2/container/types.go @@ -0,0 +1,446 @@ +package container + +import ( + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/netmap" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/session" +) + +type Attribute struct { + key, val string +} + +type Container struct { + version *refs.Version + + ownerID *refs.OwnerID + + nonce []byte + + basicACL uint32 + + attr []Attribute + + policy *netmap.PlacementPolicy +} + +type PutRequestBody struct { + cnr *Container + + sig *refs.Signature +} +type PutRequest struct { + body *PutRequestBody + + session.RequestHeaders +} + +type PutResponseBody struct { + cid *refs.ContainerID +} + +type PutResponse struct { + body *PutResponseBody + + session.ResponseHeaders +} + +type GetRequestBody struct { + cid *refs.ContainerID +} + +type GetRequest struct { + body *GetRequestBody + + session.RequestHeaders +} + +type GetResponseBody struct { + cnr *Container + + token *session.Token + + sig *refs.Signature +} + +type GetResponse struct { + body *GetResponseBody + + session.ResponseHeaders +} + +type DeleteRequestBody struct { + cid *refs.ContainerID + + sig *refs.Signature +} + +type DeleteRequest struct { + body *DeleteRequestBody + + session.RequestHeaders +} + +type DeleteResponseBody struct{} + +type DeleteResponse struct { + body *DeleteResponseBody + + session.ResponseHeaders +} + +type ListRequestBody struct { + ownerID *refs.OwnerID +} + +type ListRequest struct { + body *ListRequestBody + + session.RequestHeaders +} + +type ListResponseBody struct { + cidList []refs.ContainerID +} + +type ListResponse struct { + body *ListResponseBody + + session.ResponseHeaders +} + +func (a *Attribute) GetKey() string { + if a != nil { + return a.key + } + + return "" +} + +func (a *Attribute) SetKey(v string) { + a.key = v +} + +func (a *Attribute) GetValue() string { + if a != nil { + return a.val + } + + return "" +} + +func (a *Attribute) SetValue(v string) { + a.val = v +} + +func (c *Container) GetVersion() *refs.Version { + if c != nil { + return c.version + } + + return nil +} + +func (c *Container) SetVersion(v *refs.Version) { + c.version = v +} + +func (c *Container) GetOwnerID() *refs.OwnerID { + if c != nil { + return c.ownerID + } + + return nil +} + +func (c *Container) SetOwnerID(v *refs.OwnerID) { + c.ownerID = v +} + +func (c *Container) GetNonce() []byte { + if c != nil { + return c.nonce + } + + return nil +} + +func (c *Container) SetNonce(v []byte) { + c.nonce = v +} + +func (c *Container) GetBasicACL() uint32 { + if c != nil { + return c.basicACL + } + + return 0 +} + +func (c *Container) SetBasicACL(v uint32) { + c.basicACL = v +} + +func (c *Container) GetAttributes() []Attribute { + if c != nil { + return c.attr + } + + return nil +} + +func (c *Container) SetAttributes(v []Attribute) { + c.attr = v +} + +func (c *Container) GetPlacementPolicy() *netmap.PlacementPolicy { + if c != nil { + return c.policy + } + + return nil +} + +func (c *Container) SetPlacementPolicy(v *netmap.PlacementPolicy) { + c.policy = v +} + +func (r *PutRequestBody) GetContainer() *Container { + if r != nil { + return r.cnr + } + + return nil +} + +func (r *PutRequestBody) SetContainer(v *Container) { + r.cnr = v +} + +func (r *PutRequestBody) GetSignature() *refs.Signature { + if r != nil { + return r.sig + } + + return nil +} + +func (r *PutRequestBody) SetSignature(v *refs.Signature) { + // TODO: (neofs-api-go#381) avoid this hack (e.g. create refs.SignatureRFC6979 type) + v.SetScheme(0) + r.sig = v +} + +func (r *PutRequest) GetBody() *PutRequestBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *PutRequest) SetBody(v *PutRequestBody) { + r.body = v +} + +func (r *PutResponseBody) GetContainerID() *refs.ContainerID { + if r != nil { + return r.cid + } + + return nil +} + +func (r *PutResponseBody) SetContainerID(v *refs.ContainerID) { + r.cid = v +} + +func (r *PutResponse) GetBody() *PutResponseBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *PutResponse) SetBody(v *PutResponseBody) { + r.body = v +} + +func (r *GetRequestBody) GetContainerID() *refs.ContainerID { + if r != nil { + return r.cid + } + + return nil +} + +func (r *GetRequestBody) SetContainerID(v *refs.ContainerID) { + r.cid = v +} + +func (r *GetRequest) GetBody() *GetRequestBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *GetRequest) SetBody(v *GetRequestBody) { + r.body = v +} + +func (r *GetResponseBody) GetContainer() *Container { + if r != nil { + return r.cnr + } + + return nil +} + +func (r *GetResponseBody) SetContainer(v *Container) { + r.cnr = v +} + +// GetSessionToken returns token of the session within which requested +// container was created. +func (r *GetResponseBody) GetSessionToken() *session.Token { + if r != nil { + return r.token + } + + return nil +} + +// SetSessionToken sets token of the session within which requested +// container was created. +func (r *GetResponseBody) SetSessionToken(v *session.Token) { + r.token = v +} + +// GetSignature returns signature of the requested container. +func (r *GetResponseBody) GetSignature() *refs.Signature { + if r != nil { + return r.sig + } + + return nil +} + +// SetSignature sets signature of the requested container. +func (r *GetResponseBody) SetSignature(v *refs.Signature) { + // TODO: (neofs-api-go#381) avoid this hack (e.g. create refs.SignatureRFC6979 type) + v.SetScheme(0) + r.sig = v +} + +func (r *GetResponse) GetBody() *GetResponseBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *GetResponse) SetBody(v *GetResponseBody) { + r.body = v +} + +func (r *DeleteRequestBody) GetContainerID() *refs.ContainerID { + if r != nil { + return r.cid + } + + return nil +} + +func (r *DeleteRequestBody) SetContainerID(v *refs.ContainerID) { + r.cid = v +} + +func (r *DeleteRequestBody) GetSignature() *refs.Signature { + if r != nil { + return r.sig + } + + return nil +} + +func (r *DeleteRequestBody) SetSignature(v *refs.Signature) { + // TODO: (neofs-api-go#381) avoid this hack (e.g. create refs.SignatureRFC6979 type) + v.SetScheme(0) + r.sig = v +} + +func (r *DeleteRequest) GetBody() *DeleteRequestBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *DeleteRequest) SetBody(v *DeleteRequestBody) { + r.body = v +} + +func (r *DeleteResponse) GetBody() *DeleteResponseBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *DeleteResponse) SetBody(v *DeleteResponseBody) { + r.body = v +} + +func (r *ListRequestBody) GetOwnerID() *refs.OwnerID { + if r != nil { + return r.ownerID + } + + return nil +} + +func (r *ListRequestBody) SetOwnerID(v *refs.OwnerID) { + r.ownerID = v +} + +func (r *ListRequest) GetBody() *ListRequestBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *ListRequest) SetBody(v *ListRequestBody) { + r.body = v +} + +func (r *ListResponseBody) GetContainerIDs() []refs.ContainerID { + if r != nil { + return r.cidList + } + + return nil +} + +func (r *ListResponseBody) SetContainerIDs(v []refs.ContainerID) { + r.cidList = v +} + +func (r *ListResponse) GetBody() *ListResponseBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *ListResponse) SetBody(v *ListResponseBody) { + r.body = v +} diff --git a/apiv2/lock/grpc/types_frostfs.pb.go b/apiv2/lock/grpc/types_frostfs.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..31343dadb4d8b36a13fc41c1f702002680d90aab GIT binary patch literal 3790 zcmbtWZExE)5dLiaimQOOa^^_QK6>zgHOYn+c`253{g4JLEm1LRi8M&cb{6En?~bHo zTTa?x4cew6@8!9>=kAzgaI6XrcU*GKEH7Ys4-2iV$`A4E@J=0;S{YlK6izPT;_@0! zPu^XpQM6$BoZWG#R6dU)Q7@FXkVJ#8MoEad%vB-eT}GdAG$?BeG5&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QbmQ68TrAx87Q^uPgjb>t^rH993+Ex6Vhx;^Ilm8RK1#z%?#DR3 z$dZy(hLaam`^2O@R+W;@%@bfrsDrW5sOvD=k=j TAF>f#-^ zCAd4P>C&B7!aaF*=D54ugzow8J76bzq@{C=rb=wF9UC-A=x1xTcZ3j<5`sU@dAC;R sYXoJu>+;n_?;B`mA(2WCt?LzERD#eqgJ+w_sD++j2nuWygkCfM0?<3R4gdfE literal 0 HcmV?d00001 diff --git a/apiv2/lock/grpc/types_frostfs_fuzz.go b/apiv2/lock/grpc/types_frostfs_fuzz.go new file mode 100644 index 0000000..cb55151 --- /dev/null +++ b/apiv2/lock/grpc/types_frostfs_fuzz.go @@ -0,0 +1,26 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package lock + +func DoFuzzProtoLock(data []byte) int { + msg := new(Lock) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONLock(data []byte) int { + msg := new(Lock) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/lock/grpc/types_frostfs_test.go b/apiv2/lock/grpc/types_frostfs_test.go new file mode 100644 index 0000000..7c69064 --- /dev/null +++ b/apiv2/lock/grpc/types_frostfs_test.go @@ -0,0 +1,21 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package lock + +import ( + testing "testing" +) + +func FuzzProtoLock(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoLock(data) + }) +} +func FuzzJSONLock(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONLock(data) + }) +} diff --git a/apiv2/netmap/convert.go b/apiv2/netmap/convert.go new file mode 100644 index 0000000..d301343 --- /dev/null +++ b/apiv2/netmap/convert.go @@ -0,0 +1,916 @@ +package netmap + +import ( + netmap "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/netmap/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs" + refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/refs/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/grpc" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/rpc/message" +) + +func (f *Filter) ToGRPCMessage() grpc.Message { + var m *netmap.Filter + + if f != nil { + m = new(netmap.Filter) + + m.SetKey(f.key) + m.SetValue(f.value) + m.SetName(f.name) + m.SetOp(OperationToGRPCMessage(f.op)) + m.SetFilters(FiltersToGRPC(f.filters)) + } + + return m +} + +func (f *Filter) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.Filter) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + f.filters, err = FiltersFromGRPC(v.GetFilters()) + if err != nil { + return err + } + + f.key = v.GetKey() + f.value = v.GetValue() + f.name = v.GetName() + f.op = OperationFromGRPCMessage(v.GetOp()) + + return nil +} + +func FiltersToGRPC(fs []Filter) (res []netmap.Filter) { + if fs != nil { + res = make([]netmap.Filter, 0, len(fs)) + + for i := range fs { + res = append(res, *fs[i].ToGRPCMessage().(*netmap.Filter)) + } + } + + return +} + +func FiltersFromGRPC(fs []netmap.Filter) (res []Filter, err error) { + if fs != nil { + res = make([]Filter, len(fs)) + + for i := range fs { + err = res[i].FromGRPCMessage(&fs[i]) + if err != nil { + return + } + } + } + + return +} + +func (s *Selector) ToGRPCMessage() grpc.Message { + var m *netmap.Selector + + if s != nil { + m = new(netmap.Selector) + + m.SetName(s.name) + m.SetAttribute(s.attribute) + m.SetFilter(s.filter) + m.SetCount(s.count) + m.SetClause(ClauseToGRPCMessage(s.clause)) + } + + return m +} + +func (s *Selector) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.Selector) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + s.name = v.GetName() + s.attribute = v.GetAttribute() + s.filter = v.GetFilter() + s.count = v.GetCount() + s.clause = ClauseFromGRPCMessage(v.GetClause()) + + return nil +} + +func SelectorsToGRPC(ss []Selector) (res []netmap.Selector) { + if ss != nil { + res = make([]netmap.Selector, 0, len(ss)) + + for i := range ss { + res = append(res, *ss[i].ToGRPCMessage().(*netmap.Selector)) + } + } + + return +} + +func SelectorsFromGRPC(ss []netmap.Selector) (res []Selector, err error) { + if ss != nil { + res = make([]Selector, len(ss)) + + for i := range ss { + err = res[i].FromGRPCMessage(&ss[i]) + if err != nil { + return + } + } + } + + return +} + +func (r *Replica) ToGRPCMessage() grpc.Message { + var m *netmap.Replica + + if r != nil { + m = new(netmap.Replica) + + m.SetSelector(r.selector) + m.SetCount(r.count) + m.EcDataCount = r.ecDataCount + m.EcParityCount = r.ecParityCount + } + + return m +} + +func (r *Replica) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.Replica) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + r.selector = v.GetSelector() + r.count = v.GetCount() + r.ecDataCount = v.GetEcDataCount() + r.ecParityCount = v.GetEcParityCount() + + return nil +} + +func ReplicasToGRPC(rs []Replica) (res []netmap.Replica) { + if rs != nil { + res = make([]netmap.Replica, 0, len(rs)) + + for i := range rs { + res = append(res, *rs[i].ToGRPCMessage().(*netmap.Replica)) + } + } + + return +} + +func ReplicasFromGRPC(rs []netmap.Replica) (res []Replica, err error) { + if rs != nil { + res = make([]Replica, len(rs)) + + for i := range rs { + err = res[i].FromGRPCMessage(&rs[i]) + if err != nil { + return + } + } + } + + return +} + +func (p *PlacementPolicy) ToGRPCMessage() grpc.Message { + var m *netmap.PlacementPolicy + + if p != nil { + m = new(netmap.PlacementPolicy) + + m.SetFilters(FiltersToGRPC(p.filters)) + m.SetSelectors(SelectorsToGRPC(p.selectors)) + m.SetReplicas(ReplicasToGRPC(p.replicas)) + m.SetContainerBackupFactor(p.backupFactor) + m.SetUnique(p.unique) + } + + return m +} + +func (p *PlacementPolicy) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.PlacementPolicy) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + p.filters, err = FiltersFromGRPC(v.GetFilters()) + if err != nil { + return err + } + + p.selectors, err = SelectorsFromGRPC(v.GetSelectors()) + if err != nil { + return err + } + + p.replicas, err = ReplicasFromGRPC(v.GetReplicas()) + if err != nil { + return err + } + + p.backupFactor = v.GetContainerBackupFactor() + + p.unique = v.GetUnique() + + return nil +} + +func ClauseToGRPCMessage(n Clause) netmap.Clause { + return netmap.Clause(n) +} + +func ClauseFromGRPCMessage(n netmap.Clause) Clause { + return Clause(n) +} + +func OperationToGRPCMessage(n Operation) netmap.Operation { + return netmap.Operation(n) +} + +func OperationFromGRPCMessage(n netmap.Operation) Operation { + return Operation(n) +} + +func NodeStateToGRPCMessage(n NodeState) netmap.NodeInfo_State { + return netmap.NodeInfo_State(n) +} + +func NodeStateFromRPCMessage(n netmap.NodeInfo_State) NodeState { + return NodeState(n) +} + +func (a *Attribute) ToGRPCMessage() grpc.Message { + var m *netmap.NodeInfo_Attribute + + if a != nil { + m = new(netmap.NodeInfo_Attribute) + + m.SetKey(a.key) + m.SetValue(a.value) + m.SetParents(a.parents) + } + + return m +} + +func (a *Attribute) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NodeInfo_Attribute) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + a.key = v.GetKey() + a.value = v.GetValue() + a.parents = v.GetParents() + + return nil +} + +func AttributesToGRPC(as []Attribute) (res []netmap.NodeInfo_Attribute) { + if as != nil { + res = make([]netmap.NodeInfo_Attribute, 0, len(as)) + + for i := range as { + res = append(res, *as[i].ToGRPCMessage().(*netmap.NodeInfo_Attribute)) + } + } + + return +} + +func AttributesFromGRPC(as []netmap.NodeInfo_Attribute) (res []Attribute, err error) { + if as != nil { + res = make([]Attribute, len(as)) + + for i := range as { + err = res[i].FromGRPCMessage(&as[i]) + if err != nil { + return + } + } + } + + return +} + +func (ni *NodeInfo) ToGRPCMessage() grpc.Message { + var m *netmap.NodeInfo + + if ni != nil { + m = new(netmap.NodeInfo) + + m.SetPublicKey(ni.publicKey) + m.SetAddresses(ni.addresses) + m.SetState(NodeStateToGRPCMessage(ni.state)) + m.SetAttributes(AttributesToGRPC(ni.attributes)) + } + + return m +} + +func (ni *NodeInfo) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NodeInfo) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + ni.attributes, err = AttributesFromGRPC(v.GetAttributes()) + if err != nil { + return err + } + + ni.publicKey = v.GetPublicKey() + ni.addresses = v.GetAddresses() + ni.state = NodeStateFromRPCMessage(v.GetState()) + + return nil +} + +func (l *LocalNodeInfoRequestBody) ToGRPCMessage() grpc.Message { + var m *netmap.LocalNodeInfoRequest_Body + + if l != nil { + m = new(netmap.LocalNodeInfoRequest_Body) + } + + return m +} + +func (l *LocalNodeInfoRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.LocalNodeInfoRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + return nil +} + +func (l *LocalNodeInfoRequest) ToGRPCMessage() grpc.Message { + var m *netmap.LocalNodeInfoRequest + + if l != nil { + m = new(netmap.LocalNodeInfoRequest) + + m.SetBody(l.body.ToGRPCMessage().(*netmap.LocalNodeInfoRequest_Body)) + l.RequestHeaders.ToMessage(m) + } + + return m +} + +func (l *LocalNodeInfoRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.LocalNodeInfoRequest) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + l.body = nil + } else { + if l.body == nil { + l.body = new(LocalNodeInfoRequestBody) + } + + err = l.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return l.RequestHeaders.FromMessage(v) +} + +func (l *LocalNodeInfoResponseBody) ToGRPCMessage() grpc.Message { + var m *netmap.LocalNodeInfoResponse_Body + + if l != nil { + m = new(netmap.LocalNodeInfoResponse_Body) + + m.SetVersion(l.version.ToGRPCMessage().(*refsGRPC.Version)) + m.SetNodeInfo(l.nodeInfo.ToGRPCMessage().(*netmap.NodeInfo)) + } + + return m +} + +func (l *LocalNodeInfoResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.LocalNodeInfoResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + version := v.GetVersion() + if version == nil { + l.version = nil + } else { + if l.version == nil { + l.version = new(refs.Version) + } + + err = l.version.FromGRPCMessage(version) + if err != nil { + return err + } + } + + nodeInfo := v.GetNodeInfo() + if nodeInfo == nil { + l.nodeInfo = nil + } else { + if l.nodeInfo == nil { + l.nodeInfo = new(NodeInfo) + } + + err = l.nodeInfo.FromGRPCMessage(nodeInfo) + } + + return err +} + +func (l *LocalNodeInfoResponse) ToGRPCMessage() grpc.Message { + var m *netmap.LocalNodeInfoResponse + + if l != nil { + m = new(netmap.LocalNodeInfoResponse) + + m.SetBody(l.body.ToGRPCMessage().(*netmap.LocalNodeInfoResponse_Body)) + l.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (l *LocalNodeInfoResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.LocalNodeInfoResponse) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + l.body = nil + } else { + if l.body == nil { + l.body = new(LocalNodeInfoResponseBody) + } + + err = l.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return l.ResponseHeaders.FromMessage(v) +} + +func (x *NetworkParameter) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkConfig_Parameter + + if x != nil { + m = new(netmap.NetworkConfig_Parameter) + + m.SetKey(x.k) + m.SetValue(x.v) + } + + return m +} + +func (x *NetworkParameter) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkConfig_Parameter) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + x.k = v.GetKey() + x.v = v.GetValue() + + return nil +} + +func (x *NetworkConfig) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkConfig + + if x != nil { + m = new(netmap.NetworkConfig) + + var ps []netmap.NetworkConfig_Parameter + + if ln := len(x.ps); ln > 0 { + ps = make([]netmap.NetworkConfig_Parameter, 0, ln) + + for i := range ln { + ps = append(ps, *x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter)) + } + } + + m.SetParameters(ps) + } + + return m +} + +func (x *NetworkConfig) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkConfig) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var ( + ps []NetworkParameter + psV2 = v.GetParameters() + ) + + if psV2 != nil { + ln := len(psV2) + + ps = make([]NetworkParameter, ln) + + for i := range ln { + if err := ps[i].FromGRPCMessage(&psV2[i]); err != nil { + return err + } + } + } + + x.ps = ps + + return nil +} + +func (i *NetworkInfo) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkInfo + + if i != nil { + m = new(netmap.NetworkInfo) + + m.SetMagicNumber(i.magicNum) + m.SetCurrentEpoch(i.curEpoch) + m.SetMsPerBlock(i.msPerBlock) + m.SetNetworkConfig(i.netCfg.ToGRPCMessage().(*netmap.NetworkConfig)) + } + + return m +} + +func (i *NetworkInfo) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkInfo) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + netCfg := v.GetNetworkConfig() + if netCfg == nil { + i.netCfg = nil + } else { + if i.netCfg == nil { + i.netCfg = new(NetworkConfig) + } + + err = i.netCfg.FromGRPCMessage(netCfg) + if err != nil { + return err + } + } + + i.magicNum = v.GetMagicNumber() + i.curEpoch = v.GetCurrentEpoch() + i.msPerBlock = v.GetMsPerBlock() + + return nil +} + +func (l *NetworkInfoRequestBody) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkInfoRequest_Body + + if l != nil { + m = new(netmap.NetworkInfoRequest_Body) + } + + return m +} + +func (l *NetworkInfoRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkInfoRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + return nil +} + +func (l *NetworkInfoRequest) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkInfoRequest + + if l != nil { + m = new(netmap.NetworkInfoRequest) + + m.SetBody(l.body.ToGRPCMessage().(*netmap.NetworkInfoRequest_Body)) + l.RequestHeaders.ToMessage(m) + } + + return m +} + +func (l *NetworkInfoRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkInfoRequest) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + l.body = nil + } else { + if l.body == nil { + l.body = new(NetworkInfoRequestBody) + } + + err = l.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return l.RequestHeaders.FromMessage(v) +} + +func (i *NetworkInfoResponseBody) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkInfoResponse_Body + + if i != nil { + m = new(netmap.NetworkInfoResponse_Body) + + m.SetNetworkInfo(i.netInfo.ToGRPCMessage().(*netmap.NetworkInfo)) + } + + return m +} + +func (i *NetworkInfoResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkInfoResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + netInfo := v.GetNetworkInfo() + if netInfo == nil { + i.netInfo = nil + } else { + if i.netInfo == nil { + i.netInfo = new(NetworkInfo) + } + + err = i.netInfo.FromGRPCMessage(netInfo) + } + + return err +} + +func (l *NetworkInfoResponse) ToGRPCMessage() grpc.Message { + var m *netmap.NetworkInfoResponse + + if l != nil { + m = new(netmap.NetworkInfoResponse) + + m.SetBody(l.body.ToGRPCMessage().(*netmap.NetworkInfoResponse_Body)) + l.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (l *NetworkInfoResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetworkInfoResponse) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + l.body = nil + } else { + if l.body == nil { + l.body = new(NetworkInfoResponseBody) + } + + err = l.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return l.ResponseHeaders.FromMessage(v) +} + +func (x *NetMap) ToGRPCMessage() grpc.Message { + var m *netmap.Netmap + + if x != nil { + m = new(netmap.Netmap) + + m.SetEpoch(x.epoch) + + if x.nodes != nil { + nodes := make([]netmap.NodeInfo, len(x.nodes)) + + for i := range x.nodes { + nodes[i] = *x.nodes[i].ToGRPCMessage().(*netmap.NodeInfo) + } + + m.SetNodes(nodes) + } + } + + return m +} + +func (x *NetMap) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.Netmap) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + nodes := v.GetNodes() + if nodes == nil { + x.nodes = nil + } else { + x.nodes = make([]NodeInfo, len(nodes)) + + for i := range nodes { + err = x.nodes[i].FromGRPCMessage(&nodes[i]) + if err != nil { + return err + } + } + } + + x.epoch = v.GetEpoch() + + return nil +} + +func (x *SnapshotRequestBody) ToGRPCMessage() grpc.Message { + var m *netmap.NetmapSnapshotRequest_Body + + if x != nil { + m = new(netmap.NetmapSnapshotRequest_Body) + } + + return m +} + +func (x *SnapshotRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetmapSnapshotRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + return nil +} + +func (x *SnapshotRequest) ToGRPCMessage() grpc.Message { + var m *netmap.NetmapSnapshotRequest + + if x != nil { + m = new(netmap.NetmapSnapshotRequest) + + m.SetBody(x.body.ToGRPCMessage().(*netmap.NetmapSnapshotRequest_Body)) + x.RequestHeaders.ToMessage(m) + } + + return m +} + +func (x *SnapshotRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetmapSnapshotRequest) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + x.body = nil + } else { + if x.body == nil { + x.body = new(SnapshotRequestBody) + } + + err = x.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return x.RequestHeaders.FromMessage(v) +} + +func (x *SnapshotResponseBody) ToGRPCMessage() grpc.Message { + var m *netmap.NetmapSnapshotResponse_Body + + if x != nil { + m = new(netmap.NetmapSnapshotResponse_Body) + + m.SetNetmap(x.netMap.ToGRPCMessage().(*netmap.Netmap)) + } + + return m +} + +func (x *SnapshotResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetmapSnapshotResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + netMap := v.GetNetmap() + if netMap == nil { + x.netMap = nil + } else { + if x.netMap == nil { + x.netMap = new(NetMap) + } + + err = x.netMap.FromGRPCMessage(netMap) + } + + return err +} + +func (x *SnapshotResponse) ToGRPCMessage() grpc.Message { + var m *netmap.NetmapSnapshotResponse + + if x != nil { + m = new(netmap.NetmapSnapshotResponse) + + m.SetBody(x.body.ToGRPCMessage().(*netmap.NetmapSnapshotResponse_Body)) + x.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (x *SnapshotResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*netmap.NetmapSnapshotResponse) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + body := v.GetBody() + if body == nil { + x.body = nil + } else { + if x.body == nil { + x.body = new(SnapshotResponseBody) + } + + err = x.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return x.ResponseHeaders.FromMessage(v) +} diff --git a/apiv2/netmap/grpc/service_frostfs.pb.go b/apiv2/netmap/grpc/service_frostfs.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..b137fb908f841a7a0615fdb8e6c5339f94960a2c GIT binary patch literal 53488 zcmeHQS(Dqw5q>6r#fVk5NoCEo >;D!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>THfFe~N88M(ph2u(zdU8M)$N@!uX7 Zzmkslp-4v8Qr zKgR7T0urpW$DKVx08g<}$wB^#lYEAdGaGN=!3YBRX^_3PBVR(|)@3i!RFeeqt!8Ng z`4V!1VkYXmzawAiuvd5#^}okkJc^oklLZ_vJMW1rP$Wy&?(!&-u>*9060r<4)hZ;2 zV9snE#);TOKHQvvkPDnP!FwO0lix-cz>2H&A{6b7%AQ hD(}QXEhSyyn)wkD z28#T{M2=kmRD03@g^6vF2J${Y+aLDJX# HYJ#Q8A*a(xqe xxE)sB-GRMb>%G+8 z*nwT|@v;uL6kSVBQv*_v>4~R*-9$m+N7G;EA2Jzu*R5dp6)6JBIpvt+QMg?$$xG!Z zQLdQcsJ#CSoU}Z93@N-R$sAL+b%4De=AsVwK%4dPfz!Fv02`r9GT#$q8WCh R%??*w*(YiinW{%e3$Pj{_ zo6|XNj`lROogN`((EzTHhxaXm71&7%s=zNGxK-D8I1?ufo;i9!N09k}L!f2ymGGm8 zgJuH_3@ld3^ko#Sqs4f%4Od Zj&Oc|gGVDv^*4CnnUn&b>RJx` ztRZ4m%FvOE+1@ESdW{5_45yq0$sG7Ez&G_sI=W$?vDhrI?F&5$mY4nB=~38$o2es> zP>{lc83|2e$iH&0Gy`o1A98bbT++0Bvqz!Lx(SGyw+jtW*3)%9-XGv8bX*gYbOPY* h2|E-x9*nRfm(Xg)4l7p&16DzDf7eH_=;Dv^{2y7kZJYoA literal 0 HcmV?d00001 diff --git a/apiv2/netmap/grpc/service_frostfs_fuzz.go b/apiv2/netmap/grpc/service_frostfs_fuzz.go new file mode 100644 index 0000000..ebb59bc --- /dev/null +++ b/apiv2/netmap/grpc/service_frostfs_fuzz.go @@ -0,0 +1,121 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package netmap + +func DoFuzzProtoLocalNodeInfoRequest(data []byte) int { + msg := new(LocalNodeInfoRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONLocalNodeInfoRequest(data []byte) int { + msg := new(LocalNodeInfoRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoLocalNodeInfoResponse(data []byte) int { + msg := new(LocalNodeInfoResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONLocalNodeInfoResponse(data []byte) int { + msg := new(LocalNodeInfoResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoNetworkInfoRequest(data []byte) int { + msg := new(NetworkInfoRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONNetworkInfoRequest(data []byte) int { + msg := new(NetworkInfoRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoNetworkInfoResponse(data []byte) int { + msg := new(NetworkInfoResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONNetworkInfoResponse(data []byte) int { + msg := new(NetworkInfoResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoNetmapSnapshotRequest(data []byte) int { + msg := new(NetmapSnapshotRequest) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONNetmapSnapshotRequest(data []byte) int { + msg := new(NetmapSnapshotRequest) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} +func DoFuzzProtoNetmapSnapshotResponse(data []byte) int { + msg := new(NetmapSnapshotResponse) + if err := msg.UnmarshalProtobuf(data); err != nil { + return 0 + } + _ = msg.MarshalProtobuf(nil) + return 1 +} +func DoFuzzJSONNetmapSnapshotResponse(data []byte) int { + msg := new(NetmapSnapshotResponse) + if err := msg.UnmarshalJSON(data); err != nil { + return 0 + } + _, err := msg.MarshalJSON() + if err != nil { + panic(err) + } + return 1 +} diff --git a/apiv2/netmap/grpc/service_frostfs_test.go b/apiv2/netmap/grpc/service_frostfs_test.go new file mode 100644 index 0000000..5c9035f --- /dev/null +++ b/apiv2/netmap/grpc/service_frostfs_test.go @@ -0,0 +1,71 @@ +//go:build gofuzz +// +build gofuzz + +// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. + +package netmap + +import ( + testing "testing" +) + +func FuzzProtoLocalNodeInfoRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoLocalNodeInfoRequest(data) + }) +} +func FuzzJSONLocalNodeInfoRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONLocalNodeInfoRequest(data) + }) +} +func FuzzProtoLocalNodeInfoResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoLocalNodeInfoResponse(data) + }) +} +func FuzzJSONLocalNodeInfoResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONLocalNodeInfoResponse(data) + }) +} +func FuzzProtoNetworkInfoRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoNetworkInfoRequest(data) + }) +} +func FuzzJSONNetworkInfoRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONNetworkInfoRequest(data) + }) +} +func FuzzProtoNetworkInfoResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoNetworkInfoResponse(data) + }) +} +func FuzzJSONNetworkInfoResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONNetworkInfoResponse(data) + }) +} +func FuzzProtoNetmapSnapshotRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoNetmapSnapshotRequest(data) + }) +} +func FuzzJSONNetmapSnapshotRequest(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONNetmapSnapshotRequest(data) + }) +} +func FuzzProtoNetmapSnapshotResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzProtoNetmapSnapshotResponse(data) + }) +} +func FuzzJSONNetmapSnapshotResponse(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + DoFuzzJSONNetmapSnapshotResponse(data) + }) +} diff --git a/apiv2/netmap/grpc/service_grpc.pb.go b/apiv2/netmap/grpc/service_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..7881cd61760a4572989f516b8bd3d6d60cbfebcf GIT binary patch literal 9132 zcmeHNZExE+68;?h3Z4(>*?}YXdN?eQqBs<8x@X)rDdP0L92O} hr8b!=%qe|1>6pTne~ 5 v0iC+%D%=NwK$Yj0FY6{jX%zKDHL ~3trevfKFOfMZ$#rl~o3GqMvhR5c-iU5@LX{TJi<`gkYN?D|5*q zsbwlPk#25nX--F@@^*%u5GQgu>fRTle_4L>DpBIE-uSU93IuI6bqmCiU6- {E0E4}O%EHPj&UDq)HCsa6X|=8|Jah$`or6_j}ra8=lR9lO~ylVxC)USJns z;|N}W?9B38S$HKMJ%AsXSwI!`Kw&i(HfEConFItBK)?*0I*_uO&4)}Ck}dd}tpF^+ zGJ}y=)&(h8tg(f*3ZyL0Z{5Fh>9jd}3uW0F(@ShIKi|1URuO60J6?XINoj^?smihy zZFmZPoifQKrw(o*s)-{-T4_*4(~e$LMJAl{vCk_t1Uxs&Pk?qYm*SRXDKZXO<@6yf zRHY+{u8IPjaFDv8sY_-O*_uLh!j6wG{&RfH`p<`KdN#hAT%2D|Ka9s`)9JvAgdyNJ z _hN@9k;|N#Yuw^Ra(R1ICf{$nCJOLNvs*L{_X@*BIn5= zlUgf1aAsb@;4T(y{XLiJ?Uc?OitLl4DJrdrLA8Et7G&qA1-B+8Wzzeh4TKH>wk6&P zD>iHf|x?GE-+urcy_w#&r*{ER~plad^p&CuJ^x2u_j*@eSk-gt#?h2j#oSr{f|# zl