Newer AWS services like bedrock-runtime are using union shapes in their API. Contrary to older services (like S3 or MediaConvert) that have a type property containing an enum, and then additional properties used depending on the type, union shapes expect exactly 1 of their members to be filled.
In the SDK manifest, those union shapes are defined with union: true: https://github.com/aws/aws-sdk-php/blob/33f6d393834053b11a5fc10573a211d92e61c2db/src/data/bedrock-runtime/2023-09-30/api-2.json#L1013-L1021
Looking at official AWS SDKs for other languages (the official PHP SDK does not return typed responses and so cannot be used as comparison), here is how they represent it:
Newer AWS services like bedrock-runtime are using union shapes in their API. Contrary to older services (like S3 or MediaConvert) that have a
typeproperty containing an enum, and then additional properties used depending on the type, union shapes expect exactly 1 of their members to be filled.In the SDK manifest, those union shapes are defined with
union: true: https://github.com/aws/aws-sdk-php/blob/33f6d393834053b11a5fc10573a211d92e61c2db/src/data/bedrock-runtime/2023-09-30/api-2.json#L1013-L1021Looking at official AWS SDKs for other languages (the official PHP SDK does not return typed responses and so cannot be used as comparison), here is how they represent it:
<shapeName>.<memberName>Member) with that member defined with its type and all other members defined as optional properties with typenever(which forbids having such properties in the object in typescript) and then uses a union type: https://github.com/aws/aws-sdk-js-v3/blob/b09a8f969ad6b2508e4d3de93089fe4498f57408/clients/client-bedrock-runtime/src/models/models_0.ts#L2351-L2382. They also expose aVisitorinterface with methods for each type, with avisitfunction calling the right method of the visitor: https://github.com/aws/aws-sdk-js-v3/blob/b09a8f969ad6b2508e4d3de93089fe4498f57408/clients/client-bedrock-runtime/src/models/models_0.ts#L2544-L2569 (note that this Visitor interface seems to imply that adding a new member in the union would be a BC break)<shapeName>Member<memberName>) that have aValuefield containing the value of the member: https://github.com/aws/aws-sdk-go-v2/blob/43445011355b4bb4226fa797c5fc141bbc1b793f/service/bedrockruntime/types/types.go#L127-L137 The serializer and deserializer take care of using the right structure for each kind of members.type()getter returning an enum identifying which member is relevant (inferred from which member is populated). That class has static factory methods for each member. See https://github.com/aws/aws-sdk-java-v2/blob/master/docs/design/core/tagged-unions/README.md#union-type-definition for an example in their design documentation (the generated code is not committed for the Java SDK)valuefield of the appropriate type. The base class hasas*andas*OrNullmethods for each member that return the associatedvalueif it is of the appropriate type and either throw or returnnullwhen called on another type. See https://sdk.amazonaws.com/kotlin/api/latest/bedrockruntime/aws.sdk.kotlin.services.bedrockruntime.model/-content-block/index.html for an example