Airat Arifullin
b2ad1f3b3e
* Introduce `APEManagerAddChain`, `APEManagerRemoveChain`, `APEManagerListChains`. * Introduce reqeuest/response types for these handlers (Prm*, Res*). * Inroduce status type for apemanager `APEManagerAccessDenied`; add unit-tests. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package apistatus
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status"
|
|
)
|
|
|
|
// APEManagerAccessDenied describes status of the failure because of the access control violation.
|
|
// Instances provide Status and StatusV2 interfaces.
|
|
type APEManagerAccessDenied struct {
|
|
v2 status.Status
|
|
}
|
|
|
|
const defaultAPEManagerAccessDeniedMsg = "apemanager access denied"
|
|
|
|
func (x *APEManagerAccessDenied) Error() string {
|
|
msg := x.v2.Message()
|
|
if msg == "" {
|
|
msg = defaultAPEManagerAccessDeniedMsg
|
|
}
|
|
|
|
return errMessageStatusV2(
|
|
globalizeCodeV2(apemanager.StatusAPEManagerAccessDenied, apemanager.GlobalizeFail),
|
|
msg,
|
|
)
|
|
}
|
|
|
|
func (x *APEManagerAccessDenied) fromStatusV2(st *status.Status) {
|
|
x.v2 = *st
|
|
}
|
|
|
|
// ToStatusV2 converts APEManagerAccessDenied to v2's Status.
|
|
// If the value was returned by FromStatusV2, returns the source message.
|
|
// Otherwise, returns message with
|
|
// - code: APE_MANAGER_ACCESS_DENIED;
|
|
// - string message: "apemanager access denied";
|
|
// - details: empty.
|
|
func (x APEManagerAccessDenied) ToStatusV2() *status.Status {
|
|
x.v2.SetCode(globalizeCodeV2(apemanager.StatusAPEManagerAccessDenied, apemanager.GlobalizeFail))
|
|
x.v2.SetMessage(defaultAPEManagerAccessDeniedMsg)
|
|
return &x.v2
|
|
}
|
|
|
|
// WriteReason writes human-readable access rejection reason.
|
|
func (x *APEManagerAccessDenied) WriteReason(reason string) {
|
|
apemanager.WriteAccessDeniedDesc(&x.v2, reason)
|
|
}
|
|
|
|
// Reason returns human-readable access rejection reason returned by the server.
|
|
// Returns empty value is reason is not presented.
|
|
func (x APEManagerAccessDenied) Reason() string {
|
|
return apemanager.ReadAccessDeniedDesc(x.v2)
|
|
}
|