Search in sources :

Example 1 with Items

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);
}
Also used : ApiKey(com.google.api.server.spi.config.model.ApiKey) Icons(com.google.api.services.discovery.model.DirectoryList.Items.Icons) Items(com.google.api.services.discovery.model.DirectoryList.Items) RestDescription(com.google.api.services.discovery.model.RestDescription) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) TreeMap(java.util.TreeMap) DirectoryList(com.google.api.services.discovery.model.DirectoryList)

Example 2 with 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;
}
Also used : Items(com.google.api.services.discovery.model.DirectoryList.Items)

Aggregations

Items (com.google.api.services.discovery.model.DirectoryList.Items)2 ApiKey (com.google.api.server.spi.config.model.ApiKey)1 DirectoryList (com.google.api.services.discovery.model.DirectoryList)1 Icons (com.google.api.services.discovery.model.DirectoryList.Items.Icons)1 RestDescription (com.google.api.services.discovery.model.RestDescription)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1