|
| 1 | +module Kafka |
| 2 | + module Protocol |
| 3 | + class DescribeConfigsResponse |
| 4 | + class ResourceDescription |
| 5 | + attr_reader :name, :type, :error_code, :error_message, :configs |
| 6 | + |
| 7 | + def initialize(name:, type:, error_code:, error_message:, configs:) |
| 8 | + @name = name |
| 9 | + @type = type |
| 10 | + @error_code = error_code |
| 11 | + @error_message = error_message |
| 12 | + @configs = configs |
| 13 | + end |
| 14 | + end |
| 15 | + |
| 16 | + class ConfigEntry |
| 17 | + attr_reader :name, :value, :read_only, :is_default, :is_sensitive |
| 18 | + |
| 19 | + def initialize(name:, value:, read_only:, is_default:, is_sensitive:) |
| 20 | + @name = name |
| 21 | + @value = value |
| 22 | + @read_only = read_only |
| 23 | + @is_default = is_default |
| 24 | + @is_sensitive = is_sensitive |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + attr_reader :resources |
| 29 | + |
| 30 | + def initialize(throttle_time_ms:, resources:) |
| 31 | + @throttle_time_ms = throttle_time_ms |
| 32 | + @resources = resources |
| 33 | + end |
| 34 | + |
| 35 | + def self.decode(decoder) |
| 36 | + throttle_time_ms = decoder.int32 |
| 37 | + resources = decoder.array do |
| 38 | + error_code = decoder.int16 |
| 39 | + error_message = decoder.string |
| 40 | + |
| 41 | + resource_type = decoder.int8 |
| 42 | + if Kafka::Protocol::RESOURCE_TYPES[resource_type].nil? |
| 43 | + raise Kafka::ProtocolError, "Resource type not supported: #{resource_type}" |
| 44 | + end |
| 45 | + resource_name = decoder.string |
| 46 | + |
| 47 | + configs = decoder.array do |
| 48 | + ConfigEntry.new( |
| 49 | + name: decoder.string, |
| 50 | + value: decoder.string, |
| 51 | + read_only: decoder.boolean, |
| 52 | + is_default: decoder.boolean, |
| 53 | + is_sensitive: decoder.boolean, |
| 54 | + ) |
| 55 | + end |
| 56 | + |
| 57 | + ResourceDescription.new( |
| 58 | + type: RESOURCE_TYPES[resource_type], |
| 59 | + name: resource_name, |
| 60 | + error_code: error_code, |
| 61 | + error_message: error_message, |
| 62 | + configs: configs |
| 63 | + ) |
| 64 | + end |
| 65 | + |
| 66 | + new(throttle_time_ms: throttle_time_ms, resources: resources) |
| 67 | + end |
| 68 | + end |
| 69 | + |
| 70 | + end |
| 71 | +end |
0 commit comments