use of com.google.api.services.discovery.model.DirectoryList.Items in project endpoints-java by cloudendpoints.
the class DiscoveryGenerator method generateDirectory.
private DirectoryList generateDirectory(Map<ApiKey, RestDescription> discoveryDocs, ImmutableSet<ApiKey> preferred, DiscoveryContext context) {
DirectoryList directory = new DirectoryList().setDiscoveryVersion("v1").setKind("discovery#directoryList");
List<Items> items = Lists.newArrayList();
for (Map.Entry<ApiKey, RestDescription> entry : discoveryDocs.entrySet()) {
RestDescription doc = entry.getValue();
String relativePath = "/apis/" + doc.getName() + "/" + doc.getVersion() + "/rest";
items.add(new Items().setDescription(doc.getDescription()).setDiscoveryLink("." + relativePath).setDiscoveryRestUrl(context.getApiRoot() + "/discovery/v1" + relativePath).setIcons(new Icons().setX16("https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png").setX32("https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png")).setId(doc.getName() + ":" + doc.getVersion()).setKind("discovery#directoryItem").setName(doc.getName()).setPreferred(preferred.contains(entry.getKey())).setTitle(doc.getTitle()).setVersion(doc.getVersion()).setDocumentationLink(doc.getDocumentationLink()));
}
return directory.setItems(items);
}
use of com.google.api.services.discovery.model.DirectoryList.Items in project endpoints-java by cloudendpoints.
the class LocalDiscoveryProvider method replaceRoot.
private static DirectoryList replaceRoot(DirectoryList directory, String newRoot) {
if (directory == null) {
return null;
}
newRoot = Strings.stripTrailingSlash(newRoot);
directory = directory.clone();
for (Items item : directory.getItems()) {
item.setDiscoveryRestUrl(item.getDiscoveryRestUrl().replaceFirst(PLACEHOLDER_ROOT, newRoot));
}
return directory;
}
Aggregations