use of com.google.api.services.discovery.model.DirectoryList 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 in project endpoints-java by cloudendpoints.
the class ProxyingDiscoveryServiceTest method getApiList.
@Test
public void getApiList() throws Exception {
ProxyingDiscoveryService discoveryService = createDiscoveryService(true);
when(provider.getDirectory(SERVER_ROOT)).thenReturn(DIRECTORY);
DirectoryList actual = discoveryService.getApiList(createRequest("discovery/v1/apis"));
assertThat(actual).isEqualTo(DIRECTORY);
}
use of com.google.api.services.discovery.model.DirectoryList in project endpoints-java by cloudendpoints.
the class LocalDiscoveryProviderTest method getDirectory.
@Test
public void getDirectory() throws Exception {
DirectoryList directory = provider.getDirectory(ROOT);
assertThat(directory.getItems().get(0).getDiscoveryRestUrl()).isEqualTo("https://root.appspot.com/api/discovery/v1/apis/foo/v1/rest");
}
use of com.google.api.services.discovery.model.DirectoryList in project endpoints-java by cloudendpoints.
the class ProxyingDiscoveryProviderTest method getDirectory.
@Test
public void getDirectory() throws Exception {
when(directoryRequest.execute()).thenReturn(DIRECTORY);
DirectoryList actual = provider.getDirectory(REWRITTEN_ROOT);
assertThat(actual).isEqualTo(DIRECTORY);
verify(apis).generateDirectory(withConfigs(V1_JSON_API_CONFIG, V2_JSON_API_CONFIG));
}
Aggregations