summaryrefslogtreecommitdiff
path: root/kafka/admin/config_resource.py
diff options
context:
space:
mode:
authorRichard Lee <github@richardlee.name>2018-07-12 11:39:29 -0700
committerJeff Widman <jeff@jeffwidman.com>2018-10-24 22:42:12 -0700
commit481f88068bdf0a18f12fd7a811b795f889d35fc7 (patch)
tree818f3b1ff92c847f90da3e9f2603d8100e899a50 /kafka/admin/config_resource.py
parentac9d5623116a5754c57a8ecd95b2954ba0f30c14 (diff)
downloadkafka-python-481f88068bdf0a18f12fd7a811b795f889d35fc7.tar.gz
Add KafkaAdmin class
Requires cluster version > 0.10.0.0, and uses new wire protocol classes to do many things via broker connection that previously needed to be done directly in zookeeper.
Diffstat (limited to 'kafka/admin/config_resource.py')
-rw-r--r--kafka/admin/config_resource.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/kafka/admin/config_resource.py b/kafka/admin/config_resource.py
new file mode 100644
index 0000000..e3294c9
--- /dev/null
+++ b/kafka/admin/config_resource.py
@@ -0,0 +1,36 @@
+from __future__ import absolute_import
+
+# enum in stdlib as of py3.4
+try:
+ from enum import IntEnum # pylint: disable=import-error
+except ImportError:
+ # vendored backport module
+ from kafka.vendor.enum34 import IntEnum
+
+
+class ConfigResourceType(IntEnum):
+ """An enumerated type of config resources"""
+
+ BROKER = 4,
+ TOPIC = 2
+
+
+class ConfigResource(object):
+ """A class for specifying config resources.
+ Arguments:
+ resource_type (ConfigResourceType): the type of kafka resource
+ name (string): The name of the kafka resource
+ configs ({key : value}): A maps of config keys to values.
+ """
+
+ def __init__(
+ self,
+ resource_type,
+ name,
+ configs=None
+ ):
+ if not isinstance(resource_type, (ConfigResourceType)):
+ resource_type = ConfigResourceType[str(resource_type).upper()] # pylint: disable-msg=unsubscriptable-object
+ self.resource_type = resource_type
+ self.name = name
+ self.configs = configs