acl_delete_request.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 (d *DeleteAclsRequest) headerVersion() int16 {
  42. return 1
  43. }
  44. func (d *DeleteAclsRequest) isValidVersion() bool {
  45. return d.Version >= 0 && d.Version <= 1
  46. }
  47. func (d *DeleteAclsRequest) requiredVersion() KafkaVersion {
  48. switch d.Version {
  49. case 1:
  50. return V2_0_0_0
  51. default:
  52. return V0_11_0_0
  53. }
  54. }