[#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
|
// Required: true
|
||||||
BasicACL *string `json:"basicAcl"`
|
BasicACL *string `json:"basicAcl"`
|
||||||
|
|
||||||
|
// The friendly name for the basicAcl field.
|
||||||
|
CannedACL string `json:"cannedAcl,omitempty"`
|
||||||
|
|
||||||
// container Id
|
// container Id
|
||||||
// Required: true
|
// Required: true
|
||||||
ContainerID *string `json:"containerId"`
|
ContainerID *string `json:"containerId"`
|
||||||
|
|
|
@ -866,6 +866,10 @@ func init() {
|
||||||
"basicAcl": {
|
"basicAcl": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"cannedAcl": {
|
||||||
|
"description": "The friendly name for the basicAcl field.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"containerId": {
|
"containerId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -2509,6 +2513,10 @@ func init() {
|
||||||
"basicAcl": {
|
"basicAcl": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"cannedAcl": {
|
||||||
|
"description": "The friendly name for the basicAcl field.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"containerId": {
|
"containerId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -253,12 +253,36 @@ func getContainerInfo(ctx context.Context, p *pool.Pool, cnrID cid.ID) (*models.
|
||||||
ContainerName: util.NewString(container.Name(*cnr)),
|
ContainerName: util.NewString(container.Name(*cnr)),
|
||||||
OwnerID: util.NewString(cnr.Owner().String()),
|
OwnerID: util.NewString(cnr.Owner().String()),
|
||||||
BasicACL: util.NewString(cnr.BasicACL().EncodeToString()),
|
BasicACL: util.NewString(cnr.BasicACL().EncodeToString()),
|
||||||
|
CannedACL: friendlyBasicACL(cnr.BasicACL()),
|
||||||
PlacementPolicy: util.NewString(sb.String()),
|
PlacementPolicy: util.NewString(sb.String()),
|
||||||
Attributes: attrs,
|
Attributes: attrs,
|
||||||
Version: util.NewString(getContainerVersion(cnr).String()),
|
Version: util.NewString(getContainerVersion(cnr).String()),
|
||||||
}, nil
|
}, 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 {
|
func getContainerVersion(cnr *container.Container) version.Version {
|
||||||
var v2cnr containerv2.Container
|
var v2cnr containerv2.Container
|
||||||
cnr.WriteToV2(&v2cnr)
|
cnr.WriteToV2(&v2cnr)
|
||||||
|
|
|
@ -710,6 +710,9 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
basicAcl:
|
basicAcl:
|
||||||
type: string
|
type: string
|
||||||
|
cannedAcl:
|
||||||
|
description: The friendly name for the basicAcl field.
|
||||||
|
type: string
|
||||||
placementPolicy:
|
placementPolicy:
|
||||||
type: string
|
type: string
|
||||||
attributes:
|
attributes:
|
||||||
|
|
Reference in a new issue