Scott Baker | e7144bc | 2019-10-01 14:16:47 -0700 | [diff] [blame^] | 1 | package sarama |
| 2 | |
| 3 | type DeleteAclsRequest struct { |
| 4 | Version int |
| 5 | Filters []*AclFilter |
| 6 | } |
| 7 | |
| 8 | func (d *DeleteAclsRequest) encode(pe packetEncoder) error { |
| 9 | if err := pe.putArrayLength(len(d.Filters)); err != nil { |
| 10 | return err |
| 11 | } |
| 12 | |
| 13 | for _, filter := range d.Filters { |
| 14 | filter.Version = d.Version |
| 15 | if err := filter.encode(pe); err != nil { |
| 16 | return err |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | return nil |
| 21 | } |
| 22 | |
| 23 | func (d *DeleteAclsRequest) decode(pd packetDecoder, version int16) (err error) { |
| 24 | d.Version = int(version) |
| 25 | n, err := pd.getArrayLength() |
| 26 | if err != nil { |
| 27 | return err |
| 28 | } |
| 29 | |
| 30 | d.Filters = make([]*AclFilter, n) |
| 31 | for i := 0; i < n; i++ { |
| 32 | d.Filters[i] = new(AclFilter) |
| 33 | d.Filters[i].Version = int(version) |
| 34 | if err := d.Filters[i].decode(pd, version); err != nil { |
| 35 | return err |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | return nil |
| 40 | } |
| 41 | |
| 42 | func (d *DeleteAclsRequest) key() int16 { |
| 43 | return 31 |
| 44 | } |
| 45 | |
| 46 | func (d *DeleteAclsRequest) version() int16 { |
| 47 | return int16(d.Version) |
| 48 | } |
| 49 | |
| 50 | func (d *DeleteAclsRequest) requiredVersion() KafkaVersion { |
| 51 | switch d.Version { |
| 52 | case 1: |
| 53 | return V2_0_0_0 |
| 54 | default: |
| 55 | return V0_11_0_0 |
| 56 | } |
| 57 | } |