Return datasource names along with datasource annotation (#4973)

* Add new `datasource_names` annotation that returns the string version of the `datasources` annotation
This commit is contained in:
Daniel Patterson
2018-04-03 15:13:25 -07:00
committed by GitHub
parent 8a63ad9b4b
commit b5a4ffed96
7 changed files with 81 additions and 5 deletions
+17
View File
@@ -324,6 +324,23 @@ class RouteAPI : public BaseAPI
}
annotation.values["nodes"] = std::move(nodes);
}
// Add any supporting metadata, if needed
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
{
const auto MAX_DATASOURCE_ID = 255u;
util::json::Object metadata;
util::json::Array datasource_names;
for (auto i = 0u; i < MAX_DATASOURCE_ID; i++)
{
const auto name = facade.GetDatasourceName(i);
// Length of 0 indicates the first empty name, so we can stop here
if (name.size() == 0)
break;
datasource_names.values.push_back(std::string(facade.GetDatasourceName(i)));
}
metadata.values["datasource_names"] = datasource_names;
annotation.values["metadata"] = metadata;
}
annotations.push_back(std::move(annotation));
}