Merge pull request #1141 from jclouds/vcloud-tidy

remove unused code and migrate off obscure annotations
This commit is contained in:
Adrian Cole 2013-01-04 12:25:15 -08:00
commit 545eae0151
42 changed files with 213 additions and 1479 deletions

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import static com.google.common.base.Preconditions.checkNotNull;
@ -27,11 +27,12 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.Catalog;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
@ -40,7 +41,7 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
public class OrgNameAndCatalogNameToEndpoint implements MapBinder {
private final Supplier<Map<String, Org>> orgMap;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@ -55,21 +56,26 @@ public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object catalog = postParams.get("catalogName");
if (org == null && catalog == null)
return defaultCatalog.get().getHref();
return (R) request.toBuilder().endpoint(defaultCatalog.get().getHref()).build();
else if (org == null)
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();
return catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref();
URI endpoint = catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref();
return (R) request.toBuilder().endpoint(endpoint).build();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
}
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import static com.google.common.base.Preconditions.checkNotNull;
@ -27,11 +27,12 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
@ -40,7 +41,7 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
public class OrgNameAndVDCNameToEndpoint implements MapBinder {
private final Supplier<Map<String, Org>> orgNameToVDCEndpoint;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultVDC;
@ -54,21 +55,26 @@ public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVdc = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVdc, 0);
Object vdc = Iterables.get(orgVdc, 1);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object vdc = postParams.get("vdcName");
if (org == null && vdc == null)
return defaultVDC.get().getHref();
return (R) request.toBuilder().endpoint(defaultVDC.get().getHref()).build();
else if (org == null)
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();
return vdc == null ? Iterables.getLast(vdcs.values()).getHref() : vdcs.get(vdc).getHref();
URI endpoint = vdc == null ? Iterables.getLast(vdcs.values()).getHref() : vdcs.get(vdc).getHref();
return (R) request.toBuilder().endpoint(endpoint).build();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get());
}
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,31 +16,30 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
@Singleton
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
public class OrgNameCatalogNameItemNameToEndpoint implements MapBinder {
private final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@ -55,22 +54,26 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object catalog = postParams.get("catalogName");
Object catalogItem = postParams.get("itemName");
if (org == null)
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.get().getName();
try {
Map<String, org.jclouds.vcloud.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getHref();
return (R) request.toBuilder().endpoint(catalogs.get(catalog).get(catalogItem).getHref()).build();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ orgCatalogMap.get());
}
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import static com.google.common.base.Preconditions.checkNotNull;
@ -27,21 +27,21 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
@Singleton
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements MapBinder {
private final Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@ -56,11 +56,11 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object catalog = postParams.get("catalogName");
Object catalogItem = postParams.get("itemName");
if (org == null)
org = defaultOrg.get().getName();
if (catalog == null)
@ -80,8 +80,13 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
+ catalogMap.keySet());
CatalogItem item = catalogMap.get(catalogItem);
return checkNotNull(item.getEntity(), "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity")
.getHref();
URI endpoint = checkNotNull(item.getEntity(),
"item: " + org + "/" + catalog + "/" + catalogItem + " has no entity").getHref();
return (R) request.toBuilder().endpoint(endpoint).build();
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import java.net.URI;
import java.util.Map;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import java.net.URI;
import java.util.Map;

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.net.URI;
@ -27,18 +26,18 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<Object, URI>{
public abstract class OrgNameVDCNameResourceNameToEndpoint implements MapBinder {
protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
protected final Supplier<ReferenceType> defaultOrg;
@ -54,11 +53,11 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVDC = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVDC, 0);
Object vDC = Iterables.get(orgVDC, 1);
Object resource = Iterables.get(orgVDC, 2);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object vDC = postParams.get("vdcName");
Object resource = postParams.get("resourceName");
if (org == null)
org = defaultOrg.get().getName();
if (vDC == null)
@ -71,9 +70,14 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
org.jclouds.vcloud.domain.VDC vDCObject = vDCs.get(vDC);
if (vDCObject == null)
throw new NoSuchElementException("vdc " + vDC + " in org " + org + " not found in " + vDCs.keySet());
return getEndpointOfResourceInVDC(org, vDC, resource, vDCObject);
URI endpoint = getEndpointOfResourceInVDC(org, vDC, resource, vDCObject);
return (R) request.toBuilder().endpoint(endpoint).build();
}
protected abstract URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource, VDC vDCObject);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -40,11 +40,11 @@ import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.binders.BindCatalogItemToXmlPayload;
import org.jclouds.vcloud.binders.OrgNameAndCatalogNameToEndpoint;
import org.jclouds.vcloud.binders.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.vcloud.options.CatalogItemOptions;
import org.jclouds.vcloud.xml.CatalogHandler;
import org.jclouds.vcloud.xml.CatalogItemHandler;
@ -76,9 +76,9 @@ public interface CatalogAsyncClient {
@XMLResponseParser(CatalogHandler.class)
@Fallback(NullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<Catalog> findCatalogInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
@MapBinder(OrgNameAndCatalogNameToEndpoint.class)
ListenableFuture<Catalog> findCatalogInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("catalogName") String catalogName);
/**
* @see CatalogClient#getCatalogItem
@ -96,10 +96,9 @@ public interface CatalogAsyncClient {
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(CatalogItemHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<CatalogItem> findCatalogItemInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
@MapBinder(OrgNameCatalogNameItemNameToEndpoint.class)
ListenableFuture<CatalogItem> findCatalogItemInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("catalogName") String catalogName, @PayloadParam("itemName") String itemName);
/**
* @see CatalogClient#addVAppTemplateOrMediaImageToCatalog

View File

@ -29,11 +29,13 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.binders.OrgNameVDCNameNetworkNameToEndpoint;
import org.jclouds.vcloud.domain.network.OrgNetwork;
import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.vcloud.xml.OrgNetworkHandler;
import com.google.common.util.concurrent.ListenableFuture;
@ -54,10 +56,9 @@ public interface NetworkAsyncClient {
@Consumes(NETWORK_XML)
@XMLResponseParser(OrgNetworkHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<OrgNetwork> findNetworkInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
@MapBinder(OrgNameVDCNameNetworkNameToEndpoint.class)
ListenableFuture<OrgNetwork> findNetworkInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String networkName);
/**
* @see NetworkClient#getNetwork

View File

@ -47,10 +47,10 @@ import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
import org.jclouds.vcloud.binders.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.VAppHandler;
@ -100,10 +100,9 @@ public interface VAppAsyncClient {
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<VApp> findVAppInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
@MapBinder(OrgNameVDCNameResourceEntityNameToEndpoint.class)
ListenableFuture<VApp> findVAppInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String vAppName);
/**
* @see VAppClient#getVApp

View File

@ -49,11 +49,11 @@ import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload;
import org.jclouds.vcloud.binders.BindCloneVAppTemplateParamsToXmlPayload;
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
import org.jclouds.vcloud.binders.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.vcloud.options.CaptureVAppOptions;
import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
@ -142,10 +142,9 @@ public interface VAppTemplateAsyncClient {
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<VAppTemplate> findVAppTemplateInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
@MapBinder(OrgNameCatalogNameVAppTemplateNameToEndpoint.class)
ListenableFuture<VAppTemplate> findVAppTemplateInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("catalogName") String catalogName, @PayloadParam("itemName") String itemName);
/**
* @see VAppTemplateClient#getVAppTemplate

View File

@ -29,11 +29,13 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.binders.OrgNameAndVDCNameToEndpoint;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
import org.jclouds.vcloud.xml.VDCHandler;
import com.google.common.util.concurrent.ListenableFuture;
@ -63,7 +65,7 @@ public interface VDCAsyncClient {
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<VDC> findVDCInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
@MapBinder(OrgNameAndVDCNameToEndpoint.class)
ListenableFuture<VDC> findVDCInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName);
}

View File

@ -60,7 +60,7 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsy
String.class);
HttpRequest request = processor.createRequest(method, "org", "vdc", "network");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
assertPayloadEquals(request, null, null, false);

View File

@ -69,7 +69,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, null, null);
HttpRequest request = processor.createRequest(method, new Object[] { null, null });
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");

View File

@ -64,6 +64,11 @@ import org.jclouds.trmk.vcloud_0_8.binders.BindCloneVAppParamsToXmlPayload;
import org.jclouds.trmk.vcloud_0_8.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
import org.jclouds.trmk.vcloud_0_8.binders.BindNodeConfigurationToXmlPayload;
import org.jclouds.trmk.vcloud_0_8.binders.BindVAppConfigurationToXmlPayload;
import org.jclouds.trmk.vcloud_0_8.binders.OrgNameAndCatalogNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.binders.OrgNameAndVDCNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.binders.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.binders.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.binders.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.domain.Catalog;
import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters;
@ -81,14 +86,8 @@ import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
import org.jclouds.trmk.vcloud_0_8.domain.VDC;
import org.jclouds.trmk.vcloud_0_8.endpoints.Org;
import org.jclouds.trmk.vcloud_0_8.filters.SetVCloudTokenCookie;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameAndCatalogNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameAndTasksListNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameAndVDCNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameVDCNameNetworkNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.ParseTaskFromLocationHeader;
import org.jclouds.trmk.vcloud_0_8.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.VDCURIToPublicIPsEndpoint;
@ -134,10 +133,9 @@ public interface TerremarkVCloudAsyncClient {
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(CatalogItemHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
@MapBinder(OrgNameCatalogNameItemNameToEndpoint.class)
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("catalogName") String catalogName, @PayloadParam("itemName") String itemName);
/**
* @see TerremarkVCloudClient#getCatalogItem
@ -199,9 +197,9 @@ public interface TerremarkVCloudAsyncClient {
@XMLResponseParser(CatalogHandler.class)
@Fallback(NullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
@MapBinder(OrgNameAndCatalogNameToEndpoint.class)
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("catalogName") String catalogName);
/**
* @see VCloudClient#getVAppTemplate
@ -219,10 +217,9 @@ public interface TerremarkVCloudAsyncClient {
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends VAppTemplate> findVAppTemplateInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
@MapBinder(OrgNameCatalogNameVAppTemplateNameToEndpoint.class)
ListenableFuture<? extends VAppTemplate> findVAppTemplateInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("catalogName") String catalogName, @PayloadParam("itemName") String itemName);
/**
* @see VCloudClient#findNetworkInOrgVDCNamed
@ -231,10 +228,9 @@ public interface TerremarkVCloudAsyncClient {
@Consumes(NETWORK_XML)
@XMLResponseParser(NetworkHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends Network> findNetworkInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameNetworkNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameNetworkNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameNetworkNameToEndpoint.class) String networkName);
@MapBinder(OrgNameVDCNameResourceEntityNameToEndpoint.class)
ListenableFuture<? extends Network> findNetworkInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String networkName);
/**
* @see VCloudClient#getNetwork
@ -264,10 +260,9 @@ public interface TerremarkVCloudAsyncClient {
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends VApp> findVAppInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
@MapBinder(OrgNameVDCNameResourceEntityNameToEndpoint.class)
ListenableFuture<? extends VApp> findVAppInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String vAppName);
/**
* @see VCloudClient#getVApp
@ -388,9 +383,9 @@ public interface TerremarkVCloudAsyncClient {
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> findVDCInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
@MapBinder(OrgNameAndVDCNameToEndpoint.class)
ListenableFuture<? extends VDC> findVDCInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName);
/**
* @see TerremarkVCloudClient#instantiateVAppTemplateInVDC

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import static com.google.common.base.Preconditions.checkNotNull;
@ -27,11 +27,12 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.trmk.vcloud_0_8.domain.Org;
import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
import org.jclouds.trmk.vcloud_0_8.endpoints.Catalog;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
@ -40,7 +41,7 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
public class OrgNameAndCatalogNameToEndpoint implements MapBinder {
private final Supplier<Map<String, ? extends Org>> orgMap;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@ -54,21 +55,26 @@ public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object catalog = postParams.get("catalogName");
if (org == null && catalog == null)
return defaultCatalog.get().getHref();
return (R) request.toBuilder().endpoint(defaultCatalog.get().getHref()).build();
else if (org == null)
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();
return catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref();
URI endpoint = catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref();
return (R) request.toBuilder().endpoint(endpoint).build();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
}
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import static com.google.common.base.Preconditions.checkNotNull;
@ -27,11 +27,12 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.trmk.vcloud_0_8.domain.Org;
import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
import org.jclouds.trmk.vcloud_0_8.endpoints.VDC;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
@ -40,7 +41,7 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
public class OrgNameAndVDCNameToEndpoint implements MapBinder {
private final Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultVDC;
@ -54,21 +55,26 @@ public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVdc = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVdc, 0);
Object vdc = Iterables.get(orgVdc, 1);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object vdc = postParams.get("vdcName");
if (org == null && vdc == null)
return defaultVDC.get().getHref();
return (R) request.toBuilder().endpoint(defaultVDC.get().getHref()).build();
else if (org == null)
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();
return vdc == null ? Iterables.getLast(vdcs.values()).getHref() : vdcs.get(vdc).getHref();
URI endpoint = vdc == null ? Iterables.getLast(vdcs.values()).getHref() : vdcs.get(vdc).getHref();
return (R) request.toBuilder().endpoint(endpoint).build();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get());
}
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,31 +16,30 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
import org.jclouds.trmk.vcloud_0_8.endpoints.Catalog;
import org.jclouds.trmk.vcloud_0_8.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
@Singleton
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
public class OrgNameCatalogNameItemNameToEndpoint implements MapBinder {
private final Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog>>> orgCatalogMap;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@ -55,22 +54,26 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object catalog = postParams.get("catalogName");
Object catalogItem = postParams.get("itemName");
if (org == null)
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.get().getName();
try {
Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getHref();
return (R) request.toBuilder().endpoint(catalogs.get(catalog).get(catalogItem).getHref()).build();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ orgCatalogMap.get());
}
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import static com.google.common.base.Preconditions.checkNotNull;
@ -27,21 +27,21 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
import org.jclouds.trmk.vcloud_0_8.endpoints.Catalog;
import org.jclouds.trmk.vcloud_0_8.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
@Singleton
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements MapBinder {
private final Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.CatalogItem>>>> orgCatalogItemMap;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@ -56,11 +56,11 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object catalog = postParams.get("catalogName");
Object catalogItem = postParams.get("itemName");
if (org == null)
org = defaultOrg.get().getName();
if (catalog == null)
@ -80,8 +80,13 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
+ catalogMap.keySet());
CatalogItem item = catalogMap.get(catalogItem);
return checkNotNull(item.getEntity(), "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity")
.getHref();
URI endpoint = checkNotNull(item.getEntity(),
"item: " + org + "/" + catalog + "/" + catalogItem + " has no entity").getHref();
return (R) request.toBuilder().endpoint(endpoint).build();
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import java.net.URI;
import java.util.Map;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import java.net.URI;
import java.util.Map;

View File

@ -16,9 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.trmk.vcloud_0_8.functions;
package org.jclouds.trmk.vcloud_0_8.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.net.URI;
@ -27,18 +26,18 @@ import java.util.NoSuchElementException;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
import org.jclouds.trmk.vcloud_0_8.domain.VDC;
import org.jclouds.trmk.vcloud_0_8.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<Object, URI>{
public abstract class OrgNameVDCNameResourceNameToEndpoint implements MapBinder {
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>>> orgVDCMap;
protected final Supplier<ReferenceType> defaultOrg;
@ -54,11 +53,11 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVDC = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVDC, 0);
Object vDC = Iterables.get(orgVDC, 1);
Object resource = Iterables.get(orgVDC, 2);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
Object org = postParams.get("orgName");
Object vDC = postParams.get("vdcName");
Object resource = postParams.get("resourceName");
if (org == null)
org = defaultOrg.get().getName();
if (vDC == null)
@ -71,9 +70,14 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
org.jclouds.trmk.vcloud_0_8.domain.VDC vDCObject = vDCs.get(vDC);
if (vDCObject == null)
throw new NoSuchElementException("vdc " + vDC + " in org " + org + " not found in " + vDCs.keySet());
return getEndpointOfResourceInVDC(org, vDC, resource, vDCObject);
URI endpoint = getEndpointOfResourceInVDC(org, vDC, resource, vDCObject);
return (R) request.toBuilder().endpoint(endpoint).build();
}
protected abstract URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource, VDC vDCObject);
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
throw new IllegalStateException(getClass() + " needs parameters");
}
}

View File

@ -1,81 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncApi;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
/**
* @author danikov
*/
@Singleton
public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
@Resource
public Logger logger = Logger.NULL;
private final VCloudDirectorAsyncApi aapi;
private final ExecutorService executor;
@Inject
AllCatalogItemsInCatalog(VCloudDirectorAsyncApi aapi, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aapi = aapi;
this.executor = executor;
}
@Override
public Iterable<? extends CatalogItem> apply(Catalog from) {
Iterable<? extends CatalogItem> catalogItems = transformParallel(filter(from.getCatalogItems(), new Predicate<Reference>() {
@Override
public boolean apply(Reference input) {
return input.getType().equals(VCloudDirectorMediaType.CATALOG_ITEM);
}
}), new Function<Reference, Future<? extends CatalogItem>>() {
@Override
public Future<CatalogItem> apply(Reference from) {
return aapi.getCatalogApi().getItem(from.getHref());
}
}, executor, null, logger, "catalogItems in " + from.getHref());
return catalogItems;
}
}

View File

@ -1,59 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
/**
* @author danikov
*/
@Singleton
public class AllCatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> {
private final Function<Org, Iterable<Catalog>> allCatalogsInOrg;
private final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
@Inject
AllCatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg,
Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
this.allCatalogsInOrg = allCatalogsInOrg;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
}
@Override
public Iterable<CatalogItem> apply(Org from) {
return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
new Function<Catalog, Iterable<CatalogItem>>() {
@Override
public Iterable<CatalogItem> apply(Catalog from) {
return allCatalogItemsInCatalog.apply(from);
}
}));
}
}

View File

@ -1,68 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.concurrent.FutureIterables;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncApi;
import com.google.common.base.Function;
/**
* @author danikov
*/
@Singleton
public class AllCatalogsInOrg implements Function<AdminOrg, Iterable<? extends Catalog>> {
@Resource
public Logger logger = Logger.NULL;
private final VCloudDirectorAsyncApi aapi;
private final ExecutorService executor;
@Inject
AllCatalogsInOrg(VCloudDirectorAsyncApi aapi, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aapi = aapi;
this.executor = executor;
}
@Override
public Iterable<? extends Catalog> apply(final AdminOrg org) {
Iterable<? extends Catalog> catalogs = FutureIterables.<Reference, Catalog>transformParallel(org.getCatalogs(),
new Function<Reference, Future<? extends Catalog>>() {
@Override
public Future<? extends Catalog> apply(Reference from) {
return aapi.getCatalogApi().get(from.getHref());
}
}, executor, null, logger, "catalogs in " + org.getName());
return catalogs;
}
}

View File

@ -1,71 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncApi;
import com.google.common.base.Function;
/**
* @author danikov
*/
@Singleton
public class AllVdcsInOrg implements Function<AdminOrg, Iterable<? extends Vdc>> {
@Resource
public Logger logger = Logger.NULL;
private final VCloudDirectorAsyncApi aapi;
private final ExecutorService executor;
@Inject
AllVdcsInOrg(VCloudDirectorAsyncApi aapi, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aapi = aapi;
this.executor = executor;
}
@Override
public Iterable<? extends Vdc> apply(final AdminOrg org) {
Iterable<? extends Vdc> catalogItems = transformParallel(org.getVdcs(),
new Function<Reference, Future<? extends Vdc>>() {
@Override
public Future<? extends Vdc> apply(Reference from) {
return aapi.getVdcApi().get(from.getHref());
}
}, executor, null, logger, "vdcs in org " + org.getName());
return catalogItems;
}
}

View File

@ -1,54 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Iterables.get;
import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.dmtf.ovf.Network;
import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import com.google.common.base.Function;
@Singleton
public class DefaultNetworkNameInTemplate implements Function<VAppTemplate, String> {
@Resource
protected Logger logger = Logger.NULL;
private SectionForVAppTemplate<NetworkSection> networkSelector =
new SectionForVAppTemplate<NetworkSection>(NetworkSection.class);
@Override
public String apply(VAppTemplate vAppTemplate) {
checkArgument(vAppTemplate != null, "vAppTemplate was null!");
vAppTemplate.getSections();
Set<Network> networks = networkSelector.apply(vAppTemplate).getNetworks();
checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate);
if (networks.size() > 1)
logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks);
return get(networks, 0).getName();
}
}

View File

@ -1,78 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates.nameEquals;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
import org.jclouds.vcloud.director.v1_5.endpoints.Catalog;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, AdminOrg>> orgMap;
private final Supplier<Reference> defaultOrg;
private final Supplier<Reference> defaultCatalog;
@Inject
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, AdminOrg>> orgMap,
@org.jclouds.vcloud.director.v1_5.endpoints.Org Supplier<Reference> defaultOrg,
@Catalog Supplier<Reference> defaultCatalog) {
this.orgMap = orgMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
if (org == null && catalog == null)
return defaultCatalog.get().getHref();
else if (org == null)
org = defaultOrg.get().getName();
try {
Set<Reference> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();
return catalog == null ? Iterables.getLast(catalogs).getHref() :
Iterables.find(catalogs, nameEquals((String)catalog)).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
}
}
}

View File

@ -1,77 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates.nameEquals;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg;
import org.jclouds.vcloud.director.v1_5.endpoints.Vdc;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameAndVdcNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, AdminOrg>> orgNameToVdcEndpoint;
private final Supplier<Reference> defaultOrg;
private final Supplier<Reference> defaultVdc;
@Inject
public OrgNameAndVdcNameToEndpoint(Supplier<Map<String, AdminOrg>> orgNameToVDCEndpoint,
@org.jclouds.vcloud.director.v1_5.endpoints.Org Supplier<Reference> defaultOrg, @Vdc Supplier<Reference> defaultVdc) {
this.orgNameToVdcEndpoint = orgNameToVDCEndpoint;
this.defaultOrg = defaultOrg;
this.defaultVdc = defaultVdc;
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVdc = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVdc, 0);
Object vdc = Iterables.get(orgVdc, 1);
if (org == null && vdc == null)
return defaultVdc.get().getHref();
else if (org == null)
org = defaultOrg.get().getName();
try {
Set<Reference> vdcs = checkNotNull(orgNameToVdcEndpoint.get().get(org)).getVdcs();
return vdc == null ? Iterables.getLast(vdcs).getHref() :
Iterables.find(vdcs, nameEquals((String)vdc)).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVdcEndpoint.get());
}
}
}

View File

@ -1,78 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates.nameEquals;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, Catalog>>> orgCatalogMap;
private final Supplier<Reference> defaultOrg;
private final Supplier<Reference> defaultCatalog;
@Inject
public OrgNameCatalogNameItemNameToEndpoint(
Supplier<Map<String, Map<String, Catalog>>> orgCatalogMap,
@Org Supplier<Reference> defaultOrg,
@org.jclouds.vcloud.director.v1_5.endpoints.Catalog Supplier<Reference> defaultCatalog) {
this.orgCatalogMap = orgCatalogMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
if (org == null)
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.get().getName();
try {
Map<String, Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return Iterables.find(catalogs.get(catalog).getCatalogItems(), nameEquals((String)catalogItem)).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ orgCatalogMap.get());
}
}
}

View File

@ -1,87 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.endpoints.Catalog;
import org.jclouds.vcloud.director.v1_5.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap;
private final Supplier<Reference> defaultOrg;
private final Supplier<Reference> defaultCatalog;
@Inject
public OrgNameCatalogNameVAppTemplateNameToEndpoint(
Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap,
@Org Supplier<Reference> defaultOrg, @Catalog Supplier<Reference> defaultCatalog) {
this.orgCatalogItemMap = orgCatalogItemMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
if (org == null)
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.get().getName();
Map<String, Map<String, Map<String, CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
if (!orgCatalogItemMap.containsKey(org))
throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet());
Map<String, Map<String, CatalogItem>> catalogs = orgCatalogItemMap.get(org);
if (!catalogs.containsKey(catalog))
throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet());
Map<String, CatalogItem> catalogMap = catalogs.get(catalog);
if (!catalogMap.containsKey(catalogItem))
throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in "
+ catalogMap.keySet());
CatalogItem item = catalogMap.get(catalogItem);
return checkNotNull(item.getEntity(), "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity")
.getHref();
}
}

View File

@ -1,59 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Reference>> orgNameToEndpointSupplier;
private final Supplier<Reference> defaultOrg;
@Inject
public OrgNameToEndpoint(@Org Supplier<Map<String, Reference>> orgNameToEndpointSupplier,
@Org Supplier<Reference> defaultOrg) {
this.orgNameToEndpointSupplier = orgNameToEndpointSupplier;
this.defaultOrg = defaultOrg;
}
public URI apply(Object from) {
try {
Map<String, Reference> orgNameToEndpoint = orgNameToEndpointSupplier.get();
return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet());
}
}
}

View File

@ -1,64 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import org.jclouds.vcloud.director.v1_5.endpoints.TasksList;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Org>> orgMap;
private final Supplier<Reference> defaultTasksList;
@Inject
public OrgNameToTasksListEndpoint(Supplier<Map<String, Org>> orgMap,
@TasksList Supplier<Reference> defaultTasksList) {
this.orgMap = orgMap;
this.defaultTasksList = defaultTasksList;
}
public URI apply(Object from) {
Object org = from;
if (org == null)
return defaultTasksList.get().getHref();
try {
return checkNotNull(orgMap.get().get(org)).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + " not found in " + orgMap.get());
}
}
}

View File

@ -1,59 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates.nameEquals;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.endpoints.Org;
import org.jclouds.vcloud.director.v1_5.endpoints.Vdc;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameVdcNameNetworkNameToEndpoint extends OrgNameVdcNameResourceNameToEndpoint {
@Inject
public OrgNameVdcNameNetworkNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.director.v1_5.domain.Vdc>>> orgVdcMap,
@Org Supplier<Reference> defaultOrg, @Vdc Supplier<Reference> defaultVdc) {
super(orgVdcMap, defaultOrg, defaultVdc);
}
protected URI getEndpointOfResourceInVdc(Object org, Object Vdc, Object resource,
org.jclouds.vcloud.director.v1_5.domain.Vdc VdcObject) {
Reference resourceEntity = Iterables.find(VdcObject.getAvailableNetworks(), nameEquals((String)Vdc));
if (resourceEntity == null)
throw new NoSuchElementException("network " + resource + " in Vdc " + Vdc + ", org " + org + " not found in "
+ VdcObject.getAvailableNetworks());
return resourceEntity.getHref();
}
}

View File

@ -1,59 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates.nameEquals;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.endpoints.Org;
import org.jclouds.vcloud.director.v1_5.endpoints.Vdc;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
@Singleton
public class OrgNameVdcNameResourceEntityNameToEndpoint extends OrgNameVdcNameResourceNameToEndpoint {
@Inject
public OrgNameVdcNameResourceEntityNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.director.v1_5.domain.Vdc>>> orgVdcMap,
@Org Supplier<Reference> defaultOrg, @Vdc Supplier<Reference> defaultVdc) {
super(orgVdcMap, defaultOrg, defaultVdc);
}
protected URI getEndpointOfResourceInVdc(Object org, Object Vdc, Object resource,
org.jclouds.vcloud.director.v1_5.domain.Vdc VdcObject) {
Reference resourceEntity = Iterables.find(VdcObject.getResourceEntities(), nameEquals((String)resource));
if (resourceEntity == null)
throw new NoSuchElementException("entity " + resource + " in Vdc " + Vdc + ", org " + org + " not found in "
+ VdcObject.getResourceEntities());
return resourceEntity.getHref();
}
}

View File

@ -1,79 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.endpoints.Org;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author danikov
*/
public abstract class OrgNameVdcNameResourceNameToEndpoint implements Function<Object, URI>{
protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.director.v1_5.domain.Vdc>>> orgVdcMap;
protected final Supplier<Reference> defaultOrg;
protected final Supplier<Reference> defaultVdc;
@Inject
public OrgNameVdcNameResourceNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.director.v1_5.domain.Vdc>>> orgVdcMap,
@Org Supplier<Reference> defaultOrg, @org.jclouds.vcloud.director.v1_5.endpoints.Vdc Supplier<Reference> defaultVdc) {
this.orgVdcMap = orgVdcMap;
this.defaultOrg = defaultOrg;
this.defaultVdc = defaultVdc;
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVdc = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVdc, 0);
Object Vdc = Iterables.get(orgVdc, 1);
Object resource = Iterables.get(orgVdc, 2);
if (org == null)
org = defaultOrg.get().getName();
if (Vdc == null)
Vdc = defaultVdc.get().getName();
Map<String, Map<String, org.jclouds.vcloud.director.v1_5.domain.Vdc>> orgToVdcs = orgVdcMap.get();
checkState(orgToVdcs != null, "could not get map of org name to Vdcs!");
Map<String, org.jclouds.vcloud.director.v1_5.domain.Vdc> Vdcs = orgToVdcs.get(org);
if (Vdcs == null)
throw new NoSuchElementException("org " + org + " not found in " + orgToVdcs.keySet());
org.jclouds.vcloud.director.v1_5.domain.Vdc VdcObject = Vdcs.get(Vdc);
if (VdcObject == null)
throw new NoSuchElementException("Vdc " + Vdc + " in org " + org + " not found in " + Vdcs.keySet());
return getEndpointOfResourceInVdc(org, Vdc, resource, VdcObject);
}
protected abstract URI getEndpointOfResourceInVdc(Object org, Object Vdc, Object resource, Vdc VdcObject);
}

View File

@ -1,70 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.collect.FluentIterable.from;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.domain.Location;
import org.jclouds.location.predicates.LocationPredicates;
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorApi;
import com.google.common.base.Function;
/**
* @author danikov, Adrian Cole
*/
@Singleton
public class OrgsForLocations implements Function<Iterable<Location>, Iterable<? extends Org>> {
private final VCloudDirectorApi api;
@Inject
OrgsForLocations(VCloudDirectorApi api) {
this.api = api;
}
/**
* Zones are assignable, but we want regions. so we look for zones, whose parent is region. then,
* we use a set to extract the unique set.
*/
@Override
public Iterable<? extends Org> apply(Iterable<Location> from) {
return from(from)
.filter(LocationPredicates.isZone())
.transform(new Function<Location, String>() {
@Override
public String apply(Location from) {
return from.getParent().getId();
}
})
.transform(new Function<String, Org>() {
@Override
public Org apply(String from) {
return api.getOrgApi().get(from);
}
});
}
}

View File

@ -1,63 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.collect.FluentIterable.from;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorApi;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
* @author danikov
*/
@Singleton
public class OrgsForNames implements Function<Iterable<String>, Iterable<? extends Org>> {
private final VCloudDirectorApi api;
@Inject
OrgsForNames(VCloudDirectorApi api) {
this.api = api;
}
@Override
public Iterable<? extends Org> apply(final Iterable<String> from) {
return from(api.getOrgApi().list()).filter(new Predicate<Reference>() {
@Override
public boolean apply(Reference in) {
return Iterables.contains(from, in.getName());
}
}).transform(new Function<Reference, Org>() {
@Override
public Org apply(Reference in) {
return api.getOrgApi().get(in.getHref());
}
});
}
}

View File

@ -1,37 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import com.google.common.base.Function;
/**
* @author danikov
*/
@Singleton
public class ReferenceToName implements Function<Reference, String> {
@Override
public String apply(Reference from) {
return from.getName();
}
}

View File

@ -1,79 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncApi;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
/**
* @author danikov
*/
@Singleton
public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogItem>, Iterable<? extends VAppTemplate>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
private Logger logger = Logger.NULL;
private final VCloudDirectorAsyncApi aapi;
private final ExecutorService executor;
@Inject
VAppTemplatesForCatalogItems(VCloudDirectorAsyncApi aapi, @Named(PROPERTY_USER_THREADS) ExecutorService executor) {
this.aapi = aapi;
this.executor = executor;
}
@Override
public Iterable<? extends VAppTemplate> apply(Iterable<CatalogItem> from) {
return transformParallel(filter(from, new Predicate<CatalogItem>() {
@Override
public boolean apply(CatalogItem input) {
return input.getEntity().getType().equals(VCloudDirectorMediaType.VAPP_TEMPLATE);
}
}), new Function<CatalogItem, Future<? extends VAppTemplate>>() {
@Override
public Future<? extends VAppTemplate> apply(CatalogItem from) {
return aapi.getVAppTemplateApi().get(from.getEntity().getHref());
}
}, executor, null, logger, "vappTemplates in");
}
}

View File

@ -1,70 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions;
import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.Iterables.filter;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.org.Org;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
/**
* @author danikov
*/
@Singleton
public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>> {
private final Function<Org, Iterable<CatalogItem>> allCatalogItemsInOrg;
private final Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems;
@Inject
VAppTemplatesInOrg(Function<Org, Iterable<CatalogItem>> allCatalogItemsInOrg,
Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems) {
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
}
@Override
public Iterable<VAppTemplate> apply(Org from) {
Iterable<CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
Iterable<VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return filter(vAppTemplates, and(notNull(), new Predicate<VAppTemplate>(){
//TODO: test this
@Override
public boolean apply(VAppTemplate input) {
if (input == null)
return false;
return ImmutableSet.of(Status.RESOLVED, Status.POWERED_OFF).contains(input.getStatus());
}
}));
}
}

View File

@ -55,6 +55,7 @@ import org.jclouds.trmk.ecloud.features.TagOperationsAsyncClient;
import org.jclouds.trmk.ecloud.xml.ECloudOrgHandler;
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
import org.jclouds.trmk.vcloud_0_8.binders.BindCreateKeyToXmlPayload;
import org.jclouds.trmk.vcloud_0_8.binders.OrgNameVDCNameNetworkNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
import org.jclouds.trmk.vcloud_0_8.domain.IpAddress;
import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
@ -65,8 +66,6 @@ import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
import org.jclouds.trmk.vcloud_0_8.domain.VAppExtendedInfo;
import org.jclouds.trmk.vcloud_0_8.filters.SetVCloudTokenCookie;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameVDCNameNetworkNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.OrgURIToKeysListEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.trmk.vcloud_0_8.functions.VDCURIToPublicIPsEndpoint;
@ -230,21 +229,6 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends KeyPair> getKeyPair(@EndpointParam URI keyId);
// TODO
// /**
// * @see TerremarkVCloudClient#configureKeyPair
// */
// @PUT
// @Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
// @Path("/extensions/key/{keyId}")
// @Produces(APPLICATION_XML)
// @Consumes(APPLICATION_XML)
// @XMLResponseParser(KeyPairHandler.class)
// ListenableFuture<? extends KeyPair> configureKeyPair(
// @PathParam("keyId") int keyId,
// @BinderParam(BindKeyPairConfigurationToXmlPayload.class)
// KeyPairConfiguration keyConfiguration);
/**
* @see TerremarkECloudClient#deleteKeyPair
*/
@ -260,10 +244,9 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
@Consumes(NETWORK_XML)
@XMLResponseParser(NetworkHandler.class)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<? extends Network> findNetworkInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameNetworkNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameNetworkNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
@MapBinder(OrgNameVDCNameNetworkNameToEndpoint.class)
ListenableFuture<? extends Network> findNetworkInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName,
@Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String networkName);
/**
* @see TerremarkECloudClient#getNetwork