forked from mxsm/rocketmq-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_commands.rs
More file actions
151 lines (135 loc) · 4.93 KB
/
auth_commands.rs
File metadata and controls
151 lines (135 loc) · 4.93 KB
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
146
147
148
149
150
151
// Copyright 2026 The RocketMQ Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
mod copy_acl_sub_command;
mod copy_users_sub_command;
mod create_acl_sub_command;
mod create_user_sub_command;
mod delete_acl_sub_command;
mod delete_user_sub_command;
mod get_acl_sub_command;
mod get_user_sub_command;
mod list_acl_sub_command;
mod list_users_sub_command;
mod update_acl_sub_command;
mod update_user_sub_command;
use std::sync::Arc;
use crate::commands::auth_commands::copy_acl_sub_command::CopyAclSubCommand;
use crate::commands::auth_commands::copy_users_sub_command::CopyUsersSubCommand;
use crate::commands::auth_commands::create_acl_sub_command::CreateAclSubCommand;
use crate::commands::auth_commands::create_user_sub_command::CreateUserSubCommand;
use crate::commands::auth_commands::delete_acl_sub_command::DeleteAclSubCommand;
use crate::commands::auth_commands::delete_user_sub_command::DeleteUserSubCommand;
use crate::commands::auth_commands::get_acl_sub_command::GetAclSubCommand;
use crate::commands::auth_commands::get_user_sub_command::GetUserSubCommand;
use crate::commands::auth_commands::list_acl_sub_command::ListAclSubCommand;
use crate::commands::auth_commands::list_users_sub_command::ListUsersSubCommand;
use crate::commands::auth_commands::update_acl_sub_command::UpdateAclSubCommand;
use crate::commands::auth_commands::update_user_sub_command::UpdateUserSubCommand;
use crate::commands::CommandExecute;
use clap::Subcommand;
use rocketmq_error::RocketMQResult;
use rocketmq_remoting::runtime::RPCHook;
#[derive(Subcommand)]
pub enum AuthCommands {
#[command(
name = "copyAcl",
about = "Copy acl to cluster",
long_about = None,
)]
CopyAcl(CopyAclSubCommand),
#[command(
name = "copyUser",
about = "Copy user to cluster",
long_about = None,
)]
CopyUsers(CopyUsersSubCommand),
#[command(
name = "createAcl",
about = "Create acl to cluster",
long_about = None,
)]
CreateAcl(CreateAclSubCommand),
#[command(
name = "createUser",
about = "Create user to cluster.",
long_about = None,
)]
CreateUser(CreateUserSubCommand),
#[command(
name = "deleteAcl",
about = "Delete acl from cluster.",
long_about = None,
)]
DeleteAcl(DeleteAclSubCommand),
#[command(
name = "deleteUser",
about = "Delete user from cluster.",
long_about = None,
)]
DeleteUser(DeleteUserSubCommand),
#[command(
name = "getAcl",
about = "Get acl from cluster.",
long_about = None,
)]
GetAcl(GetAclSubCommand),
#[command(
name = "getUser",
about = "Get user from cluster.",
long_about = None,
)]
GetUser(GetUserSubCommand),
#[command(
name = "listAcl",
about = "List acl from cluster",
long_about = None,
)]
ListAcl(ListAclSubCommand),
#[command(
name = "listUsers",
about = "List users from cluster.",
long_about = None,
)]
ListUsers(ListUsersSubCommand),
#[command(
name = "updateAcl",
about = "Update Access Control List (ACL)",
long_about = None,
)]
UpdateAcl(UpdateAclSubCommand),
#[command(
name = "updateUser",
about = "Update user to cluster.",
long_about = None,
)]
UpdateUser(UpdateUserSubCommand),
}
impl CommandExecute for AuthCommands {
async fn execute(&self, rpc_hook: Option<Arc<dyn RPCHook>>) -> RocketMQResult<()> {
match self {
AuthCommands::CopyAcl(value) => value.execute(rpc_hook).await,
AuthCommands::CopyUsers(value) => value.execute(rpc_hook).await,
AuthCommands::CreateAcl(value) => value.execute(rpc_hook).await,
AuthCommands::CreateUser(value) => value.execute(rpc_hook).await,
AuthCommands::DeleteAcl(value) => value.execute(rpc_hook).await,
AuthCommands::DeleteUser(value) => value.execute(rpc_hook).await,
AuthCommands::GetAcl(value) => value.execute(rpc_hook).await,
AuthCommands::GetUser(value) => value.execute(rpc_hook).await,
AuthCommands::ListAcl(value) => value.execute(rpc_hook).await,
AuthCommands::ListUsers(value) => value.execute(rpc_hook).await,
AuthCommands::UpdateAcl(value) => value.execute(rpc_hook).await,
AuthCommands::UpdateUser(value) => value.execute(rpc_hook).await,
}
}
}