forked from TrueCloudLab/frostfs-rest-gw
[#38] Add cannedAcl field to ContainerInfo
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
357426426f
commit
e0504fec78
4 changed files with 38 additions and 0 deletions
|
@ -29,6 +29,9 @@ type ContainerInfo struct {
|
|||
// Required: true
|
||||
BasicACL *string `json:"basicAcl"`
|
||||
|
||||
// The friendly name for the basicAcl field.
|
||||
CannedACL string `json:"cannedAcl,omitempty"`
|
||||
|
||||
// container Id
|
||||
// Required: true
|
||||
ContainerID *string `json:"containerId"`
|
||||
|
|
|
@ -866,6 +866,10 @@ func init() {
|
|||
"basicAcl": {
|
||||
"type": "string"
|
||||
},
|
||||
"cannedAcl": {
|
||||
"description": "The friendly name for the basicAcl field.",
|
||||
"type": "string"
|
||||
},
|
||||
"containerId": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -2509,6 +2513,10 @@ func init() {
|
|||
"basicAcl": {
|
||||
"type": "string"
|
||||
},
|
||||
"cannedAcl": {
|
||||
"description": "The friendly name for the basicAcl field.",
|
||||
"type": "string"
|
||||
},
|
||||
"containerId": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -253,12 +253,36 @@ func getContainerInfo(ctx context.Context, p *pool.Pool, cnrID cid.ID) (*models.
|
|||
ContainerName: util.NewString(container.Name(*cnr)),
|
||||
OwnerID: util.NewString(cnr.Owner().String()),
|
||||
BasicACL: util.NewString(cnr.BasicACL().EncodeToString()),
|
||||
CannedACL: friendlyBasicACL(cnr.BasicACL()),
|
||||
PlacementPolicy: util.NewString(sb.String()),
|
||||
Attributes: attrs,
|
||||
Version: util.NewString(getContainerVersion(cnr).String()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func friendlyBasicACL(basicACL acl.Basic) string {
|
||||
switch basicACL {
|
||||
case acl.Private:
|
||||
return acl.NamePrivate
|
||||
case acl.PrivateExtended:
|
||||
return acl.NamePrivateExtended
|
||||
case acl.PublicRO:
|
||||
return acl.NamePublicRO
|
||||
case acl.PublicROExtended:
|
||||
return acl.NamePublicROExtended
|
||||
case acl.PublicRW:
|
||||
return acl.NamePublicRW
|
||||
case acl.PublicRWExtended:
|
||||
return acl.NamePublicRWExtended
|
||||
case acl.PublicAppend:
|
||||
return acl.NamePublicAppend
|
||||
case acl.PublicAppendExtended:
|
||||
return acl.NamePublicAppendExtended
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func getContainerVersion(cnr *container.Container) version.Version {
|
||||
var v2cnr containerv2.Container
|
||||
cnr.WriteToV2(&v2cnr)
|
||||
|
|
|
@ -710,6 +710,9 @@ definitions:
|
|||
type: string
|
||||
basicAcl:
|
||||
type: string
|
||||
cannedAcl:
|
||||
description: The friendly name for the basicAcl field.
|
||||
type: string
|
||||
placementPolicy:
|
||||
type: string
|
||||
attributes:
|
||||
|
|
Loading…
Reference in a new issue