aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.2k stars 853 forks source link

Support construction of Document from java POJOs #5484

Open vivekg-amazon opened 3 months ago

vivekg-amazon commented 3 months ago

Describe the feature

Document is a type supported in smithy which can be used to pass unstructured data like json - https://smithy.io/2.0/spec/simple-types.html#document This is an alternative to sending json strings.

However the java AWS SDK support for it requires json to be hand crafted into a document class.

Example Json:

{ "prompt" : "hello" }

needs to be converted as Document as shown below, before it can be passed to an API

Document.fromMap(ImmutableMap.of("prompt", Document.fromString("text"))

It would helpful if Document class provides a helper method fromObject where we can pass a Java POJO (similar to dynamo db enhanced client's bean schema)

Use Case

It is frustrating for customers to create Document objects to send in a json unstructured data in an API request. For example; APIs like Bedrock's Converse takes in Document type which is cumbersome to do in Java. For other languages like python and javascript, you can send in the json object as is.

Proposed Solution

No response

Other Information

No response

Acknowledgements

AWS Java SDK version used

latest

JDK version used

17

Operating System and version

macOs

debora-ito commented 1 month ago

@vivekg-amazon feature request added to our backlog.