2024-05-28 09:05:02 +00:00
|
|
|
package ape
|
2024-05-06 13:26:51 +00:00
|
|
|
|
|
|
|
import (
|
2024-05-28 09:05:02 +00:00
|
|
|
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape"
|
2024-05-06 13:26:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TargetType is an SDK representation for v2's TargetType.
|
2024-05-28 09:05:02 +00:00
|
|
|
type TargetType apeV2.TargetType
|
2024-05-06 13:26:51 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
TargetTypeUndefined TargetType = iota
|
|
|
|
TargetTypeNamespace
|
|
|
|
TargetTypeContainer
|
|
|
|
TargetTypeUser
|
|
|
|
TargetTypeGroup
|
|
|
|
)
|
|
|
|
|
|
|
|
// ToV2 converts TargetType to v2.
|
2024-05-28 09:05:02 +00:00
|
|
|
func (targetType TargetType) ToV2() apeV2.TargetType {
|
|
|
|
return apeV2.TargetType(targetType)
|
2024-05-06 13:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FromV2 reads TargetType to v2.
|
2024-05-28 09:05:02 +00:00
|
|
|
func (targetType *TargetType) FromV2(v2targetType apeV2.TargetType) {
|
2024-05-06 13:26:51 +00:00
|
|
|
*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.
|
2024-05-28 09:05:02 +00:00
|
|
|
func (ct *ChainTarget) ToV2() *apeV2.ChainTarget {
|
|
|
|
v2ct := new(apeV2.ChainTarget)
|
2024-05-06 13:26:51 +00:00
|
|
|
|
|
|
|
v2ct.SetTargetType(ct.TargetType.ToV2())
|
|
|
|
v2ct.SetName(ct.Name)
|
|
|
|
|
|
|
|
return v2ct
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromV2 reads ChainTarget frpm v2.
|
2024-05-28 09:05:02 +00:00
|
|
|
func (ct *ChainTarget) FromV2(v2ct *apeV2.ChainTarget) {
|
2024-05-06 13:26:51 +00:00
|
|
|
ct.TargetType.FromV2(v2ct.GetTargetType())
|
|
|
|
ct.Name = v2ct.GetName()
|
|
|
|
}
|