@@ -6,7 +6,6 @@ module.exports = {
66 compileMethodsToDynamodb ( ) {
77 this . validated . events . forEach ( ( event ) => {
88 if ( event . serviceName == 'dynamodb' ) {
9- event . http . action = this . getDynamodbAction ( event . http )
109 const resourceId = this . getResourceId ( event . http . path )
1110 const resourceName = this . getResourceName ( event . http . path )
1211
@@ -44,25 +43,6 @@ module.exports = {
4443 } )
4544 } ,
4645
47- getDynamodbAction ( http ) {
48- if ( ! _ . has ( http , 'action' ) ) {
49- switch ( http . method . toUpperCase ( ) ) {
50- case 'PUT' :
51- return 'PutItem'
52- case 'POST' :
53- return 'PutItem'
54- case 'GET' :
55- return 'GetItem'
56- case 'DELETE' :
57- return 'DeleteItem'
58- case 'PATCH' :
59- return 'UpdateItem'
60- }
61- }
62-
63- return http . action
64- } ,
65-
6646 getDynamodbMethodIntegration ( http ) {
6747 const integration = {
6848 IntegrationHttpMethod : 'POST' ,
@@ -153,20 +133,6 @@ module.exports = {
153133 attributeValue : `$input.params().querystring.${ http . hashKey . queryStringParam } `
154134 }
155135 }
156-
157- if ( http . hashKey . bodyParam ) {
158- return {
159- key : http . hashKey . bodyParam ,
160- attributeType : http . hashKey . attributeType ,
161- attributeValue : `$util.parseJson($input.body).${ http . hashKey . bodyParam } `
162- }
163- }
164-
165- return {
166- key : http . hashKey ,
167- attributeType : 'S' ,
168- attributeValue : '$context.requestId'
169- }
170136 } ,
171137
172138 getDynamodbObjectRangekeyParameter ( http ) {
@@ -185,30 +151,9 @@ module.exports = {
185151 attributeValue : `$input.params().querystring.${ http . rangeKey . queryStringParam } `
186152 }
187153 }
188-
189- if ( http . rangeKey . bodyParam ) {
190- return {
191- key : http . rangeKey . bodyParam ,
192- attributeType : http . rangeKey . attributeType ,
193- attributeValue : `$util.parseJson($input.body).${ http . rangeKey . bodyParam } `
194- }
195- }
196-
197- return {
198- key : http . rangeKey ,
199- attributeType : 'S' ,
200- attributeValue : '$context.requestId'
201- }
202154 } ,
203155
204156 getDefaultDynamodbResponseTemplates ( http ) {
205- if ( http . action === 'PutItem' && _ . isString ( http . hashKey ) ) {
206- return {
207- 'application/json' : this . getPutItemDefaultDynamodbResponseTemplate ( http ) ,
208- 'application/x-www-form-urlencoded' : this . getPutItemDefaultDynamodbResponseTemplate ( http )
209- }
210- }
211-
212157 if ( http . action === 'GetItem' ) {
213158 return {
214159 'application/json' : this . getGetItemDefaultDynamodbResponseTemplate ( ) ,
@@ -223,19 +168,6 @@ module.exports = {
223168 return `#set($item = $input.path('$.Item')){#foreach($key in $item.keySet())#set ($value = $item.get($key))#foreach( $type in $value.keySet())"$key":"$value.get($type)"#if($foreach.hasNext()),#end#end#if($foreach.hasNext()),#end#end}`
224169 } ,
225170
226- getPutItemDefaultDynamodbResponseTemplate ( http ) {
227- const objectRequestParam = this . getDynamodbObjectHashkeyParameter ( http )
228- return {
229- 'Fn::Sub' : [
230- '{"${HashKey}": "${HashAttributeValue}"}' ,
231- {
232- HashKey : `${ objectRequestParam . key } ` ,
233- HashAttributeValue : `${ objectRequestParam . attributeValue } `
234- }
235- ]
236- }
237- } ,
238-
239171 buildDefaultDynamodbRequestTemplate ( http ) {
240172 switch ( http . action ) {
241173 case 'PutItem' :
@@ -244,8 +176,6 @@ module.exports = {
244176 return this . buildDefaultDynamodbGetItemRequestTemplate ( http )
245177 case 'DeleteItem' :
246178 return this . buildDefaultDynamodbDeleteItemRequestTemplate ( http )
247- case 'UpdateItem' :
248- return this . buildDefaultDynamodbUpdateItemRequestTemplate ( http )
249179 }
250180 } ,
251181
@@ -275,37 +205,6 @@ module.exports = {
275205 }
276206 } ,
277207
278- buildDefaultDynamodbUpdateItemRequestTemplate ( http ) {
279- const fuSubValues = {
280- TableName : http . tableName
281- }
282-
283- let requestTemplate = '{"TableName": "${TableName}","Key":{'
284- if ( _ . has ( http , 'hashKey' ) ) {
285- requestTemplate += '"${HashKey}": {"${HashAttributeType}": "${HashAttributeValue}"}'
286- Object . assign ( fuSubValues , this . getDynamodbHashkeyFnSubValues ( http ) )
287- }
288-
289- if ( _ . has ( http , 'rangeKey' ) ) {
290- requestTemplate += ',"${RangeKey}": {"${RangeAttributeType}": "${RangeAttributeValue}"}'
291- Object . assign ( fuSubValues , this . getDynamodbRangekeyFnSubValues ( http ) )
292- }
293-
294- requestTemplate += '}'
295- requestTemplate += `
296- #set ($body = $input.path('$'))
297- ,"UpdateExpression":"$body.UpdateExpression"
298- ,"ExpressionAttributeValues":$input.json('$.ExpressionAttributeValues')
299- #if ($body.ExpressionAttributeNames != "")
300- ,"ExpressionAttributeNames":$input.json('$.ExpressionAttributeNames')
301- #end
302- `
303- requestTemplate += '}'
304- return {
305- 'Fn::Sub' : [ `${ requestTemplate } ` , fuSubValues ]
306- }
307- } ,
308-
309208 buildDefaultDynamodbGetItemRequestTemplate ( http ) {
310209 const fuSubValues = {
311210 TableName : http . tableName
0 commit comments