1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use crate::coreobj::CoreObjectType;
use cyfs_base::*;
use std::collections::HashMap;
use serde::Serialize;
#[derive(Clone, Debug, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::DecIpInfo)]
pub struct DecIpInfo {
pub name: String,
pub ip: String,
}
#[derive(Clone, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::DecAclInfo)]
pub struct DecAclInfo {
pub name: String,
pub acl_info: HashMap<String, bool>,
}
#[derive(Clone, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::RegisterDec)]
pub struct RegisterDec {
pub docker_gateway_ip: String,
pub dec_list: HashMap<String, DecIpInfo>,
}
#[derive(Clone, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::UnregisterDec)]
pub struct UnregisterDec {
pub dec_list: HashMap<String, String>,
}
#[derive(Clone, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::ModifyAcl)]
pub struct ModifyAcl {
pub dec_list: HashMap<String, DecAclInfo>,
}
#[derive(Clone, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::app_manager_action_desc::AppManagerActionEnum)]
pub enum AppManagerActionEnum {
RegisterDec(RegisterDec),
UnregisterDec(UnregisterDec),
ModifyAcl(ModifyAcl),
}
#[derive(Clone, ProtobufEncode, ProtobufDecode, ProtobufTransform, Serialize)]
#[cyfs_protobuf_type(crate::codec::protos::AppManagerActionDesc)]
pub struct AppManagerActionDesc {
app_manager_action_enum: AppManagerActionEnum,
}
impl DescContent for AppManagerActionDesc {
fn obj_type() -> u16 {
CoreObjectType::AppManagerAction as u16
}
fn format(&self) -> u8 {
OBJECT_CONTENT_CODEC_FORMAT_PROTOBUF
}
type OwnerType = Option<ObjectId>;
type AreaType = SubDescNone;
type AuthorType = SubDescNone;
type PublicKeyType = SubDescNone;
}
#[derive(Clone, Default, ProtobufEmptyEncode, ProtobufEmptyDecode, Serialize)]
pub struct AppManagerActionBody {}
impl BodyContent for AppManagerActionBody {
fn format(&self) -> u8 {
OBJECT_CONTENT_CODEC_FORMAT_PROTOBUF
}
}
type AppManagerActionType = NamedObjType<AppManagerActionDesc, AppManagerActionBody>;
type AppManagerActionBuilder = NamedObjectBuilder<AppManagerActionDesc, AppManagerActionBody>;
pub type AppManagerActionId = NamedObjectId<AppManagerActionType>;
pub type AppManagerAction = NamedObjectBase<AppManagerActionType>;
pub trait AppManagerActionObj {
fn create_register_dec(
owner: ObjectId,
docker_gateway_ip: String,
dec_list: HashMap<String, DecIpInfo>,
) -> Self;
fn create_unregister_dec(owner: ObjectId, dec_list: HashMap<String, String>) -> Self;
fn create_modify_acl(owner: ObjectId, dec_list: HashMap<String, DecAclInfo>) -> Self;
fn action(&self) -> &AppManagerActionEnum;
}
impl AppManagerActionObj for AppManagerAction {
fn create_register_dec(
owner: ObjectId,
docker_gateway_ip: String,
dec_list: HashMap<String, DecIpInfo>,
) -> Self {
let action = AppManagerActionEnum::RegisterDec(RegisterDec {
docker_gateway_ip,
dec_list,
});
let desc = AppManagerActionDesc {
app_manager_action_enum: action,
};
let body = AppManagerActionBody {};
AppManagerActionBuilder::new(desc, body)
.owner(owner)
.build()
}
fn create_unregister_dec(owner: ObjectId, dec_list: HashMap<String, String>) -> Self {
let action = AppManagerActionEnum::UnregisterDec(UnregisterDec { dec_list });
let desc = AppManagerActionDesc {
app_manager_action_enum: action,
};
let body = AppManagerActionBody {};
AppManagerActionBuilder::new(desc, body)
.owner(owner)
.build()
}
fn create_modify_acl(owner: ObjectId, dec_list: HashMap<String, DecAclInfo>) -> Self {
let action = AppManagerActionEnum::ModifyAcl(ModifyAcl { dec_list });
let desc = AppManagerActionDesc {
app_manager_action_enum: action,
};
let body = AppManagerActionBody {};
AppManagerActionBuilder::new(desc, body)
.owner(owner)
.build()
}
fn action(&self) -> &AppManagerActionEnum {
&self.desc().content().app_manager_action_enum
}
}