forked from TrueCloudLab/frostfs-node
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
|
package converter
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
|
||
|
nativeschema "git.frostfs.info/TrueCloudLab/policy-engine/schema/native"
|
||
|
)
|
||
|
|
||
|
func SchemaRoleFromACLRole(role acl.Role) (string, error) {
|
||
|
switch role {
|
||
|
case acl.RoleOwner:
|
||
|
return nativeschema.PropertyValueContainerRoleOwner, nil
|
||
|
case acl.RoleContainer:
|
||
|
return nativeschema.PropertyValueContainerRoleContainer, nil
|
||
|
case acl.RoleInnerRing:
|
||
|
return nativeschema.PropertyValueContainerRoleIR, nil
|
||
|
case acl.RoleOthers:
|
||
|
return nativeschema.PropertyValueContainerRoleOthers, nil
|
||
|
default:
|
||
|
return "", fmt.Errorf("failed to convert %s", role.String())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func SchemaMethodFromACLOperation(op acl.Op) (string, error) {
|
||
|
switch op {
|
||
|
case acl.OpObjectGet:
|
||
|
return nativeschema.MethodGetObject, nil
|
||
|
case acl.OpObjectHead:
|
||
|
return nativeschema.MethodHeadObject, nil
|
||
|
case acl.OpObjectPut:
|
||
|
return nativeschema.MethodPutObject, nil
|
||
|
case acl.OpObjectDelete:
|
||
|
return nativeschema.MethodDeleteObject, nil
|
||
|
case acl.OpObjectSearch:
|
||
|
return nativeschema.MethodSearchObject, nil
|
||
|
case acl.OpObjectRange:
|
||
|
return nativeschema.MethodRangeObject, nil
|
||
|
case acl.OpObjectHash:
|
||
|
return nativeschema.MethodHashObject, nil
|
||
|
default:
|
||
|
return "", fmt.Errorf("operation cannot be converted: %d", op)
|
||
|
}
|
||
|
}
|