Skip to content

Commit bae70fe

Browse files
committed
Changed describe configs
1 parent 0d8a453 commit bae70fe

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

examples/adminapi.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,13 @@ def example_create_partitions(a, topics):
103103

104104

105105
def print_config(config, depth):
106-
print('%40s = %-50s [%s,is:read-only=%r,default=%r,sensitive=%r,synonym=%r,synonyms=%s]' %
106+
print('%40s = %-50s [%s,is:read-only=%r,default=%r,sensitive=%r,synonym=%r,synonyms=%s,type=%r, documentation=%s]' %
107107
((' ' * depth) + config.name, config.value, ConfigSource(config.source),
108108
config.is_read_only, config.is_default,
109109
config.is_sensitive, config.is_synonym,
110110
["%s:%s" % (x.name, ConfigSource(x.source))
111-
for x in iter(config.synonyms.values())]))
111+
for x in iter(config.synonyms.values())],
112+
config.type, config.documentation))
112113

113114

114115
def example_describe_configs(a, args):

src/confluent_kafka/admin/_config.py

+25
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ class ConfigSource(Enum):
5858
DEFAULT_CONFIG = _cimpl.CONFIG_SOURCE_DEFAULT_CONFIG #: Default
5959

6060

61+
class ConfigType(Enum):
62+
"""
63+
Enumerates the different types of configuration properties.
64+
Used by ConfigEntry to specify the
65+
type of configuration properties returned by `describe_configs()`.
66+
"""
67+
UNKNOWN = _cimpl.CONFIG_TYPE_UNKNOWN #: Unknown
68+
BOOLEAN = _cimpl.CONFIG_TYPE_BOOLEAN #: Boolean
69+
STRING = _cimpl.CONFIG_TYPE_STRING #: String
70+
INT = _cimpl.CONFIG_TYPE_INT #: Integer
71+
SHORT = _cimpl.CONFIG_TYPE_SHORT #: Short
72+
LONG = _cimpl.CONFIG_TYPE_LONG #: Long
73+
DOUBLE = _cimpl.CONFIG_TYPE_DOUBLE #: Double
74+
LIST = _cimpl.CONFIG_TYPE_LIST #: List
75+
CLASS = _cimpl.CONFIG_TYPE_CLASS #: Class
76+
PASSWORD = _cimpl.CONFIG_TYPE_PASSWORD #: Password
77+
CNT = _cimpl.CONFIG_TYPE_CNT #: Count
78+
79+
6180
class ConfigEntry(object):
6281
"""
6382
Represents a configuration property. Returned by describe_configs() for each configuration
@@ -72,6 +91,8 @@ def __init__(self, name, value,
7291
is_default=False,
7392
is_sensitive=False,
7493
is_synonym=False,
94+
type=ConfigType.UNKNOWN,
95+
documentation=None,
7596
synonyms=[],
7697
incremental_operation=None):
7798
"""
@@ -100,6 +121,10 @@ def __init__(self, name, value,
100121
"""Indicates whether the configuration property is a synonym for the parent configuration entry."""
101122
self.synonyms = synonyms
102123
"""A list of synonyms (ConfigEntry) and alternate sources for this configuration property."""
124+
self.type = type
125+
"""The type of the configuration property."""
126+
self.documentation = documentation
127+
"""The documentation for the configuration property."""
103128
self.incremental_operation = incremental_operation
104129
"""The incremental operation (AlterConfigOpType) to use in incremental_alter_configs."""
105130

src/confluent_kafka/src/Admin.c

+8
Original file line numberDiff line numberDiff line change
@@ -3435,6 +3435,7 @@ Admin_c_ConfigEntries_to_py (PyObject *ConfigEntry_type,
34353435
PyObject *kwargs, *args;
34363436
const rd_kafka_ConfigEntry_t *ent = c_configs[ci];
34373437
const rd_kafka_ConfigEntry_t **c_synonyms;
3438+
const char *documentation;
34383439
PyObject *entry, *synonyms;
34393440
size_t synonym_cnt;
34403441
const char *val;
@@ -3472,6 +3473,13 @@ Admin_c_ConfigEntries_to_py (PyObject *ConfigEntry_type,
34723473
PyDict_SetItemString(kwargs, "synonyms", synonyms);
34733474
Py_DECREF(synonyms);
34743475

3476+
cfl_PyDict_SetInt(kwargs, "type", rd_kafka_ConfigEntry_type(ent));
3477+
3478+
documentation = rd_kafka_ConfigEntry_documentation(ent);
3479+
3480+
if (documentation)
3481+
cfl_PyDict_SetString(kwargs, "documentation", documentation);
3482+
34753483
args = PyTuple_New(0);
34763484
entry = PyObject_Call(ConfigEntry_type, args, kwargs);
34773485
Py_DECREF(args);

src/confluent_kafka/src/AdminTypes.c

+16
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,21 @@ static void AdminTypes_AddObjectsConfigSource (PyObject *m) {
516516
RD_KAFKA_CONFIG_SOURCE_DEFAULT_CONFIG);
517517
}
518518

519+
static void AdminTypes_AddObjectsConfigType(PyObject *m) {
520+
/* rd_kafka_ConfigType_t */
521+
PyModule_AddIntConstant(m, "CONFIG_TYPE_UNKNOWN", RD_KAFKA_CONFIG_UNKNOWN);
522+
PyModule_AddIntConstant(m, "CONFIG_TYPE_BOOLEAN", RD_KAFKA_CONFIG_BOOLEAN);
523+
PyModule_AddIntConstant(m, "CONFIG_TYPE_STRING", RD_KAFKA_CONFIG_STRING);
524+
PyModule_AddIntConstant(m, "CONFIG_TYPE_INT", RD_KAFKA_CONFIG_INT);
525+
PyModule_AddIntConstant(m, "CONFIG_TYPE_SHORT", RD_KAFKA_CONFIG_SHORT);
526+
PyModule_AddIntConstant(m, "CONFIG_TYPE_LONG", RD_KAFKA_CONFIG_LONG);
527+
PyModule_AddIntConstant(m, "CONFIG_TYPE_DOUBLE", RD_KAFKA_CONFIG_DOUBLE);
528+
PyModule_AddIntConstant(m, "CONFIG_TYPE_LIST", RD_KAFKA_CONFIG_LIST);
529+
PyModule_AddIntConstant(m, "CONFIG_TYPE_CLASS", RD_KAFKA_CONFIG_CLASS);
530+
PyModule_AddIntConstant(m, "CONFIG_TYPE_PASSWORD", RD_KAFKA_CONFIG_PASSWORD);
531+
PyModule_AddIntConstant(m, "CONFIG_TYPE_CNT", RD_KAFKA_CONFIG__CNT);
532+
}
533+
519534

520535
static void AdminTypes_AddObjectsResourceType (PyObject *m) {
521536
/* rd_kafka_ResourceType_t */
@@ -622,6 +637,7 @@ void AdminTypes_AddObjects (PyObject *m) {
622637
PyModule_AddObject(m, "NewPartitions", (PyObject *)&NewPartitionsType);
623638

624639
AdminTypes_AddObjectsConfigSource(m);
640+
AdminTypes_AddObjectsConfigType(m);
625641
AdminTypes_AddObjectsResourceType(m);
626642
AdminTypes_AddObjectsResourcePatternType(m);
627643
AdminTypes_AddObjectsAclOperation(m);

0 commit comments

Comments
 (0)