forked from aws/aws-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
5591 lines (5076 loc) · 233 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Package dynamodb provides a client for Amazon DynamoDB.
package dynamodb
import (
"time"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/aws/request"
)
const opBatchGetItem = "BatchGetItem"
// BatchGetItemRequest generates a request for the BatchGetItem operation.
func (c *DynamoDB) BatchGetItemRequest(input *BatchGetItemInput) (req *request.Request, output *BatchGetItemOutput) {
op := &request.Operation{
Name: opBatchGetItem,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"RequestItems"},
OutputTokens: []string{"UnprocessedKeys"},
LimitToken: "",
TruncationToken: "",
},
}
if input == nil {
input = &BatchGetItemInput{}
}
req = c.newRequest(op, input, output)
output = &BatchGetItemOutput{}
req.Data = output
return
}
// The BatchGetItem operation returns the attributes of one or more items from
// one or more tables. You identify requested items by primary key.
//
// A single operation can retrieve up to 16 MB of data, which can contain as
// many as 100 items. BatchGetItem will return a partial result if the response
// size limit is exceeded, the table's provisioned throughput is exceeded, or
// an internal processing failure occurs. If a partial result is returned, the
// operation returns a value for UnprocessedKeys. You can use this value to
// retry the operation starting with the next item to get.
//
// If you request more than 100 items BatchGetItem will return a ValidationException
// with the message "Too many items requested for the BatchGetItem call".
//
// For example, if you ask to retrieve 100 items, but each individual item
// is 300 KB in size, the system returns 52 items (so as not to exceed the 16
// MB limit). It also returns an appropriate UnprocessedKeys value so you can
// get the next page of results. If desired, your application can include its
// own logic to assemble the pages of results into one data set.
//
// If none of the items can be processed due to insufficient provisioned throughput
// on all of the tables in the request, then BatchGetItem will return a ProvisionedThroughputExceededException.
// If at least one of the items is successfully processed, then BatchGetItem
// completes successfully, while returning the keys of the unread items in UnprocessedKeys.
//
// If DynamoDB returns any unprocessed items, you should retry the batch operation
// on those items. However, we strongly recommend that you use an exponential
// backoff algorithm. If you retry the batch operation immediately, the underlying
// read or write requests can still fail due to throttling on the individual
// tables. If you delay the batch operation using exponential backoff, the individual
// requests in the batch are much more likely to succeed.
//
// For more information, see Batch Operations and Error Handling (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations)
// in the Amazon DynamoDB Developer Guide.
//
// By default, BatchGetItem performs eventually consistent reads on every
// table in the request. If you want strongly consistent reads instead, you
// can set ConsistentRead to true for any or all tables.
//
// In order to minimize response latency, BatchGetItem retrieves items in parallel.
//
// When designing your application, keep in mind that DynamoDB does not return
// attributes in any particular order. To help parse the response by item, include
// the primary key values for the items in your request in the AttributesToGet
// parameter.
//
// If a requested item does not exist, it is not returned in the result. Requests
// for nonexistent items consume the minimum read capacity units according to
// the type of read. For more information, see Capacity Units Calculations (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations)
// in the Amazon DynamoDB Developer Guide.
func (c *DynamoDB) BatchGetItem(input *BatchGetItemInput) (*BatchGetItemOutput, error) {
req, out := c.BatchGetItemRequest(input)
err := req.Send()
return out, err
}
func (c *DynamoDB) BatchGetItemPages(input *BatchGetItemInput, fn func(p *BatchGetItemOutput, lastPage bool) (shouldContinue bool)) error {
page, _ := c.BatchGetItemRequest(input)
return page.EachPage(func(p interface{}, lastPage bool) bool {
return fn(p.(*BatchGetItemOutput), lastPage)
})
}
const opBatchWriteItem = "BatchWriteItem"
// BatchWriteItemRequest generates a request for the BatchWriteItem operation.
func (c *DynamoDB) BatchWriteItemRequest(input *BatchWriteItemInput) (req *request.Request, output *BatchWriteItemOutput) {
op := &request.Operation{
Name: opBatchWriteItem,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &BatchWriteItemInput{}
}
req = c.newRequest(op, input, output)
output = &BatchWriteItemOutput{}
req.Data = output
return
}
// The BatchWriteItem operation puts or deletes multiple items in one or more
// tables. A single call to BatchWriteItem can write up to 16 MB of data, which
// can comprise as many as 25 put or delete requests. Individual items to be
// written can be as large as 400 KB.
//
// BatchWriteItem cannot update items. To update items, use the UpdateItem
// API.
//
// The individual PutItem and DeleteItem operations specified in BatchWriteItem
// are atomic; however BatchWriteItem as a whole is not. If any requested operations
// fail because the table's provisioned throughput is exceeded or an internal
// processing failure occurs, the failed operations are returned in the UnprocessedItems
// response parameter. You can investigate and optionally resend the requests.
// Typically, you would call BatchWriteItem in a loop. Each iteration would
// check for unprocessed items and submit a new BatchWriteItem request with
// those unprocessed items until all items have been processed.
//
// Note that if none of the items can be processed due to insufficient provisioned
// throughput on all of the tables in the request, then BatchWriteItem will
// return a ProvisionedThroughputExceededException.
//
// If DynamoDB returns any unprocessed items, you should retry the batch operation
// on those items. However, we strongly recommend that you use an exponential
// backoff algorithm. If you retry the batch operation immediately, the underlying
// read or write requests can still fail due to throttling on the individual
// tables. If you delay the batch operation using exponential backoff, the individual
// requests in the batch are much more likely to succeed.
//
// For more information, see Batch Operations and Error Handling (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations)
// in the Amazon DynamoDB Developer Guide.
//
// With BatchWriteItem, you can efficiently write or delete large amounts
// of data, such as from Amazon Elastic MapReduce (EMR), or copy data from another
// database into DynamoDB. In order to improve performance with these large-scale
// operations, BatchWriteItem does not behave in the same way as individual
// PutItem and DeleteItem calls would. For example, you cannot specify conditions
// on individual put and delete requests, and BatchWriteItem does not return
// deleted items in the response.
//
// If you use a programming language that supports concurrency, you can use
// threads to write items in parallel. Your application must include the necessary
// logic to manage the threads. With languages that don't support threading,
// you must update or delete the specified items one at a time. In both situations,
// BatchWriteItem provides an alternative where the API performs the specified
// put and delete operations in parallel, giving you the power of the thread
// pool approach without having to introduce complexity into your application.
//
// Parallel processing reduces latency, but each specified put and delete request
// consumes the same number of write capacity units whether it is processed
// in parallel or not. Delete operations on nonexistent items consume one write
// capacity unit.
//
// If one or more of the following is true, DynamoDB rejects the entire batch
// write operation:
//
// One or more tables specified in the BatchWriteItem request does not exist.
//
// Primary key attributes specified on an item in the request do not match
// those in the corresponding table's primary key schema.
//
// You try to perform multiple operations on the same item in the same BatchWriteItem
// request. For example, you cannot put and delete the same item in the same
// BatchWriteItem request.
//
// There are more than 25 requests in the batch.
//
// Any individual item in a batch exceeds 400 KB.
//
// The total request size exceeds 16 MB.
func (c *DynamoDB) BatchWriteItem(input *BatchWriteItemInput) (*BatchWriteItemOutput, error) {
req, out := c.BatchWriteItemRequest(input)
err := req.Send()
return out, err
}
const opCreateTable = "CreateTable"
// CreateTableRequest generates a request for the CreateTable operation.
func (c *DynamoDB) CreateTableRequest(input *CreateTableInput) (req *request.Request, output *CreateTableOutput) {
op := &request.Operation{
Name: opCreateTable,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &CreateTableInput{}
}
req = c.newRequest(op, input, output)
output = &CreateTableOutput{}
req.Data = output
return
}
// The CreateTable operation adds a new table to your account. In an AWS account,
// table names must be unique within each region. That is, you can have two
// tables with same name if you create the tables in different regions.
//
// CreateTable is an asynchronous operation. Upon receiving a CreateTable request,
// DynamoDB immediately returns a response with a TableStatus of CREATING. After
// the table is created, DynamoDB sets the TableStatus to ACTIVE. You can perform
// read and write operations only on an ACTIVE table.
//
// You can optionally define secondary indexes on the new table, as part of
// the CreateTable operation. If you want to create multiple tables with secondary
// indexes on them, you must create the tables sequentially. Only one table
// with secondary indexes can be in the CREATING state at any given time.
//
// You can use the DescribeTable API to check the table status.
func (c *DynamoDB) CreateTable(input *CreateTableInput) (*CreateTableOutput, error) {
req, out := c.CreateTableRequest(input)
err := req.Send()
return out, err
}
const opDeleteItem = "DeleteItem"
// DeleteItemRequest generates a request for the DeleteItem operation.
func (c *DynamoDB) DeleteItemRequest(input *DeleteItemInput) (req *request.Request, output *DeleteItemOutput) {
op := &request.Operation{
Name: opDeleteItem,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &DeleteItemInput{}
}
req = c.newRequest(op, input, output)
output = &DeleteItemOutput{}
req.Data = output
return
}
// Deletes a single item in a table by primary key. You can perform a conditional
// delete operation that deletes the item if it exists, or if it has an expected
// attribute value.
//
// In addition to deleting an item, you can also return the item's attribute
// values in the same operation, using the ReturnValues parameter.
//
// Unless you specify conditions, the DeleteItem is an idempotent operation;
// running it multiple times on the same item or attribute does not result in
// an error response.
//
// Conditional deletes are useful for deleting items only if specific conditions
// are met. If those conditions are met, DynamoDB performs the delete. Otherwise,
// the item is not deleted.
func (c *DynamoDB) DeleteItem(input *DeleteItemInput) (*DeleteItemOutput, error) {
req, out := c.DeleteItemRequest(input)
err := req.Send()
return out, err
}
const opDeleteTable = "DeleteTable"
// DeleteTableRequest generates a request for the DeleteTable operation.
func (c *DynamoDB) DeleteTableRequest(input *DeleteTableInput) (req *request.Request, output *DeleteTableOutput) {
op := &request.Operation{
Name: opDeleteTable,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &DeleteTableInput{}
}
req = c.newRequest(op, input, output)
output = &DeleteTableOutput{}
req.Data = output
return
}
// The DeleteTable operation deletes a table and all of its items. After a DeleteTable
// request, the specified table is in the DELETING state until DynamoDB completes
// the deletion. If the table is in the ACTIVE state, you can delete it. If
// a table is in CREATING or UPDATING states, then DynamoDB returns a ResourceInUseException.
// If the specified table does not exist, DynamoDB returns a ResourceNotFoundException.
// If table is already in the DELETING state, no error is returned.
//
// DynamoDB might continue to accept data read and write operations, such
// as GetItem and PutItem, on a table in the DELETING state until the table
// deletion is complete.
//
// When you delete a table, any indexes on that table are also deleted.
//
// If you have DynamoDB Streams enabled on the table, then the corresponding
// stream on that table goes into the DISABLED state, and the stream is automatically
// deleted after 24 hours.
//
// Use the DescribeTable API to check the status of the table.
func (c *DynamoDB) DeleteTable(input *DeleteTableInput) (*DeleteTableOutput, error) {
req, out := c.DeleteTableRequest(input)
err := req.Send()
return out, err
}
const opDescribeTable = "DescribeTable"
// DescribeTableRequest generates a request for the DescribeTable operation.
func (c *DynamoDB) DescribeTableRequest(input *DescribeTableInput) (req *request.Request, output *DescribeTableOutput) {
op := &request.Operation{
Name: opDescribeTable,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &DescribeTableInput{}
}
req = c.newRequest(op, input, output)
output = &DescribeTableOutput{}
req.Data = output
return
}
// Returns information about the table, including the current status of the
// table, when it was created, the primary key schema, and any indexes on the
// table.
//
// If you issue a DescribeTable request immediately after a CreateTable request,
// DynamoDB might return a ResourceNotFoundException. This is because DescribeTable
// uses an eventually consistent query, and the metadata for your table might
// not be available at that moment. Wait for a few seconds, and then try the
// DescribeTable request again.
func (c *DynamoDB) DescribeTable(input *DescribeTableInput) (*DescribeTableOutput, error) {
req, out := c.DescribeTableRequest(input)
err := req.Send()
return out, err
}
const opGetItem = "GetItem"
// GetItemRequest generates a request for the GetItem operation.
func (c *DynamoDB) GetItemRequest(input *GetItemInput) (req *request.Request, output *GetItemOutput) {
op := &request.Operation{
Name: opGetItem,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &GetItemInput{}
}
req = c.newRequest(op, input, output)
output = &GetItemOutput{}
req.Data = output
return
}
// The GetItem operation returns a set of attributes for the item with the given
// primary key. If there is no matching item, GetItem does not return any data.
//
// GetItem provides an eventually consistent read by default. If your application
// requires a strongly consistent read, set ConsistentRead to true. Although
// a strongly consistent read might take more time than an eventually consistent
// read, it always returns the last updated value.
func (c *DynamoDB) GetItem(input *GetItemInput) (*GetItemOutput, error) {
req, out := c.GetItemRequest(input)
err := req.Send()
return out, err
}
const opListTables = "ListTables"
// ListTablesRequest generates a request for the ListTables operation.
func (c *DynamoDB) ListTablesRequest(input *ListTablesInput) (req *request.Request, output *ListTablesOutput) {
op := &request.Operation{
Name: opListTables,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"ExclusiveStartTableName"},
OutputTokens: []string{"LastEvaluatedTableName"},
LimitToken: "Limit",
TruncationToken: "",
},
}
if input == nil {
input = &ListTablesInput{}
}
req = c.newRequest(op, input, output)
output = &ListTablesOutput{}
req.Data = output
return
}
// Returns an array of table names associated with the current account and endpoint.
// The output from ListTables is paginated, with each page returning a maximum
// of 100 table names.
func (c *DynamoDB) ListTables(input *ListTablesInput) (*ListTablesOutput, error) {
req, out := c.ListTablesRequest(input)
err := req.Send()
return out, err
}
func (c *DynamoDB) ListTablesPages(input *ListTablesInput, fn func(p *ListTablesOutput, lastPage bool) (shouldContinue bool)) error {
page, _ := c.ListTablesRequest(input)
return page.EachPage(func(p interface{}, lastPage bool) bool {
return fn(p.(*ListTablesOutput), lastPage)
})
}
const opPutItem = "PutItem"
// PutItemRequest generates a request for the PutItem operation.
func (c *DynamoDB) PutItemRequest(input *PutItemInput) (req *request.Request, output *PutItemOutput) {
op := &request.Operation{
Name: opPutItem,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &PutItemInput{}
}
req = c.newRequest(op, input, output)
output = &PutItemOutput{}
req.Data = output
return
}
// Creates a new item, or replaces an old item with a new item. If an item that
// has the same primary key as the new item already exists in the specified
// table, the new item completely replaces the existing item. You can perform
// a conditional put operation (add a new item if one with the specified primary
// key doesn't exist), or replace an existing item if it has certain attribute
// values.
//
// In addition to putting an item, you can also return the item's attribute
// values in the same operation, using the ReturnValues parameter.
//
// When you add an item, the primary key attribute(s) are the only required
// attributes. Attribute values cannot be null. String and Binary type attributes
// must have lengths greater than zero. Set type attributes cannot be empty.
// Requests with empty values will be rejected with a ValidationException exception.
//
// You can request that PutItem return either a copy of the original item (before
// the update) or a copy of the updated item (after the update). For more information,
// see the ReturnValues description below.
//
// To prevent a new item from replacing an existing item, use a conditional
// put operation with ComparisonOperator set to NULL for the primary key attribute,
// or attributes.
//
// For more information about using this API, see Working with Items (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html)
// in the Amazon DynamoDB Developer Guide.
func (c *DynamoDB) PutItem(input *PutItemInput) (*PutItemOutput, error) {
req, out := c.PutItemRequest(input)
err := req.Send()
return out, err
}
const opQuery = "Query"
// QueryRequest generates a request for the Query operation.
func (c *DynamoDB) QueryRequest(input *QueryInput) (req *request.Request, output *QueryOutput) {
op := &request.Operation{
Name: opQuery,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"ExclusiveStartKey"},
OutputTokens: []string{"LastEvaluatedKey"},
LimitToken: "Limit",
TruncationToken: "",
},
}
if input == nil {
input = &QueryInput{}
}
req = c.newRequest(op, input, output)
output = &QueryOutput{}
req.Data = output
return
}
// A Query operation uses the primary key of a table or a secondary index to
// directly access items from that table or index.
//
// Use the KeyConditionExpression parameter to provide a specific hash key
// value. The Query operation will return all of the items from the table or
// index with that hash key value. You can optionally narrow the scope of the
// Query operation by specifying a range key value and a comparison operator
// in KeyConditionExpression. You can use the ScanIndexForward parameter to
// get results in forward or reverse order, by range key or by index key.
//
// Queries that do not return results consume the minimum number of read capacity
// units for that type of read operation.
//
// If the total number of items meeting the query criteria exceeds the result
// set size limit of 1 MB, the query stops and results are returned to the user
// with the LastEvaluatedKey element to continue the query in a subsequent operation.
// Unlike a Scan operation, a Query operation never returns both an empty result
// set and a LastEvaluatedKey value. LastEvaluatedKey is only provided if the
// results exceed 1 MB, or if you have used the Limit parameter.
//
// You can query a table, a local secondary index, or a global secondary index.
// For a query on a table or on a local secondary index, you can set the ConsistentRead
// parameter to true and obtain a strongly consistent result. Global secondary
// indexes support eventually consistent reads only, so do not specify ConsistentRead
// when querying a global secondary index.
func (c *DynamoDB) Query(input *QueryInput) (*QueryOutput, error) {
req, out := c.QueryRequest(input)
err := req.Send()
return out, err
}
func (c *DynamoDB) QueryPages(input *QueryInput, fn func(p *QueryOutput, lastPage bool) (shouldContinue bool)) error {
page, _ := c.QueryRequest(input)
return page.EachPage(func(p interface{}, lastPage bool) bool {
return fn(p.(*QueryOutput), lastPage)
})
}
const opScan = "Scan"
// ScanRequest generates a request for the Scan operation.
func (c *DynamoDB) ScanRequest(input *ScanInput) (req *request.Request, output *ScanOutput) {
op := &request.Operation{
Name: opScan,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"ExclusiveStartKey"},
OutputTokens: []string{"LastEvaluatedKey"},
LimitToken: "Limit",
TruncationToken: "",
},
}
if input == nil {
input = &ScanInput{}
}
req = c.newRequest(op, input, output)
output = &ScanOutput{}
req.Data = output
return
}
// The Scan operation returns one or more items and item attributes by accessing
// every item in a table or a secondary index. To have DynamoDB return fewer
// items, you can provide a ScanFilter operation.
//
// If the total number of scanned items exceeds the maximum data set size limit
// of 1 MB, the scan stops and results are returned to the user as a LastEvaluatedKey
// value to continue the scan in a subsequent operation. The results also include
// the number of items exceeding the limit. A scan can result in no table data
// meeting the filter criteria.
//
// By default, Scan operations proceed sequentially; however, for faster performance
// on a large table or secondary index, applications can request a parallel
// Scan operation by providing the Segment and TotalSegments parameters. For
// more information, see Parallel Scan (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan)
// in the Amazon DynamoDB Developer Guide.
//
// By default, Scan uses eventually consistent reads when acessing the data
// in the table or local secondary index. However, you can use strongly consistent
// reads instead by setting the ConsistentRead parameter to true.
func (c *DynamoDB) Scan(input *ScanInput) (*ScanOutput, error) {
req, out := c.ScanRequest(input)
err := req.Send()
return out, err
}
func (c *DynamoDB) ScanPages(input *ScanInput, fn func(p *ScanOutput, lastPage bool) (shouldContinue bool)) error {
page, _ := c.ScanRequest(input)
return page.EachPage(func(p interface{}, lastPage bool) bool {
return fn(p.(*ScanOutput), lastPage)
})
}
const opUpdateItem = "UpdateItem"
// UpdateItemRequest generates a request for the UpdateItem operation.
func (c *DynamoDB) UpdateItemRequest(input *UpdateItemInput) (req *request.Request, output *UpdateItemOutput) {
op := &request.Operation{
Name: opUpdateItem,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &UpdateItemInput{}
}
req = c.newRequest(op, input, output)
output = &UpdateItemOutput{}
req.Data = output
return
}
// Edits an existing item's attributes, or adds a new item to the table if it
// does not already exist. You can put, delete, or add attribute values. You
// can also perform a conditional update on an existing item (insert a new attribute
// name-value pair if it doesn't exist, or replace an existing name-value pair
// if it has certain expected attribute values). If conditions are specified
// and the item does not exist, then the operation fails and a new item is not
// created.
//
// You can also return the item's attribute values in the same UpdateItem operation
// using the ReturnValues parameter.
func (c *DynamoDB) UpdateItem(input *UpdateItemInput) (*UpdateItemOutput, error) {
req, out := c.UpdateItemRequest(input)
err := req.Send()
return out, err
}
const opUpdateTable = "UpdateTable"
// UpdateTableRequest generates a request for the UpdateTable operation.
func (c *DynamoDB) UpdateTableRequest(input *UpdateTableInput) (req *request.Request, output *UpdateTableOutput) {
op := &request.Operation{
Name: opUpdateTable,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &UpdateTableInput{}
}
req = c.newRequest(op, input, output)
output = &UpdateTableOutput{}
req.Data = output
return
}
// Modifies the provisioned throughput settings, global secondary indexes, or
// DynamoDB Streams settings for a given table.
//
// You can only perform one of the following operations at once:
//
// Modify the provisioned throughput settings of the table.
//
// Enable or disable Streams on the table.
//
// Remove a global secondary index from the table.
//
// Create a new global secondary index on the table. Once the index begins
// backfilling, you can use UpdateTable to perform other operations.
//
// UpdateTable is an asynchronous operation; while it is executing, the table
// status changes from ACTIVE to UPDATING. While it is UPDATING, you cannot
// issue another UpdateTable request. When the table returns to the ACTIVE state,
// the UpdateTable operation is complete.
func (c *DynamoDB) UpdateTable(input *UpdateTableInput) (*UpdateTableOutput, error) {
req, out := c.UpdateTableRequest(input)
err := req.Send()
return out, err
}
// Represents an attribute for describing the key schema for the table and indexes.
type AttributeDefinition struct {
// A name for the attribute.
AttributeName *string `min:"1" type:"string" required:"true"`
// The data type for the attribute.
AttributeType *string `type:"string" required:"true" enum:"ScalarAttributeType"`
metadataAttributeDefinition `json:"-" xml:"-"`
}
type metadataAttributeDefinition struct {
SDKShapeTraits bool `type:"structure"`
}
// String returns the string representation
func (s AttributeDefinition) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s AttributeDefinition) GoString() string {
return s.String()
}
// Represents the data for an attribute. You can set one, and only one, of the
// elements.
//
// Each attribute in an item is a name-value pair. An attribute can be single-valued
// or multi-valued set. For example, a book item can have title and authors
// attributes. Each book has one title but can have many authors. The multi-valued
// attribute is a set; duplicate values are not allowed.
type AttributeValue struct {
// A Binary data type.
B []byte `type:"blob"`
// A Boolean data type.
BOOL *bool `type:"boolean"`
// A Binary Set data type.
BS [][]byte `type:"list"`
// A List of attribute values.
L []*AttributeValue `type:"list"`
// A Map of attribute values.
M map[string]*AttributeValue `type:"map"`
// A Number data type.
N *string `type:"string"`
// A Number Set data type.
NS []*string `type:"list"`
// A Null data type.
NULL *bool `type:"boolean"`
// A String data type.
S *string `type:"string"`
// A String Set data type.
SS []*string `type:"list"`
metadataAttributeValue `json:"-" xml:"-"`
}
type metadataAttributeValue struct {
SDKShapeTraits bool `type:"structure"`
}
// String returns the string representation
func (s AttributeValue) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s AttributeValue) GoString() string {
return s.String()
}
// For the UpdateItem operation, represents the attributes to be modified, the
// action to perform on each, and the new value for each.
//
// You cannot use UpdateItem to update any primary key attributes. Instead,
// you will need to delete the item, and then use PutItem to create a new item
// with new attributes.
//
// Attribute values cannot be null; string and binary type attributes must
// have lengths greater than zero; and set type attributes must not be empty.
// Requests with empty values will be rejected with a ValidationException exception.
type AttributeValueUpdate struct {
// Specifies how to perform the update. Valid values are PUT (default), DELETE,
// and ADD. The behavior depends on whether the specified primary key already
// exists in the table.
//
// If an item with the specified Key is found in the table:
//
// PUT - Adds the specified attribute to the item. If the attribute already
// exists, it is replaced by the new value.
//
// DELETE - If no value is specified, the attribute and its value are removed
// from the item. The data type of the specified value must match the existing
// value's data type.
//
// If a set of values is specified, then those values are subtracted from the
// old set. For example, if the attribute value was the set [a,b,c] and the
// DELETE action specified [a,c], then the final attribute value would be [b].
// Specifying an empty set is an error.
//
// ADD - If the attribute does not already exist, then the attribute and
// its values are added to the item. If the attribute does exist, then the behavior
// of ADD depends on the data type of the attribute:
//
// If the existing attribute is a number, and if Value is also a number,
// then the Value is mathematically added to the existing attribute. If Value
// is a negative number, then it is subtracted from the existing attribute.
//
// If you use ADD to increment or decrement a number value for an item that
// doesn't exist before the update, DynamoDB uses 0 as the initial value.
//
// In addition, if you use ADD to update an existing item, and intend to increment
// or decrement an attribute value which does not yet exist, DynamoDB uses 0
// as the initial value. For example, suppose that the item you want to update
// does not yet have an attribute named itemcount, but you decide to ADD the
// number 3 to this attribute anyway, even though it currently does not exist.
// DynamoDB will create the itemcount attribute, set its initial value to 0,
// and finally add 3 to it. The result will be a new itemcount attribute in
// the item, with a value of 3.
//
// If the existing data type is a set, and if the Value is also a set, then
// the Value is added to the existing set. (This is a set operation, not mathematical
// addition.) For example, if the attribute value was the set [1,2], and the
// ADD action specified [3], then the final attribute value would be [1,2,3].
// An error occurs if an Add action is specified for a set attribute and the
// attribute type specified does not match the existing set type.
//
// Both sets must have the same primitive data type. For example, if the existing
// data type is a set of strings, the Value must also be a set of strings. The
// same holds true for number sets and binary sets.
//
// This action is only valid for an existing attribute whose data type is
// number or is a set. Do not use ADD for any other data types.
//
// If no item with the specified Key is found:
//
// PUT - DynamoDB creates a new item with the specified primary key, and
// then adds the attribute.
//
// DELETE - Nothing happens; there is no attribute to delete.
//
// ADD - DynamoDB creates an item with the supplied primary key and number
// (or set of numbers) for the attribute value. The only data types allowed
// are number and number set; no other data types can be specified.
Action *string `type:"string" enum:"AttributeAction"`
// Represents the data for an attribute. You can set one, and only one, of the
// elements.
//
// Each attribute in an item is a name-value pair. An attribute can be single-valued
// or multi-valued set. For example, a book item can have title and authors
// attributes. Each book has one title but can have many authors. The multi-valued
// attribute is a set; duplicate values are not allowed.
Value *AttributeValue `type:"structure"`
metadataAttributeValueUpdate `json:"-" xml:"-"`
}
type metadataAttributeValueUpdate struct {
SDKShapeTraits bool `type:"structure"`
}
// String returns the string representation
func (s AttributeValueUpdate) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s AttributeValueUpdate) GoString() string {
return s.String()
}
// Represents the input of a BatchGetItem operation.
type BatchGetItemInput struct {
// A map of one or more table names and, for each table, a map that describes
// one or more items to retrieve from that table. Each table name can be used
// only once per BatchGetItem request.
//
// Each element in the map of items to retrieve consists of the following:
//
// ConsistentRead - If true, a strongly consistent read is used; if false
// (the default), an eventually consistent read is used.
//
// ExpressionAttributeNames - One or more substitution tokens for attribute
// names in the ProjectionExpression parameter. The following are some use cases
// for using ExpressionAttributeNames:
//
// To access an attribute whose name conflicts with a DynamoDB reserved word.
//
// To create a placeholder for repeating occurrences of an attribute name
// in an expression.
//
// To prevent special characters in an attribute name from being misinterpreted
// in an expression.
//
// Use the # character in an expression to dereference an attribute name.
// For example, consider the following attribute name:
//
// Percentile
//
// The name of this attribute conflicts with a reserved word, so it cannot
// be used directly in an expression. (For the complete list of reserved words,
// see Reserved Words (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html)
// in the Amazon DynamoDB Developer Guide). To work around this, you could specify
// the following for ExpressionAttributeNames:
//
// {"#P":"Percentile"}
//
// You could then use this substitution in an expression, as in this example:
//
// #P = :val
//
// Tokens that begin with the : character are expression attribute values,
// which are placeholders for the actual value at runtime.
//
// For more information on expression attribute names, see Accessing Item Attributes
// (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html)
// in the Amazon DynamoDB Developer Guide.
//
// Keys - An array of primary key attribute values that define specific items
// in the table. For each primary key, you must provide all of the key attributes.
// For example, with a hash type primary key, you only need to provide the hash
// attribute. For a hash-and-range type primary key, you must provide both the
// hash attribute and the range attribute.
//
// ProjectionExpression - A string that identifies one or more attributes
// to retrieve from the table. These attributes can include scalars, sets, or
// elements of a JSON document. The attributes in the expression must be separated
// by commas.
//
// If no attribute names are specified, then all attributes will be returned.
// If any of the requested attributes are not found, they will not appear in
// the result.
//
// For more information, see Accessing Item Attributes (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html)
// in the Amazon DynamoDB Developer Guide.
//
// AttributesToGet -
//
// This is a legacy parameter, for backward compatibility. New applications
// should use ProjectionExpression instead. Do not combine legacy parameters
// and expression parameters in a single API call; otherwise, DynamoDB will
// return a ValidationException exception.
//
// This parameter allows you to retrieve attributes of type List or Map; however,
// it cannot retrieve individual elements within a List or a Map.
//
// The names of one or more attributes to retrieve. If no attribute names are
// provided, then all attributes will be returned. If any of the requested attributes
// are not found, they will not appear in the result.
//
// Note that AttributesToGet has no effect on provisioned throughput consumption.
// DynamoDB determines capacity units consumed based on item size, not on the
// amount of data that is returned to an application.
RequestItems map[string]*KeysAndAttributes `min:"1" type:"map" required:"true"`
// Determines the level of detail about provisioned throughput consumption that
// is returned in the response:
//
// INDEXES - The response includes the aggregate ConsumedCapacity for the
// operation, together with ConsumedCapacity for each table and secondary index
// that was accessed.
//
// Note that some operations, such as GetItem and BatchGetItem, do not access
// any indexes at all. In these cases, specifying INDEXES will only return ConsumedCapacity
// information for table(s).
//
// TOTAL - The response includes only the aggregate ConsumedCapacity for the
// operation.
//
// NONE - No ConsumedCapacity details are included in the response.
ReturnConsumedCapacity *string `type:"string" enum:"ReturnConsumedCapacity"`
metadataBatchGetItemInput `json:"-" xml:"-"`
}
type metadataBatchGetItemInput struct {
SDKShapeTraits bool `type:"structure"`
}
// String returns the string representation
func (s BatchGetItemInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s BatchGetItemInput) GoString() string {
return s.String()
}
// Represents the output of a BatchGetItem operation.
type BatchGetItemOutput struct {
// The read capacity units consumed by the operation.
//
// Each element consists of:
//
// TableName - The table that consumed the provisioned throughput.
//
// CapacityUnits - The total number of capacity units consumed.
ConsumedCapacity []*ConsumedCapacity `type:"list"`
// A map of table name to a list of items. Each object in Responses consists
// of a table name, along with a map of attribute data consisting of the data
// type and attribute value.
Responses map[string][]map[string]*AttributeValue `type:"map"`
// A map of tables and their respective keys that were not processed with the
// current response. The UnprocessedKeys value is in the same form as RequestItems,