|
1
|
|
|
package sqs |
|
2
|
|
|
|
|
3
|
|
|
import ( |
|
4
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/sqs" |
|
5
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
|
6
|
|
|
) |
|
7
|
|
|
|
|
8
|
|
|
type BatchResultErrorEntry struct { |
|
|
|
|
|
|
9
|
|
|
Code string |
|
10
|
|
|
ID string |
|
11
|
|
|
SenderFault bool |
|
12
|
|
|
|
|
13
|
|
|
// optional |
|
14
|
|
|
Message string |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
func newBatchResultErrorEntryList(list []SDK.BatchResultErrorEntry) []BatchResultErrorEntry { |
|
18
|
|
|
if len(list) == 0 { |
|
19
|
|
|
return nil |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
results := make([]BatchResultErrorEntry, len(list)) |
|
23
|
|
|
for i, v := range list { |
|
24
|
|
|
results[i] = newBatchResultErrorEntry(v) |
|
25
|
|
|
} |
|
26
|
|
|
return results |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
func newBatchResultErrorEntry(o SDK.BatchResultErrorEntry) BatchResultErrorEntry { |
|
30
|
|
|
result := BatchResultErrorEntry{} |
|
31
|
|
|
|
|
32
|
|
|
if o.Code != nil { |
|
33
|
|
|
result.Code = *o.Code |
|
34
|
|
|
} |
|
35
|
|
|
if o.Id != nil { |
|
36
|
|
|
result.ID = *o.Id |
|
37
|
|
|
} |
|
38
|
|
|
if o.SenderFault != nil { |
|
39
|
|
|
result.SenderFault = *o.SenderFault |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if o.Message != nil { |
|
43
|
|
|
result.Message = *o.Message |
|
44
|
|
|
} |
|
45
|
|
|
return result |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
type ChangeMessageVisibilityBatchRequestEntry struct { |
|
|
|
|
|
|
49
|
|
|
ID string |
|
50
|
|
|
ReceiptHandle string |
|
51
|
|
|
|
|
52
|
|
|
// optional |
|
53
|
|
|
VisibilityTimeout int64 |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
func (r ChangeMessageVisibilityBatchRequestEntry) ToSDK() SDK.ChangeMessageVisibilityBatchRequestEntry { |
|
|
|
|
|
|
57
|
|
|
o := SDK.ChangeMessageVisibilityBatchRequestEntry{} |
|
58
|
|
|
|
|
59
|
|
|
if r.ID != "" { |
|
60
|
|
|
o.Id = pointers.String(r.ID) |
|
61
|
|
|
} |
|
62
|
|
|
if r.ReceiptHandle != "" { |
|
63
|
|
|
o.ReceiptHandle = pointers.String(r.ReceiptHandle) |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
o.VisibilityTimeout = pointers.Long64(r.VisibilityTimeout) |
|
67
|
|
|
return o |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
type ChangeMessageVisibilityBatchResultEntry struct { |
|
|
|
|
|
|
71
|
|
|
ID string |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
func newChangeMessageVisibilityBatchResultEntryList(list []SDK.ChangeMessageVisibilityBatchResultEntry) []ChangeMessageVisibilityBatchResultEntry { |
|
75
|
|
|
if len(list) == 0 { |
|
76
|
|
|
return nil |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
results := make([]ChangeMessageVisibilityBatchResultEntry, len(list)) |
|
80
|
|
|
for i, v := range list { |
|
81
|
|
|
results[i] = newChangeMessageVisibilityBatchResultEntry(v) |
|
82
|
|
|
} |
|
83
|
|
|
return results |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
func newChangeMessageVisibilityBatchResultEntry(o SDK.ChangeMessageVisibilityBatchResultEntry) ChangeMessageVisibilityBatchResultEntry { |
|
87
|
|
|
result := ChangeMessageVisibilityBatchResultEntry{} |
|
88
|
|
|
|
|
89
|
|
|
if o.Id != nil { |
|
90
|
|
|
result.ID = *o.Id |
|
91
|
|
|
} |
|
92
|
|
|
return result |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
type DeleteMessageBatchRequestEntry struct { |
|
|
|
|
|
|
96
|
|
|
ID string |
|
97
|
|
|
ReceiptHandle string |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
func (r DeleteMessageBatchRequestEntry) ToSDK() SDK.DeleteMessageBatchRequestEntry { |
|
|
|
|
|
|
101
|
|
|
o := SDK.DeleteMessageBatchRequestEntry{} |
|
102
|
|
|
|
|
103
|
|
|
if r.ID != "" { |
|
104
|
|
|
o.Id = pointers.String(r.ID) |
|
105
|
|
|
} |
|
106
|
|
|
if r.ReceiptHandle != "" { |
|
107
|
|
|
o.ReceiptHandle = pointers.String(r.ReceiptHandle) |
|
108
|
|
|
} |
|
109
|
|
|
return o |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
type DeleteMessageBatchResultEntry struct { |
|
|
|
|
|
|
113
|
|
|
ID string |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
func newDeleteMessageBatchResultEntryList(list []SDK.DeleteMessageBatchResultEntry) []DeleteMessageBatchResultEntry { |
|
117
|
|
|
if len(list) == 0 { |
|
118
|
|
|
return nil |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
results := make([]DeleteMessageBatchResultEntry, len(list)) |
|
122
|
|
|
for i, v := range list { |
|
123
|
|
|
results[i] = newDeleteMessageBatchResultEntry(v) |
|
124
|
|
|
} |
|
125
|
|
|
return results |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
func newDeleteMessageBatchResultEntry(o SDK.DeleteMessageBatchResultEntry) DeleteMessageBatchResultEntry { |
|
129
|
|
|
result := DeleteMessageBatchResultEntry{} |
|
130
|
|
|
|
|
131
|
|
|
if o.Id != nil { |
|
132
|
|
|
result.ID = *o.Id |
|
133
|
|
|
} |
|
134
|
|
|
return result |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
type Message struct { |
|
|
|
|
|
|
138
|
|
|
Attributes map[string]string |
|
139
|
|
|
Body string |
|
140
|
|
|
MD5OfBody string |
|
141
|
|
|
MD5OfMessageAttributes string |
|
142
|
|
|
MessageAttributes map[string]MessageAttributeValue |
|
143
|
|
|
MessageID string |
|
144
|
|
|
ReceiptHandle string |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
func newMessage(o SDK.Message) Message { |
|
148
|
|
|
result := Message{} |
|
149
|
|
|
|
|
150
|
|
|
result.Attributes = o.Attributes |
|
151
|
|
|
if o.Body != nil { |
|
152
|
|
|
result.Body = *o.Body |
|
153
|
|
|
} |
|
154
|
|
|
if o.MD5OfBody != nil { |
|
155
|
|
|
result.MD5OfBody = *o.MD5OfBody |
|
156
|
|
|
} |
|
157
|
|
|
if o.MD5OfMessageAttributes != nil { |
|
158
|
|
|
result.MD5OfMessageAttributes = *o.MD5OfMessageAttributes |
|
159
|
|
|
} |
|
160
|
|
|
result.MessageAttributes = newMessageAttributeValueMap(o.MessageAttributes) |
|
161
|
|
|
if o.MessageId != nil { |
|
162
|
|
|
result.MessageID = *o.MessageId |
|
163
|
|
|
} |
|
164
|
|
|
if o.ReceiptHandle != nil { |
|
165
|
|
|
result.ReceiptHandle = *o.ReceiptHandle |
|
166
|
|
|
} |
|
167
|
|
|
return result |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
type MessageAttributeValue struct { |
|
|
|
|
|
|
171
|
|
|
DataType string |
|
172
|
|
|
|
|
173
|
|
|
// optional |
|
174
|
|
|
BinaryValue []byte |
|
175
|
|
|
StringValue string |
|
176
|
|
|
|
|
177
|
|
|
// Not implemented. Reserved for future use. |
|
178
|
|
|
BinaryListValues [][]byte |
|
179
|
|
|
StringListValues []string |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
func newMessageAttributeValueMap(o map[string]SDK.MessageAttributeValue) map[string]MessageAttributeValue { |
|
183
|
|
|
if len(o) == 0 { |
|
184
|
|
|
return nil |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
m := make(map[string]MessageAttributeValue, len(o)) |
|
188
|
|
|
for key, val := range o { |
|
189
|
|
|
m[key] = newMessageAttributeValue(val) |
|
190
|
|
|
} |
|
191
|
|
|
return m |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
func newMessageAttributeValue(o SDK.MessageAttributeValue) MessageAttributeValue { |
|
195
|
|
|
result := MessageAttributeValue{} |
|
196
|
|
|
|
|
197
|
|
|
if o.DataType != nil { |
|
198
|
|
|
result.DataType = *o.DataType |
|
199
|
|
|
} |
|
200
|
|
|
result.BinaryValue = o.BinaryValue |
|
201
|
|
|
if o.StringValue != nil { |
|
202
|
|
|
result.StringValue = *o.StringValue |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
result.BinaryListValues = o.BinaryListValues |
|
206
|
|
|
result.StringListValues = o.StringListValues |
|
207
|
|
|
return result |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
func (r MessageAttributeValue) ToSDK() SDK.MessageAttributeValue { |
|
|
|
|
|
|
211
|
|
|
o := SDK.MessageAttributeValue{} |
|
212
|
|
|
|
|
213
|
|
|
if r.DataType != "" { |
|
214
|
|
|
o.DataType = pointers.String(r.DataType) |
|
215
|
|
|
} |
|
216
|
|
|
if len(r.BinaryValue) != 0 { |
|
217
|
|
|
o.BinaryValue = r.BinaryValue |
|
218
|
|
|
} |
|
219
|
|
|
if r.StringValue != "" { |
|
220
|
|
|
o.StringValue = pointers.String(r.StringValue) |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
if len(r.BinaryListValues) != 0 { |
|
224
|
|
|
o.BinaryListValues = r.BinaryListValues |
|
225
|
|
|
} |
|
226
|
|
|
if len(r.StringListValues) != 0 { |
|
227
|
|
|
o.StringListValues = r.StringListValues |
|
228
|
|
|
} |
|
229
|
|
|
return o |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
type MessageSystemAttributeValue struct { |
|
|
|
|
|
|
233
|
|
|
DataType string |
|
234
|
|
|
|
|
235
|
|
|
// optional |
|
236
|
|
|
BinaryValue []byte |
|
237
|
|
|
StringValue string |
|
238
|
|
|
|
|
239
|
|
|
// Not implemented. Reserved for future use. |
|
240
|
|
|
BinaryListValues [][]byte |
|
241
|
|
|
StringListValues []string |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
func newMessageSystemAttributeValueMap(o map[string]SDK.MessageSystemAttributeValue) map[string]MessageSystemAttributeValue { |
|
245
|
|
|
if len(o) == 0 { |
|
246
|
|
|
return nil |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
m := make(map[string]MessageSystemAttributeValue, len(o)) |
|
250
|
|
|
for key, val := range o { |
|
251
|
|
|
m[key] = newMessageSystemAttributeValue(val) |
|
252
|
|
|
} |
|
253
|
|
|
return m |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
func newMessageSystemAttributeValue(o SDK.MessageSystemAttributeValue) MessageSystemAttributeValue { |
|
257
|
|
|
result := MessageSystemAttributeValue{} |
|
258
|
|
|
|
|
259
|
|
|
if o.DataType != nil { |
|
260
|
|
|
result.DataType = *o.DataType |
|
261
|
|
|
} |
|
262
|
|
|
result.BinaryValue = o.BinaryValue |
|
263
|
|
|
if o.StringValue != nil { |
|
264
|
|
|
result.StringValue = *o.StringValue |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
result.BinaryListValues = o.BinaryListValues |
|
268
|
|
|
result.StringListValues = o.StringListValues |
|
269
|
|
|
return result |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
func (r MessageSystemAttributeValue) ToSDK() SDK.MessageSystemAttributeValue { |
|
|
|
|
|
|
273
|
|
|
o := SDK.MessageSystemAttributeValue{} |
|
274
|
|
|
|
|
275
|
|
|
if r.DataType != "" { |
|
276
|
|
|
o.DataType = pointers.String(r.DataType) |
|
277
|
|
|
} |
|
278
|
|
|
if len(r.BinaryValue) != 0 { |
|
279
|
|
|
o.BinaryValue = r.BinaryValue |
|
280
|
|
|
} |
|
281
|
|
|
if r.StringValue != "" { |
|
282
|
|
|
o.StringValue = pointers.String(r.StringValue) |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
if len(r.BinaryListValues) != 0 { |
|
286
|
|
|
o.BinaryListValues = r.BinaryListValues |
|
287
|
|
|
} |
|
288
|
|
|
if len(r.StringListValues) != 0 { |
|
289
|
|
|
o.StringListValues = r.StringListValues |
|
290
|
|
|
} |
|
291
|
|
|
return o |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
type SendMessageBatchResultEntry struct { |
|
|
|
|
|
|
295
|
|
|
ID string |
|
296
|
|
|
MD5OfMessageBody string |
|
297
|
|
|
MessageID string |
|
298
|
|
|
|
|
299
|
|
|
// for FIFO |
|
300
|
|
|
SequenceNumber string |
|
301
|
|
|
|
|
302
|
|
|
MD5OfMessageAttributes string |
|
303
|
|
|
MD5OfMessageSystemAttributes string |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
func newSendMessageBatchResultEntryList(list []SDK.SendMessageBatchResultEntry) []SendMessageBatchResultEntry { |
|
307
|
|
|
if len(list) == 0 { |
|
308
|
|
|
return nil |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
results := make([]SendMessageBatchResultEntry, len(list)) |
|
312
|
|
|
for i, v := range list { |
|
313
|
|
|
results[i] = newSendMessageBatchResultEntry(v) |
|
314
|
|
|
} |
|
315
|
|
|
return results |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
func newSendMessageBatchResultEntry(o SDK.SendMessageBatchResultEntry) SendMessageBatchResultEntry { |
|
319
|
|
|
result := SendMessageBatchResultEntry{} |
|
320
|
|
|
|
|
321
|
|
|
if o.Id != nil { |
|
322
|
|
|
result.ID = *o.Id |
|
323
|
|
|
} |
|
324
|
|
|
if o.MD5OfMessageBody != nil { |
|
325
|
|
|
result.MD5OfMessageBody = *o.MD5OfMessageBody |
|
326
|
|
|
} |
|
327
|
|
|
if o.MessageId != nil { |
|
328
|
|
|
result.MessageID = *o.MessageId |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
if o.SequenceNumber != nil { |
|
332
|
|
|
result.SequenceNumber = *o.SequenceNumber |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
if o.MD5OfMessageAttributes != nil { |
|
336
|
|
|
result.MD5OfMessageAttributes = *o.MD5OfMessageAttributes |
|
337
|
|
|
} |
|
338
|
|
|
if o.MD5OfMessageSystemAttributes != nil { |
|
339
|
|
|
result.MD5OfMessageSystemAttributes = *o.MD5OfMessageSystemAttributes |
|
340
|
|
|
} |
|
341
|
|
|
return result |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
type SendMessageBatchRequestEntry struct { |
|
|
|
|
|
|
345
|
|
|
ID string |
|
346
|
|
|
MessageBody string |
|
347
|
|
|
|
|
348
|
|
|
// for FIFO |
|
349
|
|
|
MessageDeduplicationID string |
|
350
|
|
|
MessageGroupID string |
|
351
|
|
|
|
|
352
|
|
|
DelaySeconds int64 |
|
353
|
|
|
MessageAttributes map[string]MessageAttributeValue |
|
354
|
|
|
MessageSystemAttributes map[string]MessageSystemAttributeValue |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
func (r SendMessageBatchRequestEntry) ToSDK() SDK.SendMessageBatchRequestEntry { |
|
|
|
|
|
|
358
|
|
|
o := SDK.SendMessageBatchRequestEntry{} |
|
359
|
|
|
|
|
360
|
|
|
if r.ID != "" { |
|
361
|
|
|
o.Id = pointers.String(r.ID) |
|
362
|
|
|
} |
|
363
|
|
|
if r.MessageBody != "" { |
|
364
|
|
|
o.MessageBody = pointers.String(r.MessageBody) |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
if r.MessageDeduplicationID != "" { |
|
368
|
|
|
o.MessageDeduplicationId = pointers.String(r.MessageDeduplicationID) |
|
369
|
|
|
} |
|
370
|
|
|
if r.MessageGroupID != "" { |
|
371
|
|
|
o.MessageGroupId = pointers.String(r.MessageGroupID) |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
if r.DelaySeconds != 0 { |
|
375
|
|
|
o.DelaySeconds = pointers.Long64(r.DelaySeconds) |
|
376
|
|
|
} |
|
377
|
|
|
r.MessageAttributes = newMessageAttributeValueMap(o.MessageAttributes) |
|
378
|
|
|
r.MessageSystemAttributes = newMessageSystemAttributeValueMap(o.MessageSystemAttributes) |
|
379
|
|
|
return o |
|
380
|
|
|
} |
|
381
|
|
|
|