use of software.amazon.neptune.cluster.EndpointsType in project amazon-neptune-tools by awslabs.
the class NeptuneEndpointsInfoLambda method handleRequest.
@Override
public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
LambdaLogger logger = context.getLogger();
EndpointsType endpointsType = EndpointsType.ReadReplicas;
Scanner scanner = new Scanner(input);
if (scanner.hasNext()) {
String param = scanner.next().replace("\"", "");
if (!param.isEmpty()) {
endpointsType = EndpointsType.valueOf(param);
}
}
logger.log("EndpointsType: " + endpointsType);
Map<EndpointsSelector, Collection<String>> addressesMap = addresses.get();
for (Map.Entry<EndpointsSelector, Collection<String>> entry : addressesMap.entrySet()) {
logger.log(entry.getKey() + ": " + entry.getValue());
}
String results = String.join(",", addressesMap.get(endpointsType));
logger.log("Results: " + results);
try (Writer writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8))) {
writer.write(results);
writer.flush();
}
}
Aggregations