@@ -62,6 +62,8 @@ defmodule ExAws.Dynamo do
62
62
63
63
import ExAws.Utils , only: [ camelize: 1 , camelize_keys: 1 , camelize_keys: 2 , upcase: 1 ]
64
64
alias __MODULE__
65
+ alias ExAws.Dynamo . { Decoder , Lazy }
66
+ alias ExAws.Operation.JSON
65
67
66
68
@ nested_opts [ :exclusive_start_key , :expression_attribute_values , :expression_attribute_names ]
67
69
@ upcase_opts [ :return_values , :return_item_collection_metrics , :select , :total_segments ]
@@ -125,8 +127,8 @@ defmodule ExAws.Dynamo do
125
127
|> Dynamo.decode_item(as: User)
126
128
```
127
129
"""
128
- @ spec decode_item ( Map . t ( ) ) :: Map . t ( )
129
- @ spec decode_item ( Map . t ( ) , as: atom ) :: Map . t ( )
130
+ @ spec decode_item ( map ( ) ) :: map ( )
131
+ @ spec decode_item ( map ( ) , as: atom ) :: map ( )
130
132
def decode_item ( item , opts \\ [ ] )
131
133
132
134
def decode_item ( % { "Items" => items } , opts ) do
@@ -138,12 +140,12 @@ defmodule ExAws.Dynamo do
138
140
end
139
141
140
142
def decode_item ( item , opts ) do
141
- ExAws.Dynamo. Decoder. decode ( item , opts )
143
+ Decoder . decode ( item , opts )
142
144
end
143
145
144
146
@ doc "List tables"
145
- @ spec list_tables ( ) :: ExAws.Operation. JSON. t ( )
146
- def list_tables ( ) do
147
+ @ spec list_tables ( ) :: JSON . t ( )
148
+ def list_tables do
147
149
request ( :list_tables , % { } )
148
150
end
149
151
@@ -163,7 +165,7 @@ defmodule ExAws.Dynamo do
163
165
read_capacity :: pos_integer ,
164
166
write_capacity :: pos_integer ,
165
167
billing_mode :: dynamo_billing_types
166
- ) :: ExAws.Operation. JSON. t ( )
168
+ ) :: JSON . t ( )
167
169
def create_table (
168
170
name ,
169
171
primary_key ,
@@ -252,10 +254,10 @@ defmodule ExAws.Dynamo do
252
254
key_definitions :: key_definitions ,
253
255
read_capacity :: pos_integer ,
254
256
write_capacity :: pos_integer ,
255
- global_indexes :: [ Map . t ( ) ] ,
256
- local_indexes :: [ Map . t ( ) ] ,
257
+ global_indexes :: [ map ( ) ] ,
258
+ local_indexes :: [ map ( ) ] ,
257
259
billing_mode :: dynamo_billing_types
258
- ) :: ExAws.ExAws.Operation. JSON. t ( )
260
+ ) :: JSON . t ( )
259
261
def create_table (
260
262
name ,
261
263
key_schema ,
@@ -303,7 +305,7 @@ defmodule ExAws.Dynamo do
303
305
read_capacity :: pos_integer ,
304
306
write_capacity :: pos_integer ,
305
307
billing_mode :: dynamo_billing_types
306
- ) :: Map . t ( )
308
+ ) :: map ( )
307
309
defp build_billing_mode ( read_capacity , write_capacity , :provisioned ) do
308
310
% {
309
311
"BillingMode" => "PROVISIONED" ,
@@ -320,14 +322,14 @@ defmodule ExAws.Dynamo do
320
322
end
321
323
322
324
@ doc "Describe table"
323
- @ spec describe_table ( name :: binary ) :: ExAws.Operation. JSON. t ( )
325
+ @ spec describe_table ( name :: binary ) :: JSON . t ( )
324
326
def describe_table ( name ) do
325
327
request ( :describe_table , % { "TableName" => name } )
326
328
end
327
329
328
330
@ doc "Update Table"
329
- @ spec update_table ( name :: binary , attributes :: Keyword . t ( ) | Map . t ( ) ) ::
330
- ExAws.Operation. JSON. t ( )
331
+ @ spec update_table ( name :: binary , attributes :: Keyword . t ( ) | map ( ) ) ::
332
+ JSON . t ( )
331
333
def update_table ( name , attributes ) do
332
334
data =
333
335
attributes
@@ -338,46 +340,46 @@ defmodule ExAws.Dynamo do
338
340
request ( :update_table , data )
339
341
end
340
342
341
- @ spec maybe_convert_billing_mode ( attributes :: Keyword . t ( ) | Map . t ( ) ) :: Keyword . t ( ) | Map . t ( )
343
+ @ spec maybe_convert_billing_mode ( attributes :: Keyword . t ( ) | map ( ) ) :: Keyword . t ( ) | map ( )
342
344
defp maybe_convert_billing_mode ( attributes ) do
343
345
case attributes [ :billing_mode ] do
344
346
nil -> attributes
345
347
_ -> convert_billing_mode ( attributes , attributes [ :billing_mode ] )
346
348
end
347
349
end
348
350
349
- @ spec convert_billing_mode ( attributes :: Keyword . t ( ) | Map . t ( ) , dynamo_billing_types ) ::
350
- Keyword . t ( ) | Map . t ( )
351
+ @ spec convert_billing_mode ( attributes :: Keyword . t ( ) | map ( ) , dynamo_billing_types ) ::
352
+ Keyword . t ( ) | map ( )
351
353
defp convert_billing_mode ( attributes , :provisioned ) ,
352
354
do: do_convert_billing_mode ( attributes , "PROVISIONED" )
353
355
354
356
defp convert_billing_mode ( attributes , :pay_per_request ) ,
355
357
do: do_convert_billing_mode ( attributes , "PAY_PER_REQUEST" )
356
358
357
- @ spec do_convert_billing_mode ( attributes :: Keyword . t ( ) | Map . t ( ) , value :: String . t ( ) ) ::
358
- Keyword . t ( ) | Map . t ( )
359
+ @ spec do_convert_billing_mode ( attributes :: Keyword . t ( ) | map ( ) , value :: String . t ( ) ) ::
360
+ Keyword . t ( ) | map ( )
359
361
defp do_convert_billing_mode ( attributes , value ) when is_map ( attributes ) ,
360
362
do: Map . replace! ( attributes , :billing_mode , value )
361
363
362
364
defp do_convert_billing_mode ( attributes , value ) when is_list ( attributes ) ,
363
365
do: Keyword . replace! ( attributes , :billing_mode , value )
364
366
365
367
@ doc "Delete Table"
366
- @ spec delete_table ( table :: binary ) :: ExAws.Operation. JSON. t ( )
368
+ @ spec delete_table ( table :: binary ) :: JSON . t ( )
367
369
def delete_table ( table ) do
368
370
request ( :delete_table , % { "TableName" => table } )
369
371
end
370
372
371
373
@ doc "Update time to live"
372
374
@ spec update_time_to_live ( table :: binary , ttl_attribute :: binary , enabled :: boolean ) ::
373
- ExAws.Operation. JSON. t ( )
375
+ JSON . t ( )
374
376
def update_time_to_live ( table , ttl_attribute , enabled ) do
375
377
data = build_time_to_live ( ttl_attribute , enabled ) |> Map . merge ( % { "TableName" => table } )
376
378
377
379
request ( :update_time_to_live , data )
378
380
end
379
381
380
- @ spec build_time_to_live ( ttl_attribute :: binary , enabled :: boolean ) :: Map . t ( )
382
+ @ spec build_time_to_live ( ttl_attribute :: binary , enabled :: boolean ) :: map ( )
381
383
defp build_time_to_live ( "" , _enabled ) do
382
384
% { }
383
385
end
@@ -396,7 +398,7 @@ defmodule ExAws.Dynamo do
396
398
end
397
399
398
400
@ doc "Describe time to live"
399
- @ spec describe_time_to_live ( table :: binary ) :: ExAws.Operation. JSON. t ( )
401
+ @ spec describe_time_to_live ( table :: binary ) :: JSON . t ( )
400
402
def describe_time_to_live ( table ) do
401
403
request ( :describe_time_to_live , % { "TableName" => table } )
402
404
end
@@ -437,15 +439,15 @@ defmodule ExAws.Dynamo do
437
439
| { :select , select_vals }
438
440
| { :total_segments , pos_integer }
439
441
]
440
- @ spec scan ( table_name :: table_name ) :: ExAws.Operation. JSON. t ( )
441
- @ spec scan ( table_name :: table_name , opts :: scan_opts ) :: ExAws.Operation. JSON. t ( )
442
+ @ spec scan ( table_name :: table_name ) :: JSON . t ( )
443
+ @ spec scan ( table_name :: table_name , opts :: scan_opts ) :: JSON . t ( )
442
444
def scan ( name , opts \\ [ ] ) do
443
445
data =
444
446
opts
445
447
|> build_opts ( )
446
448
|> Map . merge ( % { "TableName" => name } )
447
449
448
- request ( :scan , data , % { stream_builder: & ExAws.Dynamo. Lazy. stream_scan ( name , opts , & 1 ) } )
450
+ request ( :scan , data , % { stream_builder: & Lazy . stream_scan ( name , opts , & 1 ) } )
449
451
end
450
452
451
453
@ doc """
@@ -477,15 +479,15 @@ defmodule ExAws.Dynamo do
477
479
| { :scan_index_forward , boolean }
478
480
| { :select , select_vals }
479
481
]
480
- @ spec query ( table_name :: table_name ) :: ExAws.Operation. JSON. t ( )
481
- @ spec query ( table_name :: table_name , opts :: query_opts ) :: ExAws.Operation. JSON. t ( )
482
+ @ spec query ( table_name :: table_name ) :: JSON . t ( )
483
+ @ spec query ( table_name :: table_name , opts :: query_opts ) :: JSON . t ( )
482
484
def query ( name , opts \\ [ ] ) do
483
485
data =
484
486
opts
485
487
|> build_opts ( )
486
488
|> Map . merge ( % { "TableName" => name } )
487
489
488
- request ( :query , data , % { stream_builder: & ExAws.Dynamo. Lazy. stream_query ( name , opts , & 1 ) } )
490
+ request ( :query , data , % { stream_builder: & Lazy . stream_query ( name , opts , & 1 ) } )
489
491
end
490
492
491
493
@ doc """
@@ -529,9 +531,9 @@ defmodule ExAws.Dynamo do
529
531
| { :expression_attribute_names , expression_attribute_names_vals }
530
532
| { :projection_expression , binary }
531
533
]
532
- @ spec batch_get_item ( % { table_name => get_item } ) :: ExAws.Operation. JSON. t ( )
534
+ @ spec batch_get_item ( % { table_name => get_item } ) :: JSON . t ( )
533
535
@ spec batch_get_item ( % { table_name => get_item } , opts :: batch_get_item_opts ) ::
534
- ExAws.Operation. JSON. t ( )
536
+ JSON . t ( )
535
537
def batch_get_item ( data , opts \\ [ ] ) do
536
538
request_items =
537
539
data
@@ -571,9 +573,9 @@ defmodule ExAws.Dynamo do
571
573
| { :return_item_collection_metrics , return_item_collection_metrics_vals }
572
574
| { :return_values , return_values_vals }
573
575
]
574
- @ spec put_item ( table_name :: table_name , record :: map ( ) ) :: ExAws.Operation. JSON. t ( )
576
+ @ spec put_item ( table_name :: table_name , record :: map ( ) ) :: JSON . t ( )
575
577
@ spec put_item ( table_name :: table_name , record :: map ( ) , opts :: put_item_opts ) ::
576
- ExAws.Operation. JSON. t ( )
578
+ JSON . t ( )
577
579
def put_item ( name , record , opts \\ [ ] ) do
578
580
data =
579
581
opts
@@ -603,9 +605,9 @@ defmodule ExAws.Dynamo do
603
605
{ :return_consumed_capacity , return_consumed_capacity_vals }
604
606
| { :return_item_collection_metrics , return_item_collection_metrics_vals }
605
607
]
606
- @ spec batch_write_item ( % { table_name => [ write_item ] } ) :: ExAws.Operation. JSON. t ( )
608
+ @ spec batch_write_item ( % { table_name => [ write_item ] } ) :: JSON . t ( )
607
609
@ spec batch_write_item ( % { table_name => [ write_item ] } , opts :: batch_write_item_opts ) ::
608
- ExAws.Operation. JSON. t ( )
610
+ JSON . t ( )
609
611
def batch_write_item ( data , opts \\ [ ] ) do
610
612
request_items =
611
613
data
@@ -638,9 +640,9 @@ defmodule ExAws.Dynamo do
638
640
| { :projection_expression , binary }
639
641
| { :return_consumed_capacity , return_consumed_capacity_vals }
640
642
]
641
- @ spec get_item ( table_name :: table_name , primary_key :: primary_key ) :: ExAws.Operation. JSON. t ( )
643
+ @ spec get_item ( table_name :: table_name , primary_key :: primary_key ) :: JSON . t ( )
642
644
@ spec get_item ( table_name :: table_name , primary_key :: primary_key , opts :: get_item_opts ) ::
643
- ExAws.Operation. JSON. t ( )
645
+ JSON . t ( )
644
646
def get_item ( name , primary_key , opts \\ [ ] ) do
645
647
data =
646
648
opts
@@ -672,7 +674,7 @@ defmodule ExAws.Dynamo do
672
674
table_name :: table_name ,
673
675
primary_key :: primary_key ,
674
676
opts :: update_item_opts
675
- ) :: ExAws.Operation. JSON. t ( )
677
+ ) :: JSON . t ( )
676
678
def update_item ( table_name , primary_key , update_opts ) do
677
679
data =
678
680
update_opts
@@ -695,12 +697,12 @@ defmodule ExAws.Dynamo do
695
697
| { :return_values , return_values_vals }
696
698
]
697
699
@ spec delete_item ( table_name :: table_name , primary_key :: primary_key ) ::
698
- ExAws.Operation. JSON. t ( )
700
+ JSON . t ( )
699
701
@ spec delete_item (
700
702
table_name :: table_name ,
701
703
primary_key :: primary_key ,
702
704
opts :: delete_item_opts
703
- ) :: ExAws.Operation. JSON. t ( )
705
+ ) :: JSON . t ( )
704
706
def delete_item ( name , primary_key , opts \\ [ ] ) do
705
707
data =
706
708
opts
@@ -727,8 +729,8 @@ defmodule ExAws.Dynamo do
727
729
]
728
730
729
731
@ spec transact_get_items ( items :: [ transact_get_item ] , transact_get_items_opts ) ::
730
- ExAws.Operation. JSON. t ( )
731
- @ spec transact_get_items ( items :: [ transact_get_item ] ) :: ExAws.Operation. JSON. t ( )
732
+ JSON . t ( )
733
+ @ spec transact_get_items ( items :: [ transact_get_item ] ) :: JSON . t ( )
732
734
733
735
@ doc """
734
736
A synchronous operation that retrieves multiple items from one or more tables (but not from indexes) in a single account and region
@@ -801,8 +803,8 @@ defmodule ExAws.Dynamo do
801
803
A synchronous write operation that groups up to 25 action requests
802
804
"""
803
805
@ spec transact_write_items ( items :: [ transact_write_item ] , transact_write_items_opts ) ::
804
- ExAws.Operation. JSON. t ( )
805
- @ spec transact_write_items ( items :: [ transact_write_item ] ) :: ExAws.Operation. JSON. t ( )
806
+ JSON . t ( )
807
+ @ spec transact_write_items ( items :: [ transact_write_item ] ) :: JSON . t ( )
806
808
def transact_write_items ( items , opts \\ [ ] ) do
807
809
data =
808
810
opts
@@ -896,7 +898,7 @@ defmodule ExAws.Dynamo do
896
898
|> Atom . to_string ( )
897
899
|> Macro . camelize ( )
898
900
899
- ExAws.Operation. JSON. new (
901
+ JSON . new (
900
902
:dynamodb ,
901
903
% {
902
904
data: data ,
0 commit comments