Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) CloudFormation AWS::ApiGateway::Methods and AWS::ApiGateway::Resources support #1247

Merged
merged 78 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
8f6b8fb
Initial setup and work
viksrivat Jun 17, 2019
f457401
Add RestApi tests
viksrivat Jun 19, 2019
8112cf4
Remove Stage Name/Variable from pr
viksrivat Jun 20, 2019
5050dd8
Run make pr
viksrivat Jun 20, 2019
bf5a083
Add Rest Api integration test
viksrivat Jun 20, 2019
6eb226a
Remove AWS::Stage from current pr
viksrivat Jun 20, 2019
7c5823d
Update integration test to only use CloudFormation types
viksrivat Jun 20, 2019
4966513
Re-run Travis Ci
viksrivat Jun 24, 2019
2c38ede
Update Uri to BodyS3Location
viksrivat Jun 24, 2019
9d3d137
Add docstring to extract_swagger_api
viksrivat Jun 24, 2019
b6d9b62
Fix Merge conflicts with dev and branch
viksrivat Jun 24, 2019
f8ac623
Update AWS::ApiGateway::Stage tests
viksrivat Jun 24, 2019
54bda7f
Test local file in body fail and clean tests
viksrivat Jun 24, 2019
9b06696
Initial Attempt
viksrivat Jun 25, 2019
145162e
Refactor Sam API provider
viksrivat Jun 25, 2019
5615163
Cleanup Refactoring
viksrivat Jun 25, 2019
752fba8
Merge pull request #1 from viksrivat/feature/cloud_formation_api_prov…
viksrivat Jun 25, 2019
1157284
Update AWS::ApiGateway::Stage tests
viksrivat Jun 24, 2019
5d1dfc7
Fix merge conflict
viksrivat Jun 25, 2019
7ed267c
Remove .vscode
viksrivat Jun 25, 2019
681ede3
Re-run travis
viksrivat Jun 25, 2019
a0f5837
Restructure the information Api has the way it passed through
viksrivat Jun 26, 2019
a3ca29f
Merge pull request #2 from viksrivat/cleanup/update_common_stage_feat…
viksrivat Jun 26, 2019
0078786
Update common
viksrivat Jun 26, 2019
9879105
Merge branch 'feature/cloud_formation_stage_support' of github.com:vi…
viksrivat Jun 26, 2019
a9117ad
Update AbstractParserProvider documentation
viksrivat Jun 26, 2019
997845c
Initial Refactor refactor
viksrivat Jun 26, 2019
de65fd0
Fix tests and run make pr
viksrivat Jun 26, 2019
df243a7
Fix merge conflict
viksrivat Jun 27, 2019
4555f11
Reorganize classes
viksrivat Jun 27, 2019
420a842
Update docstrings
viksrivat Jun 27, 2019
53f4b7e
Update the SAMBaseProvider
viksrivat Jun 27, 2019
856326e
Fix merge conflict
viksrivat Jun 27, 2019
6803a0b
Restructure to seperate SAM and CF providers seperately + tests
viksrivat Jun 27, 2019
837137f
Remove transform flag in the rest-api
viksrivat Jun 27, 2019
4130ea2
Remove BaseProvider object
viksrivat Jun 27, 2019
ec833dc
Fix merge conflict
viksrivat Jun 27, 2019
693692b
Update with style
viksrivat Jun 27, 2019
19eaebe
Update tests and code with comments
viksrivat Jun 27, 2019
d226f53
Fix merge conflicts with comments from feature/cfn_rest_api
viksrivat Jun 27, 2019
23467de
Update tests with comments
viksrivat Jun 28, 2019
7e25c02
Fix merge conflict tests
viksrivat Jun 28, 2019
066b236
Trigger
viksrivat Jun 28, 2019
36018f1
Start working on method&resources
viksrivat Jun 28, 2019
8987db2
Remove noapievent
viksrivat Jun 28, 2019
626ea71
Update cloud_formation resource processing
viksrivat Jun 28, 2019
666b2e4
Update cfn_api_provider
viksrivat Jun 28, 2019
4a792bf
Update tests
viksrivat Jun 28, 2019
644b851
Update merge conflictz
viksrivat Jun 28, 2019
efdc3a4
Merge changes from stage
viksrivat Jun 28, 2019
fd4ab05
Add tests for resources&methods
viksrivat Jun 28, 2019
238742a
Fix bug with api
viksrivat Jun 29, 2019
739e74b
Update tests with make pr
viksrivat Jun 29, 2019
1d2e2b1
Fix tests and binary_types
viksrivat Jun 29, 2019
78341e9
Fix pathpart code
viksrivat Jun 29, 2019
2d0da34
Add cdk templates
viksrivat Jun 29, 2019
1c29946
Add serverless template
viksrivat Jun 29, 2019
7662f24
Fixed comments
viksrivat Jul 8, 2019
3df93ba
Update tests
viksrivat Jul 9, 2019
cc21095
Fix merge with rest_api
viksrivat Jul 9, 2019
b50e644
Remove Invalid Integration Test
viksrivat Jul 9, 2019
a01aee2
Run make pr
viksrivat Jul 9, 2019
8d2abd0
Fix merge conflict with stage
viksrivat Jul 9, 2019
49d16b4
feat(start-api): CloudFormation AWS::ApiGateway::RestApi support (#1238)
viksrivat Jul 23, 2019
aeba546
feat(start-api): CloudFormation AWS::ApiGateway::Stage Support (#1239)
viksrivat Jul 26, 2019
07830b9
Merge branch 'start-api/cfn' into feature/cloud_formation_method_reso…
viksrivat Jul 29, 2019
fa2472d
Fix merge issue with cfn_api_provider
viksrivat Jul 29, 2019
b594aed
Update tests
viksrivat Jul 29, 2019
3d79b5c
Fix Integration Tests
viksrivat Jul 29, 2019
45e7e51
Fix Integration Tests
viksrivat Jul 29, 2019
d751f00
Merge branch 'start-api/cfn' into feature/cloud_formation_method_reso…
viksrivat Aug 8, 2019
0bb1d3b
Update with comments
viksrivat Aug 9, 2019
33be359
Update method docstring
viksrivat Aug 9, 2019
b9b7396
Fix style for flake8
viksrivat Aug 9, 2019
fe2a2bb
Merge branch 'develop' into feature/cloud_formation_method_resources
jfuss Aug 9, 2019
fa3006d
Merge branch 'develop' into feature/cloud_formation_method_resources
jfuss Aug 10, 2019
7365d2c
Update intrinsic Test by fixing overriden yaml values
viksrivat Aug 12, 2019
2e1b4e1
Merge branch 'develop' into feature/cloud_formation_method_resources
jfuss Aug 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Uri to BodyS3Location
  • Loading branch information
viksrivat committed Jun 24, 2019
commit 2c38ede28d8f129df4ceade541a85e6290ae0aaa
22 changes: 7 additions & 15 deletions samcli/commands/local/lib/sam_api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,7 @@ def _extract_from_serverless_api(self, logical_id, api_resource, collector):
LOG.debug("Skipping resource '%s'. Swagger document not found in DefinitionBody and DefinitionUri",
logical_id)
return

reader = SamSwaggerReader(definition_body=body,
definition_uri=uri,
working_dir=self.cwd)
swagger = reader.read()
parser = SwaggerParser(swagger)
apis = parser.get_apis()
LOG.debug("Found '%s' APIs in resource '%s'", len(apis), logical_id)

collector.add_apis(logical_id, apis)
collector.add_binary_media_types(logical_id, parser.get_binary_media_types()) # Binary media from swagger
collector.add_binary_media_types(logical_id, binary_media) # Binary media specified on resource in template
self._extract_swagger_api(logical_id, body, uri, binary_media, collector)

def _extract_cloud_formation_api(self, logical_id, api_resource, collector):
"""
Expand All @@ -167,14 +156,17 @@ def _extract_cloud_formation_api(self, logical_id, api_resource, collector):
"""
properties = api_resource.get("Properties", {})
body = properties.get("Body")
uri = properties.get("Uri")
s3_location = properties.get("BodyS3Location")
binary_media = properties.get("BinaryMediaTypes", [])

if not body and not uri:
if not body and not s3_location:
# Swagger is not found anywhere.
LOG.debug("Skipping resource '%s'. Swagger document not found in DefinitionBody and DefinitionUri",
LOG.debug("Skipping resource '%s'. Swagger document not found in Body and BodyS3Location",
logical_id)
return
self._extract_swagger_api(logical_id, body, s3_location, binary_media, collector)

def _extract_swagger_api(self, logical_id, body, uri, binary_media, collector):

reader = SamSwaggerReader(definition_body=body,
definition_uri=uri,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
---
AWSTemplateFormatVersion: '2010-09-09'
Globals:
Api:
BinaryMediaTypes:
- image~1png

Resources:
Base64ResponseFunction:
Properties:
Expand Down Expand Up @@ -70,7 +66,7 @@ Resources:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyNonServerlessLambdaFunction.Arn}/invocations
swagger: '2.0'
x-amazon-apigateway-binary-media-types:
- image/gif
- image/gif
StageName: prod
Type: AWS::ApiGateway::RestApi
MyLambdaFunction:
Expand Down
12 changes: 2 additions & 10 deletions tests/unit/commands/local/lib/test_sam_api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ def test_with_no_apis(self):
"Api1": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"StageName": "Prod"
},

}
Expand All @@ -983,7 +982,6 @@ def test_with_no_apis(self):

provider = SamApiProvider(template)

self.assertEquals(len(provider.apis), 0)
self.assertEquals(provider.apis, [])

def test_with_inline_swagger_apis(self):
Expand All @@ -993,7 +991,6 @@ def test_with_inline_swagger_apis(self):
"Api1": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"StageName": "Prod",
"Body": make_swagger(self.input_apis)
}
}
Expand All @@ -1017,8 +1014,7 @@ def test_with_swagger_as_local_file(self):
"Api1": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"StageName": "Prod",
"Uri": filename
"BodyS3Location": filename
}
}
}
Expand All @@ -1038,8 +1034,7 @@ def test_with_swagger_as_both_body_and_uri(self, SamSwaggerReaderMock):
"Api1": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"StageName": "Prod",
"Uri": filename,
"BodyS3Location": filename,
"Body": body
}
}
Expand Down Expand Up @@ -1073,7 +1068,6 @@ def test_swagger_with_any_method(self):
"Api1": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"StageName": "Prod",
"Body": make_swagger(apis)
}
}
Expand All @@ -1090,7 +1084,6 @@ def test_with_binary_media_types(self):
"Api1": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"StageName": "Prod",
"Body": make_swagger(self.input_apis, binary_media_types=self.binary_types)
}
}
Expand Down Expand Up @@ -1129,7 +1122,6 @@ def test_with_binary_media_types_in_swagger_and_on_resource(self):
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"BinaryMediaTypes": extra_binary_types,
"StageName": "Prod",
"Body": make_swagger(input_apis, binary_media_types=self.binary_types)
}
}
Expand Down