line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Amazon::DynamoDB::Types; |
2
|
|
|
|
|
|
|
$Amazon::DynamoDB::Types::VERSION = '0.35'; |
3
|
11
|
|
|
11
|
|
38
|
use strict; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
315
|
|
4
|
11
|
|
|
11
|
|
59
|
use warnings; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
542
|
|
5
|
|
|
|
|
|
|
use Type::Library |
6
|
11
|
|
|
|
|
92
|
"-base", |
7
|
|
|
|
|
|
|
"-declare" => qw( |
8
|
|
|
|
|
|
|
TableNameType |
9
|
|
|
|
|
|
|
AttributeDefinitionsType |
10
|
|
|
|
|
|
|
SelectType |
11
|
|
|
|
|
|
|
ReturnValuesType |
12
|
|
|
|
|
|
|
ReturnItemCollectionMetricsType |
13
|
|
|
|
|
|
|
ReturnConsumedCapacityType |
14
|
|
|
|
|
|
|
ConditionalOperatorType |
15
|
|
|
|
|
|
|
StringBooleanType |
16
|
|
|
|
|
|
|
ComparisonOperatorType |
17
|
|
|
|
|
|
|
AttributeNameType |
18
|
|
|
|
|
|
|
AttributeValueType |
19
|
|
|
|
|
|
|
KeySchemaType |
20
|
|
|
|
|
|
|
GlobalSecondaryIndexType |
21
|
|
|
|
|
|
|
LocalSecondaryIndexType |
22
|
|
|
|
|
|
|
TableStatusType |
23
|
|
|
|
|
|
|
ExpectedType |
24
|
|
|
|
|
|
|
AttributeUpdatesType |
25
|
|
|
|
|
|
|
ItemType |
26
|
|
|
|
|
|
|
KeyType |
27
|
|
|
|
|
|
|
BatchWritePutItemType |
28
|
|
|
|
|
|
|
BatchWriteDeleteItemType |
29
|
|
|
|
|
|
|
BatchWriteRequestItemsType |
30
|
|
|
|
|
|
|
BatchGetItemsType |
31
|
|
|
|
|
|
|
KeyConditionsType |
32
|
|
|
|
|
|
|
QueryFilterType |
33
|
|
|
|
|
|
|
ScanFilterType |
34
|
|
|
|
|
|
|
ExpectedValueType |
35
|
|
|
|
|
|
|
ExpressionAttributeValuesType |
36
|
|
|
|
|
|
|
ExpressionAttributeNamesType |
37
|
11
|
|
|
11
|
|
3836
|
AttributesToGetType); |
|
11
|
|
|
|
|
180105
|
|
38
|
|
|
|
|
|
|
|
39
|
11
|
|
|
11
|
|
27298
|
use Type::Utils -all; |
|
11
|
|
|
|
|
42155
|
|
|
11
|
|
|
|
|
74
|
|
40
|
11
|
|
|
11
|
|
25108
|
use Types::Standard -types; |
|
11
|
|
|
|
|
377813
|
|
|
11
|
|
|
|
|
111
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
declare AttributeNameType, as Str, where { length($_) >= 1 && length($_) <= 255 }; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
declare "TableNameType", as StrMatch[qr/^[a-zA-Z0-9_\-\.]{3,255}$/]; |
46
|
|
|
|
|
|
|
coerce TableNameType, from Str, via { |
47
|
|
|
|
|
|
|
TableNameType->new($_); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
declare "AttributeDefinitionsType", as Map[AttributeNameType, StrMatch[qr/^(S|N|B)$/]]; |
52
|
|
|
|
|
|
|
coerce AttributeDefinitionsType, from HashRef, via { |
53
|
|
|
|
|
|
|
AttributeDefinitionsType->new($_); |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
declare ComparisonOperatorType, as StrMatch[qr/^(EQ|NE|LE|LT|GE|GT|NOT_NULL|NULL|CONTAINS|NOT_CONTAINS|BEGINS_WITH|IN|BETWEEN)$/]; |
58
|
|
|
|
|
|
|
coerce ComparisonOperatorType, from Str, via { ComparisonOperatorType->new($_); }; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
declare SelectType, as StrMatch[qr/^(ALL_ATTRIBUTES|ALL_PROJECTED_ATTRIBUTES|SPECIFIC_ATTRIBUTES|COUNT)$/]; |
61
|
|
|
|
|
|
|
coerce SelectType, from Str, via { SelectType->new($_); }; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
declare ReturnValuesType, as StrMatch[qr/^(NONE|ALL_OLD|UPDATED_OLD|ALL_NEW|UPDATED_NEW)$/]; |
64
|
|
|
|
|
|
|
coerce ReturnValuesType, from Str, via { ReturnValuesType->new($_); }; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
declare ReturnItemCollectionMetricsType, as StrMatch[qr/^(NONE|SIZE)$/]; |
67
|
|
|
|
|
|
|
coerce ReturnItemCollectionMetricsType, from Str, via { ReturnItemCollectionMetricsType->new($_); }; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
declare ReturnConsumedCapacityType, as StrMatch[qr/^(INDEXES|TOTAL|NONE)$/]; |
70
|
|
|
|
|
|
|
coerce ReturnConsumedCapacityType, from Str, via { ReturnConsumedCapacityType->new($_); }; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
declare ConditionalOperatorType, as StrMatch[qr/^(AND|OR)$/]; |
74
|
|
|
|
|
|
|
coerce ConditionalOperatorType, from Str, via { ConditionalOperatorType->new($_); }; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
declare StringBooleanType, as StrMatch[qr/^(true|false)$/]; |
77
|
|
|
|
|
|
|
coerce StringBooleanType, from Str, via { StringBooleanType->new($_); }; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
declare AttributeValueType, as Defined, where { |
80
|
|
|
|
|
|
|
my $v = shift @_; |
81
|
|
|
|
|
|
|
my $ref_type = ref($v); |
82
|
|
|
|
|
|
|
if ($ref_type ne '') { |
83
|
|
|
|
|
|
|
if ($ref_type eq 'SCALAR') { |
84
|
|
|
|
|
|
|
return defined($$v); |
85
|
|
|
|
|
|
|
} elsif ($ref_type eq 'ARRAY') { |
86
|
|
|
|
|
|
|
return scalar(@$v) > 0; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} else { |
89
|
|
|
|
|
|
|
return $v =~ /\S/; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
return 0; |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
declare AttributesToGetType, as ArrayRef[AttributeNameType], where { scalar(@$_) >= 1 }; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
declare KeySchemaType, as ArrayRef[AttributeNameType], where { scalar(@$_) <= 2 && scalar(@$_) > 0 }; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
declare GlobalSecondaryIndexType, as Dict[IndexName => TableNameType, |
100
|
|
|
|
|
|
|
ProvisionedThroughput => Optional[Dict[ReadCapacityUnits => Optional[Int], |
101
|
|
|
|
|
|
|
WriteCapacityUnits => Optional[Int] |
102
|
|
|
|
|
|
|
] |
103
|
|
|
|
|
|
|
], |
104
|
|
|
|
|
|
|
KeySchema => KeySchemaType, |
105
|
|
|
|
|
|
|
Projection => Optional[Dict[ProjectionType => StrMatch[qr/^(KEYS_ONLY|INCLUDE|ALL)$/], |
106
|
|
|
|
|
|
|
NonKeyAttributes => Optional[ArrayRef[AttributeNameType]]]], |
107
|
|
|
|
|
|
|
]; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
coerce GlobalSecondaryIndexType, from HashRef, via { |
110
|
|
|
|
|
|
|
GlobalSecondaryIndexType->new($_); |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
declare LocalSecondaryIndexType, as Dict[IndexName => TableNameType, |
114
|
|
|
|
|
|
|
KeySchema => KeySchemaType, |
115
|
|
|
|
|
|
|
Projection => Optional[Dict[ProjectionType => StrMatch[qr/^(KEYS_ONLY|INCLUDE|ALL)$/], |
116
|
|
|
|
|
|
|
NonKeyAttributes => Optional[ArrayRef[AttributeNameType]]]] |
117
|
|
|
|
|
|
|
]; |
118
|
|
|
|
|
|
|
coerce LocalSecondaryIndexType, from HashRef, via { |
119
|
|
|
|
|
|
|
LocalSecondaryIndexType->new($_); |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
declare TableStatusType, as StrMatch[qr/^(CREATING|UPDATING|DELETING|ACTIVE)$/]; |
123
|
|
|
|
|
|
|
coerce TableStatusType, from Str, via { TableStatusType->new($_) }; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
declare ExpectedValueType, as Dict[AttributeValueList => Optional[AttributeValueType], |
126
|
|
|
|
|
|
|
ComparisonOperator => Optional[ComparisonOperatorType], |
127
|
|
|
|
|
|
|
Exists => Optional[StringBooleanType], |
128
|
|
|
|
|
|
|
Value => Optional[AttributeValueType], |
129
|
|
|
|
|
|
|
], where { scalar(keys %$_) > 0 && |
130
|
|
|
|
|
|
|
# don't allow both forms of expected/comparision operator |
131
|
|
|
|
|
|
|
# to be used at the same time. |
132
|
|
|
|
|
|
|
((exists($_->{AttributeValueList}) || exists($_->{ComparisonOperator})) |
133
|
|
|
|
|
|
|
xor |
134
|
|
|
|
|
|
|
(exists($_->{Exists}) || exists($_->{Value}))) |
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
declare ExpectedType, as Map[AttributeNameType, ExpectedValueType]; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
coerce ExpectedType, from HashRef, via { ExpectedType->new($_) }; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
declare AttributeUpdatesType, as Map[AttributeNameType, Dict[Action => StrMatch[qr/^(PUT|DELETE|ADD)$/], |
145
|
|
|
|
|
|
|
Value => Optional[AttributeValueType]]]; |
146
|
|
|
|
|
|
|
coerce AttributeUpdatesType, from HashRef, via { AttributeUpdatesType->new($_); }; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
declare ItemType, as Map[AttributeNameType, AttributeValueType]; |
149
|
|
|
|
|
|
|
declare KeyType, as Map[AttributeNameType, AttributeValueType], where { scalar(keys %$_) > 0 && scalar(keys %$_) < 3 }; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
declare BatchWritePutItemType, as Dict[PutRequest => Dict[Item => ItemType]]; |
152
|
|
|
|
|
|
|
declare BatchWriteDeleteItemType, as Dict[DeleteRequest => Dict[Key => KeyType]]; |
153
|
|
|
|
|
|
|
declare BatchWriteRequestItemsType, as Map[TableNameType, ArrayRef[BatchWritePutItemType|BatchWriteDeleteItemType]], where { scalar(keys %$_) > 0 }; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
declare BatchGetItemsType, as Map[TableNameType, Dict[AttributesToGet => Optional[AttributesToGetType], |
156
|
|
|
|
|
|
|
ConsistentRead => Optional[StringBooleanType], |
157
|
|
|
|
|
|
|
Keys => ArrayRef[KeyType]] |
158
|
|
|
|
|
|
|
], where { scalar(keys %$_) > 0 }; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
declare KeyConditionsType, as Map[AttributeNameType, Dict[AttributeValueList => AttributeValueType, |
162
|
|
|
|
|
|
|
ComparisonOperator => StrMatch[qr/^(EQ|LE|LT|GE|GT|BEGINS_WITH|BETWEEN)$/] |
163
|
|
|
|
|
|
|
]]; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
declare QueryFilterType, as Map[AttributeNameType, Dict[AttributeValueList => Optional[AttributeValueType], |
167
|
|
|
|
|
|
|
ComparisonOperator => ComparisonOperatorType |
168
|
|
|
|
|
|
|
]]; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
declare ScanFilterType, as Map[AttributeNameType, Dict[AttributeValueList => Optional[AttributeValueType], |
172
|
|
|
|
|
|
|
ComparisonOperator => ComparisonOperatorType |
173
|
|
|
|
|
|
|
]]; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
declare ExpressionAttributeValuesType, as Map[StrMatch[qr/^:[a-zA-Z][a-z0-9A-Z_]*$/], AttributeValueType]; |
176
|
|
|
|
|
|
|
coerce ExpressionAttributeValuesType, from HashRef, via { ExpressionAttributeValuesType->new($_) }; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
declare ExpressionAttributeNamesType, as Map[StrMatch[qr/^\#[a-zA-Z][a-z0-9A-Z_]*$/], Str]; |
179
|
|
|
|
|
|
|
coerce ExpressionAttributeNamesType, from HashRef, via { ExpressionAttributeNamesType->new($_) }; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
__END__ |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=pod |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=encoding UTF-8 |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 NAME |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Amazon::DynamoDB::Types |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 VERSION |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
version 0.35 |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 AUTHORS |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=over 4 |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Rusty Conover <rusty@luckydinosaur.com> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Tom Molesworth <cpan@entitymodel.com> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=back |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Tom Molesworth, copyright (c) 2014 Lucky Dinosaur LLC. L<http://www.luckydinosaur.com>. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
217
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |