Passed
Push — master ( 9acbae...8ba3ae )
by eval
03:10 queued 01:28
created

sqs.MessageSystemAttributeValue.ToSDK   B

Complexity

Conditions 6

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 13
nop 0
dl 0
loc 20
rs 8.6666
c 0
b 0
f 0
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 {
0 ignored issues
show
introduced by
exported type BatchResultErrorEntry should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type ChangeMessageVisibilityBatchRequestEntry should have comment or be unexported
Loading history...
49
	ID            string
50
	ReceiptHandle string
51
52
	// optional
53
	VisibilityTimeout int64
54
}
55
56
func (r ChangeMessageVisibilityBatchRequestEntry) ToSDK() SDK.ChangeMessageVisibilityBatchRequestEntry {
0 ignored issues
show
introduced by
exported method ChangeMessageVisibilityBatchRequestEntry.ToSDK should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type ChangeMessageVisibilityBatchResultEntry should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type DeleteMessageBatchRequestEntry should have comment or be unexported
Loading history...
96
	ID            string
97
	ReceiptHandle string
98
}
99
100
func (r DeleteMessageBatchRequestEntry) ToSDK() SDK.DeleteMessageBatchRequestEntry {
0 ignored issues
show
introduced by
exported method DeleteMessageBatchRequestEntry.ToSDK should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type DeleteMessageBatchResultEntry should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type Message should have comment or be unexported
Loading history...
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 newMessageList(list []SDK.Message) []Message {
148
	if len(list) == 0 {
149
		return nil
150
	}
151
152
	results := make([]Message, len(list))
153
	for i, v := range list {
154
		results[i] = newMessage(v)
155
	}
156
	return results
157
}
158
159
func newMessage(o SDK.Message) Message {
160
	result := Message{}
161
162
	result.Attributes = o.Attributes
163
	if o.Body != nil {
164
		result.Body = *o.Body
165
	}
166
	if o.MD5OfBody != nil {
167
		result.MD5OfBody = *o.MD5OfBody
168
	}
169
	if o.MD5OfMessageAttributes != nil {
170
		result.MD5OfMessageAttributes = *o.MD5OfMessageAttributes
171
	}
172
	result.MessageAttributes = newMessageAttributeValueMap(o.MessageAttributes)
173
	if o.MessageId != nil {
174
		result.MessageID = *o.MessageId
175
	}
176
	if o.ReceiptHandle != nil {
177
		result.ReceiptHandle = *o.ReceiptHandle
178
	}
179
	return result
180
}
181
182
type MessageAttributeValue struct {
0 ignored issues
show
introduced by
exported type MessageAttributeValue should have comment or be unexported
Loading history...
183
	DataType string
184
185
	// optional
186
	BinaryValue []byte
187
	StringValue string
188
189
	// Not implemented. Reserved for future use.
190
	BinaryListValues [][]byte
191
	StringListValues []string
192
}
193
194
func newMessageAttributeValueMap(o map[string]SDK.MessageAttributeValue) map[string]MessageAttributeValue {
195
	if len(o) == 0 {
196
		return nil
197
	}
198
199
	m := make(map[string]MessageAttributeValue, len(o))
200
	for key, val := range o {
201
		m[key] = newMessageAttributeValue(val)
202
	}
203
	return m
204
}
205
206
func newMessageAttributeValue(o SDK.MessageAttributeValue) MessageAttributeValue {
207
	result := MessageAttributeValue{}
208
209
	if o.DataType != nil {
210
		result.DataType = *o.DataType
211
	}
212
	result.BinaryValue = o.BinaryValue
213
	if o.StringValue != nil {
214
		result.StringValue = *o.StringValue
215
	}
216
217
	result.BinaryListValues = o.BinaryListValues
218
	result.StringListValues = o.StringListValues
219
	return result
220
}
221
222
func (r MessageAttributeValue) ToSDK() SDK.MessageAttributeValue {
0 ignored issues
show
introduced by
exported method MessageAttributeValue.ToSDK should have comment or be unexported
Loading history...
223
	o := SDK.MessageAttributeValue{}
224
225
	if r.DataType != "" {
226
		o.DataType = pointers.String(r.DataType)
227
	}
228
	if len(r.BinaryValue) != 0 {
229
		o.BinaryValue = r.BinaryValue
230
	}
231
	if r.StringValue != "" {
232
		o.StringValue = pointers.String(r.StringValue)
233
	}
234
235
	if len(r.BinaryListValues) != 0 {
236
		o.BinaryListValues = r.BinaryListValues
237
	}
238
	if len(r.StringListValues) != 0 {
239
		o.StringListValues = r.StringListValues
240
	}
241
	return o
242
}
243
244
type MessageSystemAttributeValue struct {
0 ignored issues
show
introduced by
exported type MessageSystemAttributeValue should have comment or be unexported
Loading history...
245
	DataType string
246
247
	// optional
248
	BinaryValue []byte
249
	StringValue string
250
251
	// Not implemented. Reserved for future use.
252
	BinaryListValues [][]byte
253
	StringListValues []string
254
}
255
256
func newMessageSystemAttributeValueMap(o map[string]SDK.MessageSystemAttributeValue) map[string]MessageSystemAttributeValue {
257
	if len(o) == 0 {
258
		return nil
259
	}
260
261
	m := make(map[string]MessageSystemAttributeValue, len(o))
262
	for key, val := range o {
263
		m[key] = newMessageSystemAttributeValue(val)
264
	}
265
	return m
266
}
267
268
func newMessageSystemAttributeValue(o SDK.MessageSystemAttributeValue) MessageSystemAttributeValue {
269
	result := MessageSystemAttributeValue{}
270
271
	if o.DataType != nil {
272
		result.DataType = *o.DataType
273
	}
274
	result.BinaryValue = o.BinaryValue
275
	if o.StringValue != nil {
276
		result.StringValue = *o.StringValue
277
	}
278
279
	result.BinaryListValues = o.BinaryListValues
280
	result.StringListValues = o.StringListValues
281
	return result
282
}
283
284
func (r MessageSystemAttributeValue) ToSDK() SDK.MessageSystemAttributeValue {
0 ignored issues
show
introduced by
exported method MessageSystemAttributeValue.ToSDK should have comment or be unexported
Loading history...
285
	o := SDK.MessageSystemAttributeValue{}
286
287
	if r.DataType != "" {
288
		o.DataType = pointers.String(r.DataType)
289
	}
290
	if len(r.BinaryValue) != 0 {
291
		o.BinaryValue = r.BinaryValue
292
	}
293
	if r.StringValue != "" {
294
		o.StringValue = pointers.String(r.StringValue)
295
	}
296
297
	if len(r.BinaryListValues) != 0 {
298
		o.BinaryListValues = r.BinaryListValues
299
	}
300
	if len(r.StringListValues) != 0 {
301
		o.StringListValues = r.StringListValues
302
	}
303
	return o
304
}
305
306
type SendMessageBatchResultEntry struct {
0 ignored issues
show
introduced by
exported type SendMessageBatchResultEntry should have comment or be unexported
Loading history...
307
	ID               string
308
	MD5OfMessageBody string
309
	MessageID        string
310
311
	// for FIFO
312
	SequenceNumber string
313
314
	MD5OfMessageAttributes       string
315
	MD5OfMessageSystemAttributes string
316
}
317
318
func newSendMessageBatchResultEntryList(list []SDK.SendMessageBatchResultEntry) []SendMessageBatchResultEntry {
319
	if len(list) == 0 {
320
		return nil
321
	}
322
323
	results := make([]SendMessageBatchResultEntry, len(list))
324
	for i, v := range list {
325
		results[i] = newSendMessageBatchResultEntry(v)
326
	}
327
	return results
328
}
329
330
func newSendMessageBatchResultEntry(o SDK.SendMessageBatchResultEntry) SendMessageBatchResultEntry {
331
	result := SendMessageBatchResultEntry{}
332
333
	if o.Id != nil {
334
		result.ID = *o.Id
335
	}
336
	if o.MD5OfMessageBody != nil {
337
		result.MD5OfMessageBody = *o.MD5OfMessageBody
338
	}
339
	if o.MessageId != nil {
340
		result.MessageID = *o.MessageId
341
	}
342
343
	if o.SequenceNumber != nil {
344
		result.SequenceNumber = *o.SequenceNumber
345
	}
346
347
	if o.MD5OfMessageAttributes != nil {
348
		result.MD5OfMessageAttributes = *o.MD5OfMessageAttributes
349
	}
350
	if o.MD5OfMessageSystemAttributes != nil {
351
		result.MD5OfMessageSystemAttributes = *o.MD5OfMessageSystemAttributes
352
	}
353
	return result
354
}
355
356
type SendMessageBatchRequestEntry struct {
0 ignored issues
show
introduced by
exported type SendMessageBatchRequestEntry should have comment or be unexported
Loading history...
357
	ID          string
358
	MessageBody string
359
360
	// for FIFO
361
	MessageDeduplicationID string
362
	MessageGroupID         string
363
364
	DelaySeconds            int64
365
	MessageAttributes       map[string]MessageAttributeValue
366
	MessageSystemAttributes map[string]MessageSystemAttributeValue
367
}
368
369
func (r SendMessageBatchRequestEntry) ToSDK() SDK.SendMessageBatchRequestEntry {
0 ignored issues
show
introduced by
exported method SendMessageBatchRequestEntry.ToSDK should have comment or be unexported
Loading history...
370
	o := SDK.SendMessageBatchRequestEntry{}
371
372
	if r.ID != "" {
373
		o.Id = pointers.String(r.ID)
374
	}
375
	if r.MessageBody != "" {
376
		o.MessageBody = pointers.String(r.MessageBody)
377
	}
378
379
	if r.MessageDeduplicationID != "" {
380
		o.MessageDeduplicationId = pointers.String(r.MessageDeduplicationID)
381
	}
382
	if r.MessageGroupID != "" {
383
		o.MessageGroupId = pointers.String(r.MessageGroupID)
384
	}
385
386
	if r.DelaySeconds != 0 {
387
		o.DelaySeconds = pointers.Long64(r.DelaySeconds)
388
	}
389
	r.MessageAttributes = newMessageAttributeValueMap(o.MessageAttributes)
390
	r.MessageSystemAttributes = newMessageSystemAttributeValueMap(o.MessageSystemAttributes)
391
	return o
392
}
393