16
16
from aws_lambda_powertools import Logger , Tracer , Metrics
17
17
from aws_lambda_powertools .utilities .typing import LambdaContext
18
18
from aws_lambda_powertools .utilities .data_classes import EventBridgeEvent , APIGatewayProxyEvent
19
- from manage_blueprint import create_blueprint ,delete_blueprint ,list_blueprints ,get_blueprint ,update_blueprint
19
+ from manage_blueprint import create_blueprint ,delete_blueprint ,list_blueprints ,get_blueprint ,update_blueprint , DateTimeEncoder
20
20
from create_schema import create_schema
21
21
22
22
@@ -98,11 +98,7 @@ def get_schema(bucket_name: str, schema_key: str) -> Dict[str, Any]:
98
98
Key = schema_key
99
99
)
100
100
schema_content = json .loads (response ['Body' ].read ().decode ('utf-8' ))
101
- logger .info ("Successfully retrieved and parsed schema" , extra = {
102
- "schema_size" : len (json .dumps (schema_content )),
103
- "bucket" : bucket_name ,
104
- "key" : schema_key
105
- })
101
+ logger .info (f"Successfully retrieved and parsed schema { schema_content } " )
106
102
107
103
return schema_content
108
104
@@ -180,12 +176,9 @@ def handler(event, context: LambdaContext):
180
176
if not all (key in field for key in ['name' , 'description' , 'alias' ]):
181
177
raise ValueError ("Each field must contain 'name', 'description', and 'alias'" )
182
178
183
- # Create schema using the fields
179
+ # Create schema using AWS BDA format
184
180
try :
185
- DynamicSchema = create_schema (schema_fields )
186
- schema_instance = DynamicSchema ()
187
- schema_content = json .dumps (schema_instance .model_json_schema ())
188
-
181
+ schema_content = create_schema (schema_fields )
189
182
except Exception as e :
190
183
print ("Error creating schema" )
191
184
return {
@@ -196,8 +189,6 @@ def handler(event, context: LambdaContext):
196
189
})
197
190
}
198
191
199
- if not schema_content or not schema_content .strip ():
200
- logger .warning ("No Schema provided , creating a custom blueprint with no schema" )
201
192
202
193
response = create_blueprint (schema_content ,blueprint_details )
203
194
response_msg = 'Blueprint created successfully'
@@ -214,7 +205,7 @@ def handler(event, context: LambdaContext):
214
205
'body' : json .dumps ({
215
206
'message' : response_msg ,
216
207
'response' : response
217
- })
208
+ }, cls = DateTimeEncoder )
218
209
}
219
210
220
211
@@ -226,6 +217,5 @@ def handler(event, context: LambdaContext):
226
217
'body' : json .dumps ({
227
218
'message' : 'Unexpected error occurred' ,
228
219
'error' : str (e )
229
- })
220
+ }, cls = DateTimeEncoder )
230
221
}
231
-
0 commit comments