batch_delete_message.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package mns
  2. //Licensed under the Apache License, Version 2.0 (the "License");
  3. //you may not use this file except in compliance with the License.
  4. //You may obtain a copy of the License at
  5. //
  6. //http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. //Unless required by applicable law or agreed to in writing, software
  9. //distributed under the License is distributed on an "AS IS" BASIS,
  10. //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. //See the License for the specific language governing permissions and
  12. //limitations under the License.
  13. import (
  14. "encoding/xml"
  15. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
  16. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
  17. )
  18. func (client *Queue) BatchDeleteMessage(request *BatchDeleteMessageRequest) (response *BatchDeleteMessageResponse, err error) {
  19. response = CreateBatchDeleteMessageResponse()
  20. err = client.DoActionWithSigner(request, response)
  21. return
  22. }
  23. type BatchDeleteMessageRequest struct {
  24. *requests.RoaRequest
  25. QueueName string `position:"Path" name:"QueueName"`
  26. }
  27. type BatchDeleteMessageResponse struct {
  28. *responses.BaseResponse
  29. RequestId string `json:"RequestId" xml:"RequestId"`
  30. Code string `json:"Code" xml:"Code"`
  31. }
  32. type ReceiptHandles struct {
  33. XMLName xml.Name `xml:"ReceiptHandles"`
  34. Xmlns string `xml:"xmlns,attr"`
  35. Handles []string `xml:"ReceiptHandle"`
  36. }
  37. func (request *BatchDeleteMessageRequest) SetReceiptHandles(receiptHandles []string) {
  38. receiptHandlesObj := &ReceiptHandles{
  39. Xmlns: "http://mns.aliyuncs.com/doc/v1/",
  40. Handles: receiptHandles,
  41. }
  42. content, err := xml.Marshal(receiptHandlesObj)
  43. if err != nil {
  44. panic(err)
  45. }
  46. request.SetContent([]byte(xml.Header + string(content)))
  47. }
  48. func CreateBatchDeleteMessageRequest() (request *BatchDeleteMessageRequest) {
  49. request = &BatchDeleteMessageRequest{
  50. RoaRequest: &requests.RoaRequest{
  51. },
  52. }
  53. request.InitWithApiInfo("MNS", "2015-06-06","BatchDeleteMessage","/queues/[QueueName]/messages", "", "")
  54. request.Method = "DELETE"
  55. request.Headers["x-mns-version"] = "2015-06-06"
  56. request.AcceptFormat = "XML"
  57. return
  58. }
  59. func CreateBatchDeleteMessageResponse() (response *BatchDeleteMessageResponse) {
  60. response = &BatchDeleteMessageResponse{
  61. BaseResponse: &responses.BaseResponse{},
  62. }
  63. return
  64. }