/** * @see org.jclouds.apis.Apis#withId */ protected ApiMetadata createApiMetadata() { try { return Apis.withId(provider); } catch (NoSuchElementException e) { return null; } }
/** * @see org.jclouds.apis.Apis#withId */ protected ApiMetadata createApiMetadata() { try { return Apis.withId(provider); } catch (NoSuchElementException e) { return null; } }
@Override public ApiMetadata findApiById(String id) { return ToApiMetadata.INSTANCE.apply(Apis.withId(id)); }
/** * @see org.jclouds.apis.Apis#withId */ protected ApiMetadata createApiMetadata() { try { return Apis.withId(provider); } catch (NoSuchElementException e) { return null; } }
/** * @see org.jclouds.apis.Apis#withId */ protected ApiMetadata createApiMetadata() { try { return Apis.withId(provider); } catch (NoSuchElementException e) { return null; } }
/** * Returns true if provider or api is currently installed. * * @param provider * @param api * @return */ private boolean isProviderOrApiInstalled(String provider, String api) { boolean providerOrApiFound = false; try { Providers.withId(provider); providerOrApiFound = true; } catch (Exception ex) { // ignore } try { Apis.withId(api); providerOrApiFound = true; } catch (Exception ex) { // ignore } return providerOrApiFound; }
/** * Returns true if provider or api is currently installed. * * @param provider * @param api * @return */ private boolean isProviderOrApiInstalled(String provider, String api) { boolean providerOrApiFound = false; try { Providers.withId(provider); providerOrApiFound = true; } catch (Exception ex) { // ignore } try { Apis.withId(api); providerOrApiFound = true; } catch (Exception ex) { // ignore } return providerOrApiFound; }
@Test public void testWithId() { ApiMetadata apiMetadata; try { apiMetadata = Apis.withId("fake-id"); fail("Looking for a api with an id that doesn't exist should " + "throw an exception."); } catch (NoSuchElementException nsee) { ; // Expected } apiMetadata = Apis.withId(testBlobstoreApi.getId()); assertEquals(testBlobstoreApi, apiMetadata); }
@Test public void testWithId() { ApiMetadata apiMetadata; try { apiMetadata = Apis.withId("fake-id"); fail("Looking for a api with an id that doesn't exist should " + "throw an exception."); } catch (NoSuchElementException nsee) { // expected } apiMetadata = Apis.withId(testBlobstoreApi.getId()); assertEquals(testBlobstoreApi, apiMetadata); }
public void testEtcdApiRegistered() { ApiMetadata api = Apis.withId("jenkins"); assertNotNull(api); assertTrue(api instanceof JenkinsApiMetadata); assertEquals(api.getId(), "jenkins"); } }
@Test public void testWithId() { ApiMetadata apiMetadata = Apis.withId(toTest.getId()); assertEquals(toTest, apiMetadata); }
@Test public void testWithId() { ApiMetadata apiMetadata = Apis.withId(toTest.getId()); assertEquals(toTest, apiMetadata); }
public void testBitbucketApiRegistered() { final ApiMetadata api = Apis.withId("bitbucket"); assertThat(api).isNotNull(); assertThat(api instanceof BitbucketApiMetadata).isTrue(); assertThat("bitbucket").isEqualTo(api.getId()); } }
public void testDockerApiRegistered() { ApiMetadata api = Apis.withId("docker"); assertNotNull(api); assertTrue(api instanceof DockerApiMetadata); assertEquals(api.getId(), "docker"); }
/** * looks up a provider or api with the given id * * @param providerOrApi * id of the provider or api * @return means to build a context to that provider * @throws NoSuchElementException * if the id was not configured. */ public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { try { try { return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); } catch (NoSuchElementException e) { return ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } } catch (NoSuchElementException e) { Builder<String, String> builder = ImmutableMultimap.<String, String> builder(); builder.putAll("providers", transform(Providers.all(), Providers.idFunction())); builder.putAll("apis", transform(Apis.all(), Apis.idFunction())); throw new NoSuchElementException(String.format("key [%s] not in the list of providers or apis: %s", providerOrApi, builder.build())); } }
/** * looks up a provider or api with the given id * * @param providerOrApi * id of the provider or api * @return means to build a context to that provider * @throws NoSuchElementException * if the id was not configured. */ public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { try { try { return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); } catch (NoSuchElementException e) { return ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } } catch (NoSuchElementException e) { Builder<String, String> builder = ImmutableMultimap.<String, String> builder(); builder.putAll("providers", transform(Providers.all(), Providers.idFunction())); builder.putAll("apis", transform(Apis.all(), Apis.idFunction())); throw new NoSuchElementException(String.format("key [%s] not in the list of providers or apis: %s", providerOrApi, builder.build())); } }
/** * looks up a provider or api with the given id * * @param providerOrApi * id of the provider or api * @return means to build a context to that provider * @throws NoSuchElementException * if the id was not configured. */ public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { try { try { return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); } catch (NoSuchElementException e) { return ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } } catch (NoSuchElementException e) { Builder<String, String> builder = ImmutableMultimap.<String, String> builder(); builder.putAll("providers", transform(Providers.all(), Providers.idFunction())); builder.putAll("apis", transform(Apis.all(), Apis.idFunction())); throw new NoSuchElementException(String.format("key [%s] not in the list of providers or apis: %s", providerOrApi, builder.build())); } }
/** * looks up a provider or api with the given id * * @param providerOrApi * id of the provider or api * @return means to build a context to that provider * @throws NoSuchElementException * if the id was not configured. */ public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { try { try { return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); } catch (NoSuchElementException e) { return ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } } catch (NoSuchElementException e) { Builder<String, String> builder = ImmutableMultimap.<String, String> builder(); builder.putAll("providers", transform(Providers.all(), Providers.idFunction())); builder.putAll("apis", transform(Apis.all(), Apis.idFunction())); throw new NoSuchElementException(String.format("key [%s] not in the list of providers or apis: %s", providerOrApi, builder.build())); } }
@Override public int complete(String buffer, int cursor, List<String> candidates) { try { if (displayApisWithoutService) { for (ApiMetadata apiMetadata : Apis.viewableAs(TypeToken.of(BlobStoreContext.class))) { delegate.getStrings().add(apiMetadata.getId()); } } else if (blobStoreServices != null) { for (BlobStore blobStore : blobStoreServices) { String id = blobStore.getContext().unwrap().getId(); if (Apis.withId(id) != null) { delegate.getStrings().add(id); } } } } catch (Exception ex) { // noop } return delegate.complete(buffer, cursor, candidates); }
@Override public int complete(String buffer, int cursor, List<String> candidates) { try { if (displayApisWithoutService) { for (ApiMetadata apiMetadata : Apis.viewableAs(TypeToken.of(ComputeServiceContext.class))) { delegate.getStrings().add(apiMetadata.getId()); } } else if (computeServices != null) { for (ComputeService computeService : computeServices) { String id = computeService.getContext().unwrap().getId(); if (Apis.withId(id) != null) { delegate.getStrings().add(computeService.getContext().unwrap().getId()); } } } } catch (Exception ex) { // noop } return delegate.complete(buffer, cursor, candidates); }