热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.jclouds.apis.Apis.withId()方法的使用及代码示例

本文整理了Java中org.jclouds.apis.Apis.withId()方法的一些代码示例,展示了Apis.withId()的具体用法

本文整理了Java中org.jclouds.apis.Apis.withId()方法的一些代码示例,展示了Apis.withId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Apis.withId()方法的具体详情如下:
包路径:org.jclouds.apis.Apis
类名称:Apis
方法名:withId

Apis.withId介绍

[英]Returns the first api with the provided id
[中]返回具有所提供id的第一个api

代码示例

代码示例来源:origin: jclouds/legacy-jclouds

/**
* @see org.jclouds.apis.Apis#withId
*/
protected ApiMetadata createApiMetadata() {
try {
return Apis.withId(provider);
} catch (NoSuchElementException e) {
return null;
}
}

代码示例来源:origin: jclouds/legacy-jclouds

/**
* @see org.jclouds.apis.Apis#withId
*/
protected ApiMetadata createApiMetadata() {
try {
return Apis.withId(provider);
} catch (NoSuchElementException e) {
return null;
}
}

代码示例来源:origin: org.apache.jclouds.labs.management/management-core

@Override
public ApiMetadata findApiById(String id) {
return ToApiMetadata.INSTANCE.apply(Apis.withId(id));
}

代码示例来源:origin: apache/jclouds

/**
* @see org.jclouds.apis.Apis#withId
*/
protected ApiMetadata createApiMetadata() {
try {
return Apis.withId(provider);
} catch (NoSuchElementException e) {
return null;
}
}

代码示例来源:origin: apache/jclouds

/**
* @see org.jclouds.apis.Apis#withId
*/
protected ApiMetadata createApiMetadata() {
try {
return Apis.withId(provider);
} catch (NoSuchElementException e) {
return null;
}
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

/**
* 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;
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

/**
* 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;
}

代码示例来源:origin: jclouds/legacy-jclouds

@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);
}

代码示例来源:origin: apache/jclouds

@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);
}

代码示例来源:origin: cdancy/jenkins-rest

public void testEtcdApiRegistered() {
ApiMetadata api = Apis.withId("jenkins");
assertNotNull(api);
assertTrue(api instanceof JenkinsApiMetadata);
assertEquals(api.getId(), "jenkins");
}
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testWithId() {
ApiMetadata apiMetadata = Apis.withId(toTest.getId());
assertEquals(toTest, apiMetadata);
}

代码示例来源:origin: apache/jclouds

@Test
public void testWithId() {
ApiMetadata apiMetadata = Apis.withId(toTest.getId());
assertEquals(toTest, apiMetadata);
}

代码示例来源:origin: cdancy/bitbucket-rest

public void testBitbucketApiRegistered() {
final ApiMetadata api = Apis.withId("bitbucket");
assertThat(api).isNotNull();
assertThat(api instanceof BitbucketApiMetadata).isTrue();
assertThat("bitbucket").isEqualTo(api.getId());
}
}

代码示例来源:origin: apache/jclouds

public void testDockerApiRegistered() {
ApiMetadata api = Apis.withId("docker");
assertNotNull(api);
assertTrue(api instanceof DockerApiMetadata);
assertEquals(api.getId(), "docker");
}

代码示例来源:origin: jclouds/legacy-jclouds

/**
* 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 builder = ImmutableMultimap. 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()));
}
}

代码示例来源:origin: io.cloudsoft.jclouds/jclouds-core

/**
* 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 builder = ImmutableMultimap. 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()));
}
}

代码示例来源:origin: Nextdoor/bender

/**
* 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 builder = ImmutableMultimap. 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()));
}
}

代码示例来源:origin: org.jclouds/jclouds-core

/**
* 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 builder = ImmutableMultimap. 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()));
}
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
public int complete(String buffer, int cursor, List 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);
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
public int complete(String buffer, int cursor, List 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);
}

推荐阅读
author-avatar
nw3344_575
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有