[#85] apemanager: Generate protobufs for ape
package
* Regenerate protobufs as APE specific type are defined as separate package; * Move `ape` package related utils methods from `apemanager`. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
0803bc6ded
commit
9789b79b1d
16 changed files with 661 additions and 624 deletions
|
@ -1,6 +1,7 @@
|
|||
package apemanagertest
|
||||
|
||||
import (
|
||||
apetest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager"
|
||||
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/test"
|
||||
)
|
||||
|
@ -13,78 +14,12 @@ func generateChainID(empty bool) []byte {
|
|||
return []byte("616c6c6f774f626a476574436e72")
|
||||
}
|
||||
|
||||
func generateRawChains(empty bool, n int) []*apemanager.Chain {
|
||||
if empty {
|
||||
return []*apemanager.Chain{}
|
||||
}
|
||||
|
||||
res := make([]*apemanager.Chain, n)
|
||||
for i := range res {
|
||||
res[i] = generateRawChain(empty)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func generateRawChain(empty bool) *apemanager.Chain {
|
||||
chRaw := new(apemanager.ChainRaw)
|
||||
|
||||
if empty {
|
||||
chRaw.SetRaw([]byte("{}"))
|
||||
} else {
|
||||
chRaw.SetRaw([]byte(`{
|
||||
"ID": "",
|
||||
"Rules": [
|
||||
{
|
||||
"Status": "Allow",
|
||||
"Actions": {
|
||||
"Inverted": false,
|
||||
"Names": [
|
||||
"GetObject"
|
||||
]
|
||||
},
|
||||
"Resources": {
|
||||
"Inverted": false,
|
||||
"Names": [
|
||||
"native:object/*"
|
||||
]
|
||||
},
|
||||
"Any": false,
|
||||
"Condition": [
|
||||
{
|
||||
"Op": "StringEquals",
|
||||
"Object": "Resource",
|
||||
"Key": "Department",
|
||||
"Value": "HR"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"MatchType": "DenyPriority"
|
||||
}`))
|
||||
}
|
||||
|
||||
ch := new(apemanager.Chain)
|
||||
ch.SetKind(chRaw)
|
||||
return ch
|
||||
}
|
||||
|
||||
func GenerateChainTarget(empty bool) *apemanager.ChainTarget {
|
||||
m := new(apemanager.ChainTarget)
|
||||
|
||||
if !empty {
|
||||
m.SetTargetType(apemanager.TargetTypeContainer)
|
||||
m.SetName("BzQw5HH3feoxFDD5tCT87Y1726qzgLfxEE7wgtoRzB3R")
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAddChainRequestBody(empty bool) *apemanager.AddChainRequestBody {
|
||||
m := new(apemanager.AddChainRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetTarget(GenerateChainTarget(empty))
|
||||
m.SetChain(generateRawChain(empty))
|
||||
m.SetTarget(apetest.GenerateChainTarget(empty))
|
||||
m.SetChain(apetest.GenerateRawChain(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -129,7 +64,7 @@ func GenerateRemoveChainRequestBody(empty bool) *apemanager.RemoveChainRequestBo
|
|||
|
||||
if !empty {
|
||||
m.SetChainID(generateChainID(empty))
|
||||
m.SetTarget(GenerateChainTarget(empty))
|
||||
m.SetTarget(apetest.GenerateChainTarget(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -167,7 +102,7 @@ func GenerateListChainsRequestBody(empty bool) *apemanager.ListChainsRequestBody
|
|||
m := new(apemanager.ListChainsRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetTarget(GenerateChainTarget(empty))
|
||||
m.SetTarget(apetest.GenerateChainTarget(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -189,7 +124,7 @@ func GenerateListChainsResponseBody(empty bool) *apemanager.ListChainsResponseBo
|
|||
m := new(apemanager.ListChainsResponseBody)
|
||||
|
||||
if !empty {
|
||||
m.SetChains(generateRawChains(empty, 10))
|
||||
m.SetChains(apetest.GenerateRawChains(empty, 10))
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue