class CreatePartitionsResponse_v0(Response): API_KEY = 37 API_VERSION = 0 SCHEMA = Schema(('throttle_time_ms', Int32), ('topic_errors', Array(('topic', String('utf-8')), ('error_code', Int16), ('error_message', String('utf-8')))))
class CreateTopicsResponse_v2(Response): API_KEY = 19 API_VERSION = 2 SCHEMA = Schema(('throttle_time_ms', Int32), ('topic_error_codes', Array(('topic', String('utf-8')), ('error_code', Int16), ('error_message', String('utf-8')))))
class ListGroupsResponse_v1(Response): API_KEY = 16 API_VERSION = 1 SCHEMA = Schema(('throttle_time_ms', Int32), ('error_code', Int16), ('groups', Array(('group', String('utf-8')), ('protocol_type', String('utf-8')))))
class ListGroupsResponse_v0(Response): API_KEY = 16 API_VERSION = 0 SCHEMA = Schema(('error_code', Int16), ('groups', Array(('group', String('utf-8')), ('protocol_type', String('utf-8')))))
class OffsetFetchRequest_v0(Request): API_KEY = 9 API_VERSION = 0 # zookeeper-backed storage RESPONSE_TYPE = OffsetFetchResponse_v0 SCHEMA = Schema(('consumer_group', String('utf-8')), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(Int32)))))
class OffsetFetchResponse_v0(Response): API_KEY = 9 API_VERSION = 0 SCHEMA = Schema( ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('offset', Int64), ('metadata', String('utf-8')), ('error_code', Int16))))))
class JoinGroupResponse_v0(Response): API_KEY = 11 API_VERSION = 0 SCHEMA = Schema( ('error_code', Int16), ('generation_id', Int32), ('group_protocol', String('utf-8')), ('leader_id', String('utf-8')), ('member_id', String('utf-8')), ('members', Array(('member_id', String('utf-8')), ('member_metadata', Bytes))))
class SyncGroupRequest_v0(Request): API_KEY = 14 API_VERSION = 0 RESPONSE_TYPE = SyncGroupResponse_v0 SCHEMA = Schema(('group', String('utf-8')), ('generation_id', Int32), ('member_id', String('utf-8')), ('group_assignment', Array(('member_id', String('utf-8')), ('member_metadata', Bytes))))
class ProduceRequest_v3(ProduceRequest): API_VERSION = 3 RESPONSE_TYPE = ProduceResponse_v3 SCHEMA = Schema( ('transactional_id', String('utf-8')), ('required_acks', Int16), ('timeout', Int32), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('messages', Bytes))))))
class OffsetCommitRequest_v0(Request): API_KEY = 8 API_VERSION = 0 # Zookeeper-backed storage RESPONSE_TYPE = OffsetCommitResponse_v0 SCHEMA = Schema(('consumer_group', String('utf-8')), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('offset', Int64), ('metadata', String('utf-8')))))))
class JoinGroupRequest_v0(Request): API_KEY = 11 API_VERSION = 0 RESPONSE_TYPE = JoinGroupResponse_v0 SCHEMA = Schema(('group', String('utf-8')), ('session_timeout', Int32), ('member_id', String('utf-8')), ('protocol_type', String('utf-8')), ('group_protocols', Array(('protocol_name', String('utf-8')), ('protocol_metadata', Bytes)))) UNKNOWN_MEMBER_ID = ''
class OffsetCommitRequest_v1(Request): API_KEY = 8 API_VERSION = 1 # Kafka-backed storage RESPONSE_TYPE = OffsetCommitResponse_v1 SCHEMA = Schema(('consumer_group', String('utf-8')), ('consumer_group_generation_id', Int32), ('consumer_id', String('utf-8')), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('offset', Int64), ('timestamp', Int64), ('metadata', String('utf-8')))))))
class CreateTopicsRequest_v1(Request): API_KEY = 19 API_VERSION = 1 RESPONSE_TYPE = CreateTopicsResponse_v1 SCHEMA = Schema( ('create_topic_requests', Array(('topic', String('utf-8')), ('num_partitions', Int32), ('replication_factor', Int16), ('replica_assignment', Array(('partition_id', Int32), ('replicas', Array(Int32)))), ('configs', Array(('config_key', String('utf-8')), ('config_value', String('utf-8')))))), ('timeout', Int32), ('validate_only', Boolean))
class OffsetCommitRequest_v2(Request): API_KEY = 8 API_VERSION = 2 # added retention_time, dropped timestamp RESPONSE_TYPE = OffsetCommitResponse_v2 SCHEMA = Schema(('consumer_group', String('utf-8')), ('consumer_group_generation_id', Int32), ('consumer_id', String('utf-8')), ('retention_time', Int64), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('offset', Int64), ('metadata', String('utf-8'))))))) DEFAULT_GENERATION_ID = -1 DEFAULT_RETENTION_TIME = -1
class ProduceResponse_v0(Response): API_KEY = 0 API_VERSION = 0 SCHEMA = Schema(('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('error_code', Int16), ('offset', Int64))))))
class RequestHeader(Struct): SCHEMA = Schema(('api_key', Int16), ('api_version', Int16), ('correlation_id', Int32), ('client_id', String('utf-8'))) def __init__(self, request, correlation_id=0, client_id='kafka-python'): super(RequestHeader, self).__init__(request.API_KEY, request.API_VERSION, correlation_id, client_id)
class MetadataRequest_v0(Request): API_KEY = 3 API_VERSION = 0 RESPONSE_TYPE = MetadataResponse_v0 SCHEMA = Schema( ('topics', Array(String('utf-8'))) ) ALL_TOPICS = None # Empty Array (len 0) for topics returns all topics
class OffsetResponse_v1(Response): API_KEY = 2 API_VERSION = 1 SCHEMA = Schema(('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('error_code', Int16), ('timestamp', Int64), ('offset', Int64))))))
class OffsetCommitResponse_v0(Response): API_KEY = 8 API_VERSION = 0 SCHEMA = Schema( ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('error_code', Int16))))))
class FetchResponse_v0(Response): API_KEY = 1 API_VERSION = 0 SCHEMA = Schema( ('topics', Array(('topics', String('utf-8')), ('partitions', Array(('partition', Int32), ('error_code', Int16), ('highwater_offset', Int64), ('message_set', Bytes))))))
class MetadataResponse_v0(Response): API_KEY = 3 API_VERSION = 0 SCHEMA = Schema( ('brokers', Array( ('node_id', Int32), ('host', String('utf-8')), ('port', Int32))), ('topics', Array( ('error_code', Int16), ('topic', String('utf-8')), ('partitions', Array( ('error_code', Int16), ('partition', Int32), ('leader', Int32), ('replicas', Array(Int32)), ('isr', Array(Int32)))))) )
class ProduceResponse_v2(Response): API_KEY = 0 API_VERSION = 2 SCHEMA = Schema(('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('error_code', Int16), ('offset', Int64), ('timestamp', Int64))))), ('throttle_time_ms', Int32))
class MetadataRequest_v4(Request): API_KEY = 3 API_VERSION = 4 RESPONSE_TYPE = MetadataResponse_v4 SCHEMA = Schema( ('topics', Array(String('utf-8'))), ('allow_auto_topic_creation', Boolean) ) ALL_TOPICS = -1 # Null Array (len -1) for topics returns all topics NO_TOPICS = None # Empty array (len 0) for topics returns no topics
class CreatePartitionsRequest_v0(Request): API_KEY = 37 API_VERSION = 0 RESPONSE_TYPE = CreatePartitionsResponse_v0 SCHEMA = Schema(('topic_partitions', Array(('topic', String('utf-8')), ('new_partitions', Schema(('count', Int32), ('assignment', Array(Int32)))))), ('timeout', Int32), ('validate_only', Boolean))
class FetchRequest_v0(Request): API_KEY = 1 API_VERSION = 0 RESPONSE_TYPE = FetchResponse_v0 SCHEMA = Schema(('replica_id', Int32), ('max_wait_time', Int32), ('min_bytes', Int32), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('offset', Int64), ('max_bytes', Int32))))))
class OffsetRequest_v1(Request): API_KEY = 2 API_VERSION = 1 RESPONSE_TYPE = OffsetResponse_v1 SCHEMA = Schema( ('replica_id', Int32), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('timestamp', Int64)))))) DEFAULTS = {'replica_id': -1}
class OffsetRequest_v2(Request): API_KEY = 2 API_VERSION = 2 RESPONSE_TYPE = OffsetResponse_v2 SCHEMA = Schema( ('replica_id', Int32), ('isolation_level', Int8), # <- added isolation_level ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('timestamp', Int64)))))) DEFAULTS = {'replica_id': -1}
class MetadataResponse_v1(Response): API_KEY = 3 API_VERSION = 1 SCHEMA = Schema( ('brokers', Array( ('node_id', Int32), ('host', String('utf-8')), ('port', Int32), ('rack', String('utf-8')))), ('controller_id', Int32), ('topics', Array( ('error_code', Int16), ('topic', String('utf-8')), ('is_internal', Boolean), ('partitions', Array( ('error_code', Int16), ('partition', Int32), ('leader', Int32), ('replicas', Array(Int32)), ('isr', Array(Int32)))))) )
class ConsumerProtocolMemberAssignment(Struct): SCHEMA = Schema(('version', Int16), ('assignment', Array(('topic', String('utf-8')), ('partitions', Array(Int32)))), ('user_data', Bytes)) def partitions(self): return [ TopicPartition(topic, partition) for topic, partitions in self.assignment # pylint: disable-msg=no-member for partition in partitions ]
class FetchRequest_v5(Request): # This may only be used in broker-broker api calls API_KEY = 1 API_VERSION = 5 RESPONSE_TYPE = FetchResponse_v5 SCHEMA = Schema( ('replica_id', Int32), ('max_wait_time', Int32), ('min_bytes', Int32), ('max_bytes', Int32), ('isolation_level', Int8), ('topics', Array(('topic', String('utf-8')), ('partitions', Array(('partition', Int32), ('fetch_offset', Int64), ('log_start_offset', Int64), ('max_bytes', Int32))))))