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