acl_delete_request.go 1.1 KB

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