2121# useful
2222
2323
24+ # TODO(stephenfin): include_max_items should not be necessary once we need to
25+ # migrate remaining users to openstacksdk
2426def add_marker_pagination_option_to_parser (
2527 parser : argparse .ArgumentParser ,
28+ include_max_items : bool = True ,
2629) -> None :
2730 """Add marker-based pagination options to the parser.
2831
@@ -39,8 +42,11 @@ def add_marker_pagination_option_to_parser(
3942 type = int ,
4043 action = parseractions .NonNegativeAction ,
4144 help = _ (
42- 'The maximum number of entries to return. If the value exceeds '
43- 'the server-defined maximum, then the maximum value will be used.'
45+ 'The maximum number of entries to return per page. If the value '
46+ 'exceeds the server-defined maximum, then the server-defined '
47+ 'value will be used. Note that this controls the page size, not '
48+ 'the total number of entries returned. Use --max-items to limit '
49+ 'the total number of entries returned.'
4450 ),
4551 )
4652 parser .add_argument (
@@ -52,10 +58,26 @@ def add_marker_pagination_option_to_parser(
5258 'This should be a value that was returned in a previous request.'
5359 ),
5460 )
61+ if include_max_items :
62+ parser .add_argument (
63+ '--max-items' ,
64+ metavar = '<max-items>' ,
65+ type = int ,
66+ action = parseractions .NonNegativeAction ,
67+ default = None ,
68+ help = _ (
69+ 'The maximum number of entries to return in total, paging '
70+ 'through multiple requests if needed. Use --limit to control '
71+ 'the page size.'
72+ ),
73+ )
5574
5675
76+ # TODO(stephenfin): include_max_items should not be necessary once we need to
77+ # migrate remaining users to openstacksdk
5778def add_offset_pagination_option_to_parser (
5879 parser : argparse .ArgumentParser ,
80+ include_max_items : bool = True ,
5981) -> None :
6082 """Add offset-based pagination options to the parser.
6183
@@ -71,8 +93,11 @@ def add_offset_pagination_option_to_parser(
7193 type = int ,
7294 action = parseractions .NonNegativeAction ,
7395 help = _ (
74- 'The maximum number of entries to return. If the value exceeds '
75- 'the server-defined maximum, then the maximum value will be used.'
96+ 'The maximum number of entries to return per page. If the value '
97+ 'exceeds the server-defined maximum, then the maximum value will '
98+ 'be used. Note that this controls the page size, not the total '
99+ 'number of entries returned. Use --max-items to limit the total '
100+ 'number of entries returned.'
76101 ),
77102 )
78103 parser .add_argument (
@@ -86,3 +111,16 @@ def add_offset_pagination_option_to_parser(
86111 'return.'
87112 ),
88113 )
114+ if include_max_items :
115+ parser .add_argument (
116+ '--max-items' ,
117+ metavar = '<max-items>' ,
118+ type = int ,
119+ action = parseractions .NonNegativeAction ,
120+ default = None ,
121+ help = _ (
122+ 'The maximum number of entries to return in total, paging '
123+ 'through multiple requests if needed. Use --limit to control '
124+ 'the page size.'
125+ ),
126+ )
0 commit comments