@@ -190,6 +190,16 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
190
190
. infer_subcommands ( pre_flight_settings. infer_subcommands )
191
191
. infer_long_args ( pre_flight_settings. infer_long_options )
192
192
. subcommands ( nodes_subcommands ( pre_flight_settings. clone ( ) ) ) ;
193
+ let operator_policies_group = Command :: new ( "operator_policies" )
194
+ . about ( "Operations on operator policies" )
195
+ . infer_subcommands ( pre_flight_settings. infer_subcommands )
196
+ . infer_long_args ( pre_flight_settings. infer_long_options )
197
+ . after_help ( color_print:: cformat!(
198
+ "<bold>Doc guide</bold>: {}" ,
199
+ POLICY_GUIDE_URL
200
+ ) )
201
+ . subcommand_value_name ( "operator policy" )
202
+ . subcommands ( operator_policies_subcommands ( pre_flight_settings. clone ( ) ) ) ;
193
203
let parameters_group = Command :: new ( "parameters" )
194
204
. about ( "Operations on runtime parameters" )
195
205
. infer_subcommands ( pre_flight_settings. infer_subcommands )
@@ -309,6 +319,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
309
319
import_group,
310
320
list_group,
311
321
nodes_group,
322
+ operator_policies_group,
312
323
parameters_group,
313
324
policies_group,
314
325
publish_group,
@@ -1597,6 +1608,173 @@ fn global_parameters_subcommands(pre_flight_settings: PreFlightSettings) -> [Com
1597
1608
. map ( |cmd| cmd. infer_long_args ( pre_flight_settings. infer_long_options ) )
1598
1609
}
1599
1610
1611
+ fn operator_policies_subcommands ( pre_flight_settings : PreFlightSettings ) -> [ Command ; 10 ] {
1612
+ let declare_cmd = Command :: new ( "declare" )
1613
+ . visible_aliases ( vec ! [ "update" , "set" ] )
1614
+ . about ( "Creates or updates an operator policy" )
1615
+ . after_help ( color_print:: cformat!( "<bold>Doc guide:</bold>: {}" , POLICY_GUIDE_URL ) )
1616
+ . arg (
1617
+ Arg :: new ( "name" )
1618
+ . long ( "name" )
1619
+ . help ( "operator policy name" )
1620
+ . required ( true ) ,
1621
+ )
1622
+ . arg (
1623
+ Arg :: new ( "pattern" )
1624
+ . long ( "pattern" )
1625
+ . help ( "the pattern that is used to match entity (queue, stream, exchange) names" )
1626
+ . required ( true ) ,
1627
+ )
1628
+ . arg (
1629
+ Arg :: new ( "apply_to" )
1630
+ . long ( "apply-to" )
1631
+ . alias ( "applies-to" )
1632
+ . help ( "entities to apply to (queues, classic_queues, quorum_queues, streams, exchanges, all)" )
1633
+ . value_parser ( value_parser ! ( PolicyTarget ) )
1634
+ . required ( true ) ,
1635
+ )
1636
+ . arg (
1637
+ Arg :: new ( "priority" )
1638
+ . long ( "priority" )
1639
+ . help ( "operator policy priority (only the policy with the highest priority is effective)" )
1640
+ . required ( false )
1641
+ . default_value ( "0" ) ,
1642
+ )
1643
+ . arg (
1644
+ Arg :: new ( "definition" )
1645
+ . long ( "definition" )
1646
+ . help ( "operator policy definition" )
1647
+ . required ( true ) ,
1648
+ ) ;
1649
+
1650
+ let list_cmd = Command :: new ( "list" )
1651
+ . long_about ( "Lists operator policies" )
1652
+ . after_help ( color_print:: cformat!(
1653
+ "<bold>Doc guide</bold>: {}" ,
1654
+ POLICY_GUIDE_URL
1655
+ ) ) ;
1656
+
1657
+ let delete_cmd = Command :: new ( "delete" )
1658
+ . about ( "Deletes an operator policy" )
1659
+ . arg (
1660
+ Arg :: new ( "name" )
1661
+ . long ( "name" )
1662
+ . help ( "policy name" )
1663
+ . required ( true ) ,
1664
+ ) ;
1665
+
1666
+ let delete_definition_key_cmd = Command :: new ( "delete_definition_key" )
1667
+ . about ( "Deletes a definition key from an operator policy, unless it is the only key" )
1668
+ . arg (
1669
+ Arg :: new ( "name" )
1670
+ . long ( "name" )
1671
+ . help ( "operator policy name" )
1672
+ . required ( true ) ,
1673
+ )
1674
+ . arg (
1675
+ Arg :: new ( "definition_key" )
1676
+ . long ( "definition-key" )
1677
+ . help ( "definition key" ) ,
1678
+ ) ;
1679
+
1680
+ let delete_definition_key_from_all_in_cmd = Command :: new ( "delete_definition_key_from_all_in" )
1681
+ . about ( "Deletes a definition key from all operator policies in a virtual host, unless it is the only key" )
1682
+ . arg (
1683
+ Arg :: new ( "definition_key" )
1684
+ . long ( "definition-key" )
1685
+ . help ( "definition key" )
1686
+ ) ;
1687
+
1688
+ let list_in_cmd = Command :: new ( "list_in" )
1689
+ . about ( "Lists operator policies in a specific virtual host" )
1690
+ . arg (
1691
+ Arg :: new ( "apply_to" )
1692
+ . long ( "apply-to" )
1693
+ . alias ( "applies-to" )
1694
+ . value_parser ( value_parser ! ( PolicyTarget ) ) ,
1695
+ ) ;
1696
+
1697
+ let list_matching_cmd = Command :: new ( "list_matching_object" )
1698
+ . about ( "Lists operator policies that match an object (queue, stream, exchange) name" )
1699
+ . arg (
1700
+ Arg :: new ( "name" )
1701
+ . long ( "name" )
1702
+ . help ( "name to verify" )
1703
+ . required ( true ) ,
1704
+ )
1705
+ . arg (
1706
+ Arg :: new ( "type" )
1707
+ . long ( "type" )
1708
+ . value_parser ( value_parser ! ( PolicyTarget ) )
1709
+ . required ( true )
1710
+ . help ( "target type, one of 'queues', 'streams', 'exchanges'" ) ,
1711
+ ) ;
1712
+
1713
+ let patch_cmd = Command :: new ( "patch" )
1714
+ . about ( "Merges a set of keys into existing operator policy definitions" )
1715
+ . arg (
1716
+ Arg :: new ( "name" )
1717
+ . long ( "name" )
1718
+ . help ( "operator policy name" )
1719
+ . required ( true ) ,
1720
+ )
1721
+ . arg (
1722
+ Arg :: new ( "definition" )
1723
+ . long ( "definition" )
1724
+ . help ( "operator policy definition changes to merge into the existing ones" ) ,
1725
+ ) ;
1726
+
1727
+ let update_cmd = Command :: new ( "update_definition" )
1728
+ . about ( "Updates an operator policy definition key" )
1729
+ . arg (
1730
+ Arg :: new ( "name" )
1731
+ . long ( "name" )
1732
+ . help ( "operator policy name" )
1733
+ . required ( true ) ,
1734
+ )
1735
+ . arg (
1736
+ Arg :: new ( "definition_key" )
1737
+ . long ( "definition-key" )
1738
+ . help ( "operator policy definition key to update" )
1739
+ . required ( true ) ,
1740
+ )
1741
+ . arg (
1742
+ Arg :: new ( "definition_value" )
1743
+ . long ( "new-value" )
1744
+ . help ( "new definition value to set" )
1745
+ . required ( true ) ,
1746
+ ) ;
1747
+
1748
+ let update_all_in_cmd = Command :: new ( "update_definitions_of_all_in" )
1749
+ . about ( "Updates a definition key in all operator policies in a virtual host" )
1750
+ . arg (
1751
+ Arg :: new ( "definition_key" )
1752
+ . long ( "definition-key" )
1753
+ . help ( "operator policy definition key to update" )
1754
+ . required ( true ) ,
1755
+ )
1756
+ . arg (
1757
+ Arg :: new ( "definition_value" )
1758
+ . long ( "new-value" )
1759
+ . help ( "new operator definition value to set" )
1760
+ . required ( true ) ,
1761
+ ) ;
1762
+
1763
+ [
1764
+ declare_cmd,
1765
+ delete_cmd,
1766
+ delete_definition_key_cmd,
1767
+ delete_definition_key_from_all_in_cmd,
1768
+ list_cmd,
1769
+ list_in_cmd,
1770
+ list_matching_cmd,
1771
+ patch_cmd,
1772
+ update_cmd,
1773
+ update_all_in_cmd,
1774
+ ]
1775
+ . map ( |cmd| cmd. infer_long_args ( pre_flight_settings. infer_long_options ) )
1776
+ }
1777
+
1600
1778
fn policies_subcommands ( pre_flight_settings : PreFlightSettings ) -> [ Command ; 10 ] {
1601
1779
let declare_cmd = Command :: new ( "declare" )
1602
1780
. visible_aliases ( vec ! [ "update" , "set" ] )
0 commit comments