shared-sqs: Этап 1 — клон GoAWS, удаление SNS, go build OK
This commit is contained in:
@@ -0,0 +1,340 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
type ResponseMetadata struct {
|
||||
RequestId string `xml:"RequestId"`
|
||||
}
|
||||
|
||||
// NOTE: Every response in here MUST implement the `AbstractResponseBody` interface in order to be used
|
||||
// in `encodeResponse`
|
||||
|
||||
/*** Error Responses ***/
|
||||
type ErrorResult struct {
|
||||
Type string `json:"Type,omitempty" xml:"Type,omitempty"`
|
||||
Code string `json:"Code,omitempty" xml:"Code,omitempty"`
|
||||
Message string `json:"Message,omitempty" xml:"Message,omitempty"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Result ErrorResult `json:"Error" xml:"Error"`
|
||||
RequestId string `json:"RequestId" xml:"RequestId"`
|
||||
}
|
||||
|
||||
func (r ErrorResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r ErrorResponse) GetRequestId() string {
|
||||
return r.RequestId
|
||||
}
|
||||
|
||||
/*** Receive Message Response */
|
||||
type ReceiveMessageResult struct {
|
||||
Messages []*ResultMessage `json:"Messages" xml:"Message,omitempty"`
|
||||
}
|
||||
|
||||
type ReceiveMessageResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result ReceiveMessageResult `json:"ReceiveMessageResult" xml:"ReceiveMessageResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r ReceiveMessageResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r ReceiveMessageResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
type ResultMessage struct {
|
||||
MessageId string `json:"MessageId,omitempty" xml:"MessageId,omitempty"`
|
||||
ReceiptHandle string `json:"ReceiptHandle,omitempty" xml:"ReceiptHandle,omitempty"`
|
||||
MD5OfBody string `json:"MD5OfBody,omitempty" xml:"MD5OfBody,omitempty"`
|
||||
Body string `json:"Body,omitempty" xml:"Body,omitempty"`
|
||||
MD5OfMessageAttributes string `json:"MD5OfMessageAttributes,omitempty" xml:"MD5OfMessageAttributes,omitempty"`
|
||||
MessageAttributes map[string]MessageAttribute `json:"MessageAttributes,omitempty" xml:"MessageAttribute,omitempty,attr"`
|
||||
Attributes map[string]string `json:"Attributes,omitempty" xml:"Attribute,omitempty,attr"`
|
||||
}
|
||||
|
||||
// MarshalXML is a custom marshaler for the ResultMessage struct. We need it because we need to convert the
|
||||
// maps into something that can be shown as XML. If we ever get rid of the XML response parsing this can go,
|
||||
// and that would be glorious.
|
||||
func (r *ResultMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
||||
type Attributes struct {
|
||||
Name string `xml:"Name,omitempty"`
|
||||
Value string `xml:"Value,omitempty"`
|
||||
}
|
||||
var attrs []Attributes
|
||||
for key, value := range r.Attributes {
|
||||
attribute := Attributes{
|
||||
Name: key,
|
||||
Value: value,
|
||||
}
|
||||
attrs = append(attrs, attribute)
|
||||
}
|
||||
|
||||
type MessageAttributes struct {
|
||||
Name string `xml:"Name,omitempty"`
|
||||
Value MessageAttribute `xml:"Value,omitempty"`
|
||||
}
|
||||
var messageAttrs []MessageAttributes
|
||||
for key, value := range r.MessageAttributes {
|
||||
attribute := MessageAttributes{
|
||||
Name: key,
|
||||
Value: value,
|
||||
}
|
||||
messageAttrs = append(messageAttrs, attribute)
|
||||
}
|
||||
e.EncodeToken(start)
|
||||
|
||||
// Encode the fields
|
||||
e.EncodeElement(r.MessageId, xml.StartElement{Name: xml.Name{Local: "MessageId"}})
|
||||
e.EncodeElement(r.ReceiptHandle, xml.StartElement{Name: xml.Name{Local: "ReceiptHandle"}})
|
||||
e.EncodeElement(r.MD5OfBody, xml.StartElement{Name: xml.Name{Local: "MD5OfBody"}})
|
||||
e.EncodeElement(r.Body, xml.StartElement{Name: xml.Name{Local: "Body"}})
|
||||
e.EncodeElement(attrs, xml.StartElement{Name: xml.Name{Local: "Attribute"}})
|
||||
e.EncodeElement(messageAttrs, xml.StartElement{Name: xml.Name{Local: "MessageAttribute"}})
|
||||
e.EncodeToken(xml.EndElement{Name: start.Name})
|
||||
return nil
|
||||
}
|
||||
|
||||
type ChangeMessageVisibilityResult struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r ChangeMessageVisibilityResult) GetResult() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r ChangeMessageVisibilityResult) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Create Queue Response */
|
||||
type CreateQueueResult struct {
|
||||
QueueUrl string `json:"QueueUrl" xml:"QueueUrl"`
|
||||
}
|
||||
|
||||
type CreateQueueResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result CreateQueueResult `json:"CreateQueueResult" xml:"CreateQueueResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r CreateQueueResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r CreateQueueResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** List Queues Response */
|
||||
type ListQueuesResult struct {
|
||||
// NOTE: the old XML sdks depend on QueueUrl, and the new JSON ones need QueueUrls
|
||||
QueueUrls []string `json:"QueueUrls" xml:"QueueUrl"`
|
||||
}
|
||||
|
||||
type ListQueuesResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result ListQueuesResult `json:"ListQueuesResult" xml:"ListQueuesResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r ListQueuesResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r ListQueuesResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Get Queue QueueAttributes ***/
|
||||
type Attribute struct {
|
||||
Name string `json:"Name,omitempty" xml:"Name,omitempty"`
|
||||
Value string `json:"Value,omitempty" xml:"Value,omitempty"`
|
||||
}
|
||||
|
||||
type GetQueueAttributesResult struct {
|
||||
/* VisibilityTimeout, DelaySeconds, ReceiveMessageWaitTimeSeconds, ApproximateNumberOfMessages
|
||||
ApproximateNumberOfMessagesNotVisible, CreatedTimestamp, LastModifiedTimestamp, QueueArn */
|
||||
Attrs []Attribute `json:"Attributes,omitempty" xml:"Attribute,omitempty"`
|
||||
}
|
||||
|
||||
type GetQueueAttributesResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result GetQueueAttributesResult `json:"GetQueueAttributesResult" xml:"GetQueueAttributesResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r GetQueueAttributesResponse) GetResult() interface{} {
|
||||
result := map[string]string{}
|
||||
for _, attr := range r.Result.Attrs {
|
||||
result[attr.Name] = attr.Value
|
||||
}
|
||||
return map[string]map[string]string{"Attributes": result}
|
||||
}
|
||||
|
||||
func (r GetQueueAttributesResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Send Message Response */
|
||||
type SendMessageResult struct {
|
||||
MD5OfMessageAttributes string `json:"MD5OfMessageAttributes,omitempty" xml:"MD5OfMessageAttributes,omitempty"`
|
||||
MD5OfMessageBody string `json:"MD5OfMessageBody" xml:"MD5OfMessageBody"`
|
||||
MessageId string `json:"MessageId" xml:"MessageId"`
|
||||
SequenceNumber string `json:"SequenceNumber,omitempty" xml:"SequenceNumber,omitempty"`
|
||||
}
|
||||
|
||||
type SendMessageResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result SendMessageResult `json:"SendMessageResult" xml:"SendMessageResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r SendMessageResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r SendMessageResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Delete Message Response */
|
||||
type DeleteMessageResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r DeleteMessageResponse) GetResult() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r DeleteMessageResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Get Queue Url Response */
|
||||
type GetQueueUrlResult struct {
|
||||
QueueUrl string `json:"QueueUrl,omitempty" xml:"QueueUrl,omitempty"`
|
||||
}
|
||||
|
||||
type GetQueueUrlResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result GetQueueUrlResult `json:"GetQueueUrlResult" xml:"GetQueueUrlResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r GetQueueUrlResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r GetQueueUrlResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
type SendMessageBatchResultEntry struct {
|
||||
Id string `json:"Id" xml:"Id"`
|
||||
MessageId string `json:"MessageId" xml:"MessageId"`
|
||||
MD5OfMessageBody string `json:"MD5OfMessageBody,omitempty" xml:"MD5OfMessageBody,omitempty"`
|
||||
MD5OfMessageAttributes string `json:"MD5OfMessageAttributes,omitempty" xml:"MD5OfMessageAttributes,omitempty"`
|
||||
SequenceNumber string `json:"SequenceNumber" xml:"SequenceNumber"`
|
||||
}
|
||||
|
||||
/*** Send Message Batch Response */
|
||||
type SendMessageBatchResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result SendMessageBatchResult `json:"SendMessageBatchResult" xml:"SendMessageBatchResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
type SendMessageBatchResult struct {
|
||||
Entry []SendMessageBatchResultEntry `json:"SendMessageBatchResultEntry" xml:"SendMessageBatchResultEntry"`
|
||||
Error []BatchResultErrorEntry `json:"BatchResultErrorEntry,omitempty" xml:"BatchResultErrorEntry,omitempty"`
|
||||
}
|
||||
|
||||
func (r SendMessageBatchResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r SendMessageBatchResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
type BatchResultErrorEntry struct {
|
||||
Code string `json:"Code" xml:"Code"`
|
||||
Id string `json:"Id" xml:"Id"`
|
||||
Message string `json:"Message,omitempty" xml:"Message,omitempty"`
|
||||
SenderFault bool `json:"SenderFault" xml:"SenderFault"`
|
||||
}
|
||||
|
||||
type SetQueueAttributesResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r SetQueueAttributesResponse) GetResult() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r SetQueueAttributesResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Purge Queue Response */
|
||||
type PurgeQueueResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r PurgeQueueResponse) GetResult() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r PurgeQueueResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Delete Queue Response */
|
||||
type DeleteQueueResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r DeleteQueueResponse) GetResult() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r DeleteQueueResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
|
||||
/*** Delete Message Batch Response ***/
|
||||
type DeleteMessageBatchResultEntry struct {
|
||||
Id string `json:"Id" xml:"Id"`
|
||||
}
|
||||
|
||||
type DeleteMessageBatchResult struct {
|
||||
Successful []DeleteMessageBatchResultEntry `json:"DeleteMessageBatchResultEntry" xml:"DeleteMessageBatchResultEntry"`
|
||||
Failed []BatchResultErrorEntry `json:"BatchResultErrorEntry,omitempty" xml:"BatchResultErrorEntry,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteMessageBatchResponse struct {
|
||||
Xmlns string `json:"Xmlns" xml:"xmlns,attr"`
|
||||
Result DeleteMessageBatchResult `json:"DeleteMessageBatchResult" xml:"DeleteMessageBatchResult"`
|
||||
Metadata ResponseMetadata `json:"ResponseMetadata" xml:"ResponseMetadata"`
|
||||
}
|
||||
|
||||
func (r DeleteMessageBatchResponse) GetResult() interface{} {
|
||||
return r.Result
|
||||
}
|
||||
|
||||
func (r DeleteMessageBatchResponse) GetRequestId() string {
|
||||
return r.Metadata.RequestId
|
||||
}
|
||||
Reference in New Issue
Block a user