Search in sources :

Example 1 with DirectoryList

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);
}
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) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) DirectoryList(com.google.api.services.discovery.model.DirectoryList)

Example 2 with DirectoryList

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);
}
Also used : DirectoryList(com.google.api.services.discovery.model.DirectoryList) Test(org.junit.Test)

Example 3 with DirectoryList

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");
}
Also used : DirectoryList(com.google.api.services.discovery.model.DirectoryList) Test(org.junit.Test)

Example 4 with DirectoryList

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));
}
Also used : DirectoryList(com.google.api.services.discovery.model.DirectoryList) Test(org.junit.Test)

Aggregations

DirectoryList (com.google.api.services.discovery.model.DirectoryList)4 Test (org.junit.Test)3 ApiKey (com.google.api.server.spi.config.model.ApiKey)1 Items (com.google.api.services.discovery.model.DirectoryList.Items)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 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1