@@ -19,7 +19,8 @@ use super::tanzu_cli::tanzu_subcommands;
19
19
use crate :: output:: TableStyle ;
20
20
use clap:: { Arg , ArgAction , ArgGroup , Command , value_parser} ;
21
21
use rabbitmq_http_client:: commons:: {
22
- BindingDestinationType , ExchangeType , QueueType , ShovelAcknowledgementMode , SupportedProtocol ,
22
+ BindingDestinationType , ExchangeType , PolicyTarget , QueueType , ShovelAcknowledgementMode ,
23
+ SupportedProtocol ,
23
24
} ;
24
25
25
26
pub fn parser ( ) -> Command {
@@ -228,6 +229,10 @@ pub fn parser() -> Command {
228
229
. about ( "purges queues" )
229
230
. subcommand_value_name ( "queue" )
230
231
. subcommands ( purge_subcommands ( ) ) ,
232
+ Command :: new ( "policies" )
233
+ . about ( "operations on policies" )
234
+ . subcommand_value_name ( "policy" )
235
+ . subcommands ( policies_subcommands ( ) ) ,
231
236
Command :: new ( "health_check" )
232
237
. about ( "runs health checks" )
233
238
. subcommand_value_name ( "check" )
@@ -597,7 +602,7 @@ fn declare_subcommands() -> [Command; 12] {
597
602
Arg :: new ( "type" )
598
603
. long ( "type" )
599
604
. help ( "exchange type" )
600
- . value_parser ( clap:: value_parser!( ExchangeType ) )
605
+ . value_parser ( clap:: value_parser!( ExchangeType ) )
601
606
. required ( false ) ,
602
607
)
603
608
. arg (
@@ -666,10 +671,10 @@ fn declare_subcommands() -> [Command; 12] {
666
671
. help ( "parameter's name" )
667
672
. required ( true )
668
673
) . arg (
669
- Arg :: new ( "component" )
670
- . long ( "component" )
671
- . help ( "component (eg. federation)" )
672
- . required ( true ) )
674
+ Arg :: new ( "component" )
675
+ . long ( "component" )
676
+ . help ( "component (eg. federation)" )
677
+ . required ( true ) )
673
678
. arg (
674
679
Arg :: new ( "value" )
675
680
. long ( "value" )
@@ -687,13 +692,14 @@ fn declare_subcommands() -> [Command; 12] {
687
692
. arg (
688
693
Arg :: new ( "pattern" )
689
694
. long ( "pattern" )
690
- . help ( "queue/exchange name pattern " )
695
+ . help ( "the pattern that is used to match entity ( queue, stream, exchange) names " )
691
696
. required ( true ) ,
692
697
)
693
698
. arg (
694
699
Arg :: new ( "apply_to" )
695
700
. long ( "apply-to" )
696
701
. help ( "entities to apply to (queues, classic_queues, quorum_queues, streams, exchanges, all)" )
702
+ . value_parser ( clap:: value_parser!( PolicyTarget ) )
697
703
. required ( true ) ,
698
704
)
699
705
. arg (
@@ -993,6 +999,60 @@ fn purge_subcommands() -> [Command; 1] {
993
999
) ]
994
1000
}
995
1001
1002
+ fn policies_subcommands ( ) -> [ Command ; 3 ] {
1003
+ let declare_cmd = Command :: new ( "declare" )
1004
+ . about ( "creates or updates a policy" )
1005
+ . after_long_help ( color_print:: cformat!( "<bold>Doc guide:</bold>: {}" , POLICY_GUIDE_URL ) )
1006
+ . arg (
1007
+ Arg :: new ( "name" )
1008
+ . long ( "name" )
1009
+ . help ( "policy name" )
1010
+ . required ( true ) ,
1011
+ )
1012
+ . arg (
1013
+ Arg :: new ( "pattern" )
1014
+ . long ( "pattern" )
1015
+ . help ( "the pattern that is used to match entity (queue, stream, exchange) names" )
1016
+ . required ( true ) ,
1017
+ )
1018
+ . arg (
1019
+ Arg :: new ( "apply_to" )
1020
+ . long ( "apply-to" )
1021
+ . help ( "entities to apply to (queues, classic_queues, quorum_queues, streams, exchanges, all)" )
1022
+ . value_parser ( clap:: value_parser!( PolicyTarget ) )
1023
+ . required ( true ) ,
1024
+ )
1025
+ . arg (
1026
+ Arg :: new ( "priority" )
1027
+ . long ( "priority" )
1028
+ . help ( "policy priority (only the policy with the highest priority is effective)" )
1029
+ . required ( false )
1030
+ . default_value ( "0" ) ,
1031
+ )
1032
+ . arg (
1033
+ Arg :: new ( "definition" )
1034
+ . long ( "definition" )
1035
+ . help ( "policy definition" )
1036
+ . required ( true ) ,
1037
+ ) ;
1038
+
1039
+ let list_cmd = Command :: new ( "list" )
1040
+ . long_about ( "lists policies" )
1041
+ . after_long_help ( color_print:: cformat!(
1042
+ "<bold>Doc guide</bold>: {}" ,
1043
+ POLICY_GUIDE_URL
1044
+ ) ) ;
1045
+
1046
+ let delete_cmd = Command :: new ( "delete" ) . about ( "deletes a policy" ) . arg (
1047
+ Arg :: new ( "name" )
1048
+ . long ( "name" )
1049
+ . help ( "policy name" )
1050
+ . required ( true ) ,
1051
+ ) ;
1052
+
1053
+ [ declare_cmd, list_cmd, delete_cmd]
1054
+ }
1055
+
996
1056
fn health_check_subcommands ( ) -> [ Command ; 6 ] {
997
1057
let node_is_quorum_critical_after_help = color_print:: cformat!(
998
1058
r#"
@@ -1178,14 +1238,14 @@ fn import_subcommands() -> [Command; 1] {
1178
1238
1179
1239
pub fn feature_flags_subcommands ( ) -> [ Command ; 3 ] {
1180
1240
let list_cmd = Command :: new ( "list" )
1181
- . long_about ( "Lists feature flags and their cluster state" )
1241
+ . long_about ( "lists feature flags and their cluster state" )
1182
1242
. after_long_help ( color_print:: cformat!(
1183
1243
"<bold>Doc guide</bold>: {}" ,
1184
1244
FEATURE_FLAG_GUIDE_URL
1185
1245
) ) ;
1186
1246
1187
1247
let enable_cmd = Command :: new ( "enable" )
1188
- . long_about ( "Enables a feature flag" )
1248
+ . long_about ( "enables a feature flag" )
1189
1249
. after_long_help ( color_print:: cformat!(
1190
1250
"<bold>Doc guide</bold>: {}" ,
1191
1251
FEATURE_FLAG_GUIDE_URL
@@ -1198,7 +1258,7 @@ pub fn feature_flags_subcommands() -> [Command; 3] {
1198
1258
) ;
1199
1259
1200
1260
let enable_all_cmd = Command :: new ( "enable_all" )
1201
- . long_about ( "Enables all stable feature flags" )
1261
+ . long_about ( "enables all stable feature flags" )
1202
1262
. after_long_help ( color_print:: cformat!(
1203
1263
"<bold>Doc guide</bold>: {}" ,
1204
1264
FEATURE_FLAG_GUIDE_URL
@@ -1209,14 +1269,14 @@ pub fn feature_flags_subcommands() -> [Command; 3] {
1209
1269
1210
1270
pub fn deprecated_features_subcommands ( ) -> [ Command ; 2 ] {
1211
1271
let list_cmd = Command :: new ( "list" )
1212
- . long_about ( "Lists deprecated features" )
1272
+ . long_about ( "lists deprecated features" )
1213
1273
. after_long_help ( color_print:: cformat!(
1214
1274
"<bold>Doc guide</bold>: {}" ,
1215
1275
DEPRECATED_FEATURE_GUIDE_URL
1216
1276
) ) ;
1217
1277
1218
1278
let list_in_use_cmd = Command :: new ( "list_used" )
1219
- . long_about ( "Lists the deprecated features that are found to be in use in the cluster" )
1279
+ . long_about ( "lists the deprecated features that are found to be in use in the cluster" )
1220
1280
. after_long_help ( color_print:: cformat!(
1221
1281
"<bold>Doc guide</bold>: {}" ,
1222
1282
DEPRECATED_FEATURE_GUIDE_URL
0 commit comments