- 
  Notifications
 You must be signed in to change notification settings 
- Fork 949
-
I am looking to save https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html api response to Openserach i can save the data but i am not able to retrieve it showing the error message below. I believe the reason is this POJO classes like Instance class does not have noArgs constructor since they are Builder based Pojo. My question is there is a way to make the Instance metadata searchable in Opensearch and also retrieve(deserialize it to Instance Class) it from the spring app without getting an error. please do not suggest to copy the class to another pojo class that duplicate the content because it does not scale very well for me.
codes
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Document(indexName = "api-reponse", shards = 1, replicas = 0, refreshInterval = "5s")
public class AwsResponse {
 @Id
 private String id;
 private Instance.Builder instance;
}
 public void saveInstanceDetails() {
 Iterable<AwsResponse> instanceDetials = repository.findAll(); // this call causes the above error
 .
 .
 .
 List<Instance> instances = describeInstance("i-93ee719a803d60975");
 Instance instance = instances.get(0);
 repository.save(AwsResponse.builder().instance(instance.toBuilder()).build());
 }
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Hi @kedbirhan this is not a Java SDK usage question, it's more of a general implementation question, so I'll move this to the General category. Maybe someone from the community can help.
Beta Was this translation helpful? Give feedback.