acl_delete_request.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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) requiredVersion() KafkaVersion {
  42. switch d.Version {
  43. case 1:
  44. return V2_0_0_0
  45. default:
  46. return V0_11_0_0
  47. }
  48. }