Skip to content

Commit 7cc4816

Browse files
committed
Wire up signers
1 parent 2fa5abd commit 7cc4816

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

codegen/core/src/main/java/software/amazon/smithy/python/codegen/integrations/RestJsonProtocolGenerator.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,25 @@ public void wrapInputStream(GenerationContext context, PythonWriter writer) {
397397
writer.addImport("smithy_core.aio.types", "AsyncBytesReader");
398398
writer.addImport("smithy_core.types", "TimestampFormat");
399399
writer.addImport("aws_event_stream.aio", "AWSInputEventStream");
400+
writer.addImport("aws_sdk_signers", "AsyncEventSigner");
400401
writer.write(
401402
"""
403+
# TODO - Move this out of the RestJSON generator
404+
ctx = request_context
405+
signer_properties = ctx.properties.get("signer_properties") # type: ignore
406+
identity = ctx.properties.get("identity") # type: ignore
407+
signature = ctx.properties.get("signature") # type: ignore
408+
signer = AsyncEventSigner(
409+
signing_properties=signer_properties, # type: ignore
410+
identity=identity, # type: ignore
411+
initial_signature=signature, # type: ignore
412+
)
402413
codec = JSONCodec(default_timestamp_format=TimestampFormat.EPOCH_SECONDS)
403414
return AWSInputEventStream[Any, Any](
404415
payload_codec=codec,
405416
awaitable_output=awaitable_output,
406417
async_writer=request_context.transport_request.body, # type: ignore
418+
signer=signer, # type: ignore
407419
)
408420
""");
409421
}
@@ -439,15 +451,28 @@ public void wrapDuplexStream(GenerationContext context, PythonWriter writer) {
439451
writer.addImport("smithy_core.aio.types", "AsyncBytesReader");
440452
writer.addImport("smithy_core.types", "TimestampFormat");
441453
writer.addImport("aws_event_stream.aio", "AWSDuplexEventStream");
454+
writer.addImport("aws_sdk_signers", "AsyncEventSigner");
442455
writer.write(
443456
"""
457+
# TODO - Move this out of the RestJSON generator
458+
ctx = request_context
459+
signer_properties = ctx.properties.get("signer_properties") # type: ignore
460+
identity = ctx.properties.get("identity") # type: ignore
461+
signature = ctx.properties.get("signature") # type: ignore
462+
signer = AsyncEventSigner(
463+
signing_properties=signer_properties, # type: ignore
464+
identity=identity, # type: ignore
465+
initial_signature=signature, # type: ignore
466+
)
467+
444468
codec = JSONCodec(default_timestamp_format=TimestampFormat.EPOCH_SECONDS)
445469
return AWSDuplexEventStream[Any, Any, Any](
446470
payload_codec=codec,
447471
async_writer=request_context.transport_request.body, # type: ignore
448472
awaitable_output=awaitable_output,
449473
awaitable_response=response_future,
450474
deserializer=event_deserializer, # type: ignore
475+
signer=signer, # type: ignore
451476
)
452477
""");
453478
}

0 commit comments

Comments
 (0)