2
2
from re import match
3
3
from typing import Any , Dict , List , Optional , Union
4
4
5
- from samtranslator .model import PropertyType , Resource
5
+ from samtranslator .model import GeneratedProperty , Resource
6
6
from samtranslator .model .exceptions import InvalidResourceException
7
7
from samtranslator .model .intrinsics import fnSub , ref
8
- from samtranslator .model .types import IS_DICT , IS_STR , PassThrough , is_type , list_of , one_of
8
+ from samtranslator .model .types import PassThrough
9
9
from samtranslator .translator import logical_id_generator
10
10
from samtranslator .translator .arn_generator import ArnGenerator
11
11
from samtranslator .utils .py27hash_fix import Py27Dict , Py27UniStr
15
15
class ApiGatewayRestApi (Resource ):
16
16
resource_type = "AWS::ApiGateway::RestApi"
17
17
property_types = {
18
- "Body" : PropertyType ( False , IS_DICT ),
19
- "BodyS3Location" : PropertyType ( False , IS_DICT ),
20
- "CloneFrom" : PropertyType ( False , IS_STR ),
21
- "Description" : PropertyType ( False , IS_STR ),
22
- "FailOnWarnings" : PropertyType ( False , is_type ( bool ) ),
23
- "Name" : PropertyType ( False , IS_STR ),
24
- "Parameters" : PropertyType ( False , IS_DICT ),
25
- "EndpointConfiguration" : PropertyType ( False , IS_DICT ),
26
- "BinaryMediaTypes" : PropertyType ( False , is_type ( list ) ),
27
- "MinimumCompressionSize" : PropertyType ( False , is_type ( int ) ),
28
- "Mode" : PropertyType ( False , IS_STR ),
29
- "ApiKeySourceType" : PropertyType ( False , IS_STR ),
18
+ "Body" : GeneratedProperty ( ),
19
+ "BodyS3Location" : GeneratedProperty ( ),
20
+ "CloneFrom" : GeneratedProperty ( ),
21
+ "Description" : GeneratedProperty ( ),
22
+ "FailOnWarnings" : GeneratedProperty ( ),
23
+ "Name" : GeneratedProperty ( ),
24
+ "Parameters" : GeneratedProperty ( ),
25
+ "EndpointConfiguration" : GeneratedProperty ( ),
26
+ "BinaryMediaTypes" : GeneratedProperty ( ),
27
+ "MinimumCompressionSize" : GeneratedProperty ( ),
28
+ "Mode" : GeneratedProperty ( ),
29
+ "ApiKeySourceType" : GeneratedProperty ( ),
30
30
}
31
31
32
32
Body : Optional [Dict [str , Any ]]
@@ -48,19 +48,19 @@ class ApiGatewayRestApi(Resource):
48
48
class ApiGatewayStage (Resource ):
49
49
resource_type = "AWS::ApiGateway::Stage"
50
50
property_types = {
51
- "AccessLogSetting" : PropertyType ( False , IS_DICT ),
52
- "CacheClusterEnabled" : PropertyType ( False , is_type ( bool ) ),
53
- "CacheClusterSize" : PropertyType ( False , IS_STR ),
54
- "CanarySetting" : PropertyType ( False , IS_DICT ),
55
- "ClientCertificateId" : PropertyType ( False , IS_STR ),
56
- "DeploymentId" : PropertyType ( True , IS_STR ),
57
- "Description" : PropertyType ( False , IS_STR ),
58
- "RestApiId" : PropertyType ( True , IS_STR ),
59
- "StageName" : PropertyType ( True , one_of ( IS_STR , IS_DICT ) ),
60
- "Tags" : PropertyType ( False , list_of ( IS_DICT ) ),
61
- "TracingEnabled" : PropertyType ( False , is_type ( bool ) ),
62
- "Variables" : PropertyType ( False , IS_DICT ),
63
- "MethodSettings" : PropertyType ( False , is_type ( list ) ),
51
+ "AccessLogSetting" : GeneratedProperty ( ),
52
+ "CacheClusterEnabled" : GeneratedProperty ( ),
53
+ "CacheClusterSize" : GeneratedProperty ( ),
54
+ "CanarySetting" : GeneratedProperty ( ),
55
+ "ClientCertificateId" : GeneratedProperty ( ),
56
+ "DeploymentId" : GeneratedProperty ( ),
57
+ "Description" : GeneratedProperty ( ),
58
+ "RestApiId" : GeneratedProperty ( ),
59
+ "StageName" : GeneratedProperty ( ),
60
+ "Tags" : GeneratedProperty ( ),
61
+ "TracingEnabled" : GeneratedProperty ( ),
62
+ "Variables" : GeneratedProperty ( ),
63
+ "MethodSettings" : GeneratedProperty ( ),
64
64
}
65
65
66
66
runtime_attrs = {"stage_name" : lambda self : ref (self .logical_id )}
@@ -71,18 +71,20 @@ def update_deployment_ref(self, deployment_logical_id: str) -> None:
71
71
72
72
class ApiGatewayAccount (Resource ):
73
73
resource_type = "AWS::ApiGateway::Account"
74
- property_types = {"CloudWatchRoleArn" : PropertyType (False , one_of (IS_STR , IS_DICT ))}
74
+ property_types = {
75
+ "CloudWatchRoleArn" : GeneratedProperty (),
76
+ }
75
77
76
78
77
79
class ApiGatewayDeployment (Resource ):
78
80
_X_HASH_DELIMITER = "||"
79
81
80
82
resource_type = "AWS::ApiGateway::Deployment"
81
83
property_types = {
82
- "Description" : PropertyType ( False , IS_STR ),
83
- "RestApiId" : PropertyType ( True , IS_STR ),
84
- "StageDescription" : PropertyType ( False , IS_DICT ),
85
- "StageName" : PropertyType ( False , IS_STR ),
84
+ "Description" : GeneratedProperty ( ),
85
+ "RestApiId" : GeneratedProperty ( ),
86
+ "StageDescription" : GeneratedProperty ( ),
87
+ "StageName" : GeneratedProperty ( ),
86
88
}
87
89
88
90
runtime_attrs = {"deployment_id" : lambda self : ref (self .logical_id )}
@@ -200,13 +202,13 @@ def _status_code_string(self, status_code): # type: ignore[no-untyped-def]
200
202
class ApiGatewayDomainName (Resource ):
201
203
resource_type = "AWS::ApiGateway::DomainName"
202
204
property_types = {
203
- "RegionalCertificateArn" : PropertyType ( False , IS_STR ),
204
- "DomainName" : PropertyType ( True , IS_STR ),
205
- "EndpointConfiguration" : PropertyType ( False , IS_DICT ),
206
- "MutualTlsAuthentication" : PropertyType ( False , IS_DICT ),
207
- "SecurityPolicy" : PropertyType ( False , IS_STR ),
208
- "CertificateArn" : PropertyType ( False , IS_STR ),
209
- "OwnershipVerificationCertificateArn" : PropertyType ( False , IS_STR ),
205
+ "RegionalCertificateArn" : GeneratedProperty ( ),
206
+ "DomainName" : GeneratedProperty ( ),
207
+ "EndpointConfiguration" : GeneratedProperty ( ),
208
+ "MutualTlsAuthentication" : GeneratedProperty ( ),
209
+ "SecurityPolicy" : GeneratedProperty ( ),
210
+ "CertificateArn" : GeneratedProperty ( ),
211
+ "OwnershipVerificationCertificateArn" : GeneratedProperty ( ),
210
212
}
211
213
212
214
RegionalCertificateArn : Optional [PassThrough ]
@@ -221,45 +223,45 @@ class ApiGatewayDomainName(Resource):
221
223
class ApiGatewayBasePathMapping (Resource ):
222
224
resource_type = "AWS::ApiGateway::BasePathMapping"
223
225
property_types = {
224
- "BasePath" : PropertyType ( False , IS_STR ),
225
- "DomainName" : PropertyType ( True , IS_STR ),
226
- "RestApiId" : PropertyType ( False , IS_STR ),
227
- "Stage" : PropertyType ( False , IS_STR ),
226
+ "BasePath" : GeneratedProperty ( ),
227
+ "DomainName" : GeneratedProperty ( ),
228
+ "RestApiId" : GeneratedProperty ( ),
229
+ "Stage" : GeneratedProperty ( ),
228
230
}
229
231
230
232
231
233
class ApiGatewayUsagePlan (Resource ):
232
234
resource_type = "AWS::ApiGateway::UsagePlan"
233
235
property_types = {
234
- "ApiStages" : PropertyType ( False , is_type ( list ) ),
235
- "Description" : PropertyType ( False , IS_STR ),
236
- "Quota" : PropertyType ( False , IS_DICT ),
237
- "Tags" : PropertyType ( False , list_of ( dict ) ),
238
- "Throttle" : PropertyType ( False , IS_DICT ),
239
- "UsagePlanName" : PropertyType ( False , IS_STR ),
236
+ "ApiStages" : GeneratedProperty ( ),
237
+ "Description" : GeneratedProperty ( ),
238
+ "Quota" : GeneratedProperty ( ),
239
+ "Tags" : GeneratedProperty ( ),
240
+ "Throttle" : GeneratedProperty ( ),
241
+ "UsagePlanName" : GeneratedProperty ( ),
240
242
}
241
243
runtime_attrs = {"usage_plan_id" : lambda self : ref (self .logical_id )}
242
244
243
245
244
246
class ApiGatewayUsagePlanKey (Resource ):
245
247
resource_type = "AWS::ApiGateway::UsagePlanKey"
246
248
property_types = {
247
- "KeyId" : PropertyType ( True , IS_STR ),
248
- "KeyType" : PropertyType ( True , IS_STR ),
249
- "UsagePlanId" : PropertyType ( True , IS_STR ),
249
+ "KeyId" : GeneratedProperty ( ),
250
+ "KeyType" : GeneratedProperty ( ),
251
+ "UsagePlanId" : GeneratedProperty ( ),
250
252
}
251
253
252
254
253
255
class ApiGatewayApiKey (Resource ):
254
256
resource_type = "AWS::ApiGateway::ApiKey"
255
257
property_types = {
256
- "CustomerId" : PropertyType ( False , IS_STR ),
257
- "Description" : PropertyType ( False , IS_STR ),
258
- "Enabled" : PropertyType ( False , is_type ( bool ) ),
259
- "GenerateDistinctId" : PropertyType ( False , is_type ( bool ) ),
260
- "Name" : PropertyType ( False , IS_STR ),
261
- "StageKeys" : PropertyType ( False , is_type ( list ) ),
262
- "Value" : PropertyType ( False , IS_STR ),
258
+ "CustomerId" : GeneratedProperty ( ),
259
+ "Description" : GeneratedProperty ( ),
260
+ "Enabled" : GeneratedProperty ( ),
261
+ "GenerateDistinctId" : GeneratedProperty ( ),
262
+ "Name" : GeneratedProperty ( ),
263
+ "StageKeys" : GeneratedProperty ( ),
264
+ "Value" : GeneratedProperty ( ),
263
265
}
264
266
265
267
runtime_attrs = {"api_key_id" : lambda self : ref (self .logical_id )}
0 commit comments