forked from DuckbillGroup/followercount
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yaml
67 lines (67 loc) · 2.21 KB
/
openapi.yaml
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
openapi: "3.0.1"
info:
title:
Ref: AWS::StackName
description: REST API for Follower Count
paths:
/{twitter_handle}:
get:
responses:
200:
description: "200 response"
content:
application/json:
schema:
$ref: "#/components/schemas/Empty"
x-amazon-apigateway-integration:
type: "aws"
credentials:
Fn::GetAtt: [RestAPIRole, Arn]
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:dynamodb:action/Query"
responses:
default:
statusCode: "200"
responseTemplates:
application/json: |
#set($inputRoot = $input.path('$'))
{
"twitter_handle": "$input.params('twitter_handle')",
"Items": [#foreach($item in $inputRoot.Items){
"EpochTime": $item.EpochTime.N,
"followers": $item.followers.N
}#if($foreach.hasNext),#end
#end
],
#if(!$inputRoot.LastEvaluatedKey.EpochTime.isEmpty())
"LastEvaluatedKey": $inputRoot.LastEvaluatedKey.EpochTime.N,
#end
"ScannedCount": $inputRoot.ScannedCount
}
requestTemplates:
application/json:
Fn::Join:
- ''
- - >-
{"TableName": "
- Ref: FollowerCount
- >-
"
- |
,
#if(!$method.request.querystring.LastEvaluatedKey.isEmpty())
"ExclusiveStartKey": {"twitter_handle":{"S":"$input.params('twitter_handle')"}, "EpochTime":{"N":"$method.request.querystring.LastEvaluatedKey"}},
#end
"KeyConditionExpression": "twitter_handle = :twitter_handle",
"ExpressionAttributeValues": {
":twitter_handle": {"S": "$input.params('twitter_handle')"}
}
}
passthroughBehavior: "never"
httpMethod: "POST"
components:
schemas:
Empty:
type: object
title: Empty Schema
description: Empty Schema