forked from TrueCloudLab/frostfs-sdk-go
Airat Arifullin
dd23c6fd2b
* Update go.mod; * Fix packages; * Fix client's `apemanager` methods. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package ape
|
|
|
|
import (
|
|
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape"
|
|
)
|
|
|
|
// TargetType is an SDK representation for v2's TargetType.
|
|
type TargetType apeV2.TargetType
|
|
|
|
const (
|
|
TargetTypeUndefined TargetType = iota
|
|
TargetTypeNamespace
|
|
TargetTypeContainer
|
|
TargetTypeUser
|
|
TargetTypeGroup
|
|
)
|
|
|
|
// ToV2 converts TargetType to v2.
|
|
func (targetType TargetType) ToV2() apeV2.TargetType {
|
|
return apeV2.TargetType(targetType)
|
|
}
|
|
|
|
// FromV2 reads TargetType to v2.
|
|
func (targetType *TargetType) FromV2(v2targetType apeV2.TargetType) {
|
|
*targetType = TargetType(v2targetType)
|
|
}
|
|
|
|
// ChainTarget is an SDK representation for v2's ChainTarget.
|
|
//
|
|
// Note that ChainTarget (as well as v2's ChainTarget) and all related entities
|
|
// are NOT operated by Access-Policy-Engine (APE). The client is responsible
|
|
// to convert these types to policy-engine entities.
|
|
type ChainTarget struct {
|
|
TargetType TargetType
|
|
|
|
Name string
|
|
}
|
|
|
|
// ToV2 converts ChainTarget to v2.
|
|
func (ct *ChainTarget) ToV2() *apeV2.ChainTarget {
|
|
v2ct := new(apeV2.ChainTarget)
|
|
|
|
v2ct.SetTargetType(ct.TargetType.ToV2())
|
|
v2ct.SetName(ct.Name)
|
|
|
|
return v2ct
|
|
}
|
|
|
|
// FromV2 reads ChainTarget frpm v2.
|
|
func (ct *ChainTarget) FromV2(v2ct *apeV2.ChainTarget) {
|
|
ct.TargetType.FromV2(v2ct.GetTargetType())
|
|
ct.Name = v2ct.GetName()
|
|
}
|