@@ -82,6 +82,8 @@ struct Admin_options {
8282 rd_kafka_IsolationLevel_t isolation_level ;
8383 rd_kafka_consumer_group_state_t * states ;
8484 int states_cnt ;
85+ rd_kafka_consumer_group_type_t * types ;
86+ int types_cnt ;
8587};
8688
8789/**@brief "unset" value initializers for Admin_options
@@ -96,6 +98,8 @@ struct Admin_options {
9698 Admin_options_def_int, \
9799 Admin_options_def_ptr, \
98100 Admin_options_def_cnt, \
101+ Admin_options_def_ptr, \
102+ Admin_options_def_cnt, \
99103 }
100104
101105#define Admin_options_is_set_int (v ) ((v) != Admin_options_def_int)
@@ -185,6 +189,13 @@ Admin_options_to_c (Handle *self, rd_kafka_admin_op_t for_api,
185189 goto err ;
186190 }
187191
192+ if (Admin_options_is_set_ptr (options -> types ) &&
193+ (err_obj = rd_kafka_AdminOptions_set_match_consumer_group_types (
194+ c_options , options -> types , options -> types_cnt ))) {
195+ snprintf (errstr , sizeof (errstr ), "%s" , rd_kafka_error_string (err_obj ));
196+ goto err ;
197+ }
198+
188199 return c_options ;
189200
190201 err :
@@ -1698,24 +1709,28 @@ static const char Admin_delete_acls_doc[] = PyDoc_STR(
16981709 * @brief List consumer groups
16991710 */
17001711PyObject * Admin_list_consumer_groups (Handle * self , PyObject * args , PyObject * kwargs ) {
1701- PyObject * future , * states_int = NULL ;
1712+ PyObject * future , * states_int = NULL , * types_int = NULL ;
17021713 struct Admin_options options = Admin_options_INITIALIZER ;
17031714 rd_kafka_AdminOptions_t * c_options = NULL ;
17041715 CallState cs ;
17051716 rd_kafka_queue_t * rkqu ;
17061717 rd_kafka_consumer_group_state_t * c_states = NULL ;
1718+ rd_kafka_consumer_group_type_t * c_types = NULL ;
17071719 int states_cnt = 0 ;
1720+ int types_cnt = 0 ;
17081721 int i = 0 ;
17091722
17101723 static char * kws [] = {"future" ,
17111724 /* options */
17121725 "states_int" ,
1726+ "types_int" ,
17131727 "request_timeout" ,
17141728 NULL };
17151729
1716- if (!PyArg_ParseTupleAndKeywords (args , kwargs , "O|Of " , kws ,
1730+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "O|OOf " , kws ,
17171731 & future ,
17181732 & states_int ,
1733+ & types_int ,
17191734 & options .request_timeout )) {
17201735 goto err ;
17211736 }
@@ -1736,7 +1751,7 @@ PyObject *Admin_list_consumer_groups (Handle *self, PyObject *args, PyObject *kw
17361751 PyObject * state = PyList_GET_ITEM (states_int , i );
17371752 if (!cfl_PyInt_Check (state )) {
17381753 PyErr_SetString (PyExc_ValueError ,
1739- "Element of states must be a valid state " );
1754+ "Element of states must be valid states " );
17401755 goto err ;
17411756 }
17421757 c_states [i ] = (rd_kafka_consumer_group_state_t ) cfl_PyInt_AsInt (state );
@@ -1746,6 +1761,33 @@ PyObject *Admin_list_consumer_groups (Handle *self, PyObject *args, PyObject *kw
17461761 }
17471762 }
17481763
1764+ if (types_int != NULL && types_int != Py_None ) {
1765+ if (!PyList_Check (types_int )) {
1766+ PyErr_SetString (PyExc_ValueError ,
1767+ "types must of type list" );
1768+ goto err ;
1769+ }
1770+
1771+ types_cnt = (int )PyList_Size (types_int );
1772+
1773+ if (types_cnt > 0 ) {
1774+ c_types = (rd_kafka_consumer_group_type_t * )
1775+ malloc (types_cnt *
1776+ sizeof (rd_kafka_consumer_group_type_t ));
1777+ for (i = 0 ; i < types_cnt ; i ++ ) {
1778+ PyObject * type = PyList_GET_ITEM (types_int , i );
1779+ if (!cfl_PyInt_Check (type )) {
1780+ PyErr_SetString (PyExc_ValueError ,
1781+ "Element of types must be valid group types" );
1782+ goto err ;
1783+ }
1784+ c_types [i ] = (rd_kafka_consumer_group_type_t ) cfl_PyInt_AsInt (type );
1785+ }
1786+ options .types = c_types ;
1787+ options .types_cnt = types_cnt ;
1788+ }
1789+ }
1790+
17491791 c_options = Admin_options_to_c (self , RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPS ,
17501792 & options , future );
17511793 if (!c_options ) {
@@ -1774,22 +1816,27 @@ PyObject *Admin_list_consumer_groups (Handle *self, PyObject *args, PyObject *kw
17741816 if (c_states ) {
17751817 free (c_states );
17761818 }
1819+ if (c_types ) {
1820+ free (c_types );
1821+ }
17771822 rd_kafka_queue_destroy (rkqu ); /* drop reference from get_background */
17781823 rd_kafka_AdminOptions_destroy (c_options );
1779-
17801824 Py_RETURN_NONE ;
17811825err :
17821826 if (c_states ) {
17831827 free (c_states );
17841828 }
1829+ if (c_types ) {
1830+ free (c_types );
1831+ }
17851832 if (c_options ) {
17861833 rd_kafka_AdminOptions_destroy (c_options );
17871834 Py_DECREF (future );
17881835 }
17891836 return NULL ;
17901837}
17911838const char Admin_list_consumer_groups_doc [] = PyDoc_STR (
1792- ".. py:function:: list_consumer_groups(future, [states_int], [request_timeout])\n"
1839+ ".. py:function:: list_consumer_groups(future, [states_int], [types_int], [ request_timeout])\n"
17931840 "\n"
17941841 " List all the consumer groups.\n"
17951842 "\n"
@@ -3711,6 +3758,8 @@ static PyObject *Admin_c_ListConsumerGroupsResults_to_py(
37113758
37123759 cfl_PyDict_SetInt (kwargs , "state" , rd_kafka_ConsumerGroupListing_state (c_valid_responses [i ]));
37133760
3761+ cfl_PyDict_SetInt (kwargs , "type" , rd_kafka_ConsumerGroupListing_type (c_valid_responses [i ]));
3762+
37143763 args = PyTuple_New (0 );
37153764
37163765 valid_result = PyObject_Call (ConsumerGroupListing_type , args , kwargs );
0 commit comments