diff --git a/.gitignore b/.gitignore index e1c23c8b9a..1ce93e0405 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ bin/ *.iws *.DS_STORE TAGS +.metadata/ diff --git a/allloadbalancer/pom.xml b/allloadbalancer/pom.xml index cf757385d0..8d1e2faef5 100644 --- a/allloadbalancer/pom.xml +++ b/allloadbalancer/pom.xml @@ -30,6 +30,11 @@ jclouds-allloadbalancer allloadbalancer + + org.jclouds.provider + cloudloadbalancers-uk + ${project.version} + org.jclouds.provider cloudloadbalancers-us diff --git a/apis/byon/pom.xml b/apis/byon/pom.xml index 345daf1b40..44d0fc548f 100644 --- a/apis/byon/pom.xml +++ b/apis/byon/pom.xml @@ -72,7 +72,7 @@ org.yaml snakeyaml - 1.8 + 1.10 diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java index 69876dc4b1..877ed21638 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -62,6 +62,7 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.google.common.collect.ImmutableSet.Builder; import com.google.common.util.concurrent.UncheckedExecutionException; @@ -186,21 +187,28 @@ public class RunningInstanceToNodeMetadata implements Function data) { String group = null; try { - group = Iterables.getOnlyElement(Iterables.filter(instance.getGroupIds(), new Predicate() { + group = Iterables.getOnlyElement(Iterables.filter(data, new Predicate() { @Override public boolean apply(String input) { - return input.startsWith("jclouds#") && input.endsWith("#" + instance.getRegion()); + return input.startsWith("jclouds#") && input.contains("#" + instance.getRegion()); } - - })).substring(8).replaceAll("#" + instance.getRegion() + "$", ""); + })).split("#")[1]; } catch (NoSuchElementException e) { - logger.debug("no group parsed from %s's security groups: %s", instance.getId(), instance.getGroupIds()); + logger.debug("no group parsed from %s's data: %s", instance.getId(), data); } catch (IllegalArgumentException e) { - logger.debug("too many groups match %s; %s's security groups: %s", "jclouds#", instance.getId(), instance - .getGroupIds()); + logger.debug("too many groups match %s; %s's data: %s", "jclouds#", instance.getId(), data); } return group; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java index 03987761c4..455bd8a60b 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java @@ -217,6 +217,20 @@ public class RunningInstanceToNodeMetadataTest { .hardware(m1_small32().build()).location(provider).build()); } + @Test + public void testGroupNameIsSetWhenCustomKeyNameIsSetAndSecurityGroupIsGenerated() { + checkGroupName(RunningInstance.builder().instanceId("id").imageId("image").instanceType("m1.small") + .instanceState(InstanceState.RUNNING).region("us-east-1").keyName("custom-key") + .groupId("jclouds#groupname#us-east-1").build()); + } + + @Test + public void testGroupNameIsSetWhenCustomSecurityGroupIsSetAndKeyNameIsGenerated() { + checkGroupName(RunningInstance.builder().instanceId("id").imageId("image").instanceType("m1.small") + .instanceState(InstanceState.RUNNING).region("us-east-1").groupId("custom-sec") + .keyName("jclouds#groupname#us-east-1#23").build()); + } + protected RunningInstance firstInstanceFromResource(String resource) { RunningInstance server = Iterables.get(Iterables.get(DescribeInstancesResponseHandlerTest .parseRunningInstances(resource), 0), 0); @@ -239,6 +253,12 @@ public class RunningInstanceToNodeMetadataTest { return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage); } + private void checkGroupName(RunningInstance instance) { + assertEquals("groupname", createNodeParser(ImmutableSet. of(), ImmutableSet + . of(), ImmutableSet. of(), ImmutableMap. of()) + .apply(instance).getGroup()); + } + private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet hardware, final ImmutableSet locations, Map credentialStore, Map instanceToNodeState, LoadingCache instanceToImage) { diff --git a/apis/s3/pom.xml b/apis/s3/pom.xml index 470ba6ccbf..4a29312792 100644 --- a/apis/s3/pom.xml +++ b/apis/s3/pom.xml @@ -46,7 +46,7 @@ com.jamesmurty.utils java-xmlbuilder - 0.3 + 0.4 org.jclouds.common diff --git a/apis/vcloud/pom.xml b/apis/vcloud/pom.xml index 91e9385e4e..1c8c524ab2 100644 --- a/apis/vcloud/pom.xml +++ b/apis/vcloud/pom.xml @@ -48,7 +48,7 @@ com.jamesmurty.utils java-xmlbuilder - 0.3 + 0.4 org.jclouds diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index a6aebc28e7..5dc5f7e607 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -52,6 +52,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; +import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; import com.jamesmurty.utils.XMLBuilder; @@ -67,7 +68,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder protected final String ns; protected final String schema; protected final BindToStringPayload stringBinder; - protected final ReferenceType defaultNetwork; + protected final Supplier defaultNetwork; protected final FenceMode defaultFenceMode; protected final LoadingCache templateCache; protected final Function defaultNetworkNameInTemplate; @@ -76,7 +77,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder public BindInstantiateVAppTemplateParamsToXmlPayload(LoadingCache templateCache, @Network Function defaultNetworkNameInTemplate, BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, - @Network ReferenceType network, FenceMode fenceMode) { + @Network Supplier network, FenceMode fenceMode) { this.templateCache = templateCache; this.defaultNetworkNameInTemplate = defaultNetworkNameInTemplate; this.ns = ns; @@ -98,7 +99,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder Set networkConfig = null; NetworkConfigDecorator networkConfigDecorator = new NetworkConfigDecorator(templateCache.getUnchecked(template), - defaultNetwork.getHref(), defaultFenceMode, defaultNetworkNameInTemplate); + defaultNetwork.get().getHref(), defaultFenceMode, defaultNetworkNameInTemplate); InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java index 19499dd7c5..1e30db8269 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java @@ -51,6 +51,8 @@ import org.jclouds.vcloud.functions.VAppTemplatesInOrg; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; import com.google.inject.Provides; @@ -108,8 +110,16 @@ public class VCloudComputeServiceDependenciesModule extends AbstractModule { @Provides @Singleton - public NetworkConfig networkConfig(@Network ReferenceType network, FenceMode defaultFenceMode) { - return new NetworkConfig(network.getName(), network.getHref(), defaultFenceMode); + public Supplier networkConfig(@Network Supplier network, + final FenceMode defaultFenceMode) { + return Suppliers.compose(new Function() { + + @Override + public NetworkConfig apply(ReferenceType input) { + return new NetworkConfig(input.getName(), input.getHref(), defaultFenceMode); + } + + }, network); } } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index 823bd76aed..d40f391d31 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -57,6 +57,7 @@ import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.base.Predicate; +import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; @@ -72,13 +73,13 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA protected final VCloudClient client; protected final Predicate successTester; protected final LoadingCache vAppTemplates; - protected final NetworkConfig defaultNetworkConfig; + protected final Supplier defaultNetworkConfig; protected final String buildVersion; @Inject protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(VCloudClient client, Predicate successTester, LoadingCache vAppTemplates, - NetworkConfig defaultNetworkConfig, @Named(PROPERTY_BUILD_VERSION) String buildVersion) { + Supplier defaultNetworkConfig, @Named(PROPERTY_BUILD_VERSION) String buildVersion) { this.client = client; this.successTester = successTester; this.vAppTemplates = vAppTemplates; @@ -142,9 +143,9 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA // if we only have a disconnected network, let's add a new section for the upstream // TODO: remove the disconnected entry if (networkWithNoIpAllocation.apply(networkToConnect)) - config = defaultNetworkConfig; + config = defaultNetworkConfig.get(); else - config = defaultNetworkConfig.toBuilder().networkName(networkToConnect.getName()).build(); + config = defaultNetworkConfig.get().toBuilder().networkName(networkToConnect.getName()).build(); // note that in VCD 1.5, the network name after instantiation will be the same as the parent InstantiateVAppTemplateOptions options = addNetworkConfig(config); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java index f328a9545e..143e9d601d 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java @@ -34,13 +34,14 @@ import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfig import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; /** * * @author Adrian Cole */ @Singleton -public class DefaultOrgForUser implements Function { +public class DefaultOrgForUser implements Function> { private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; private final Supplier sessionSupplier; @@ -55,10 +56,16 @@ public class DefaultOrgForUser implements Function { } @Override - public ReferenceType apply(String user) { - VCloudSession session = sessionSupplier.get(); - checkState(session != null, "could not retrieve Session at %s", user); - return selector.apply(session.getOrgs().values()); + public Supplier apply(final String user) { + return Suppliers.compose(new Function() { + + @Override + public ReferenceType apply(VCloudSession session) { + checkState(session != null, "could not retrieve Session at %s", user); + return selector.apply(session.getOrgs().values()); + } + + }, sessionSupplier); } } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java index 78f4f65074..708f119007 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java @@ -57,7 +57,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.vcloud.endpoints.Org @Singleton - protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, + protected Supplier provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, @Named(PROPERTY_IDENTITY) String user) { return defaultOrgURIForUser.apply(user); } @@ -72,17 +72,17 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.vcloud.endpoints.TasksList @Singleton - protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { - return defaultTasksListURIForOrg.apply(defaultOrg); + protected Supplier provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg, + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(defaultTasksListURIForOrg, defaultOrg); } @Provides @org.jclouds.vcloud.endpoints.Catalog @Singleton - protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { - return defaultCatalogURIForOrg.apply(defaultOrg); + protected Supplier provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg, + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg); } @Provides @@ -146,9 +146,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.vcloud.endpoints.VDC @Singleton - protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { - return defaultVDCURIForOrg.apply(defaultOrg); + protected Supplier provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg, + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(defaultVDCURIForOrg, defaultOrg); } @Provides @@ -161,9 +161,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.vcloud.endpoints.Network @Singleton - protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC, - @org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) { - return defaultNetworkURIForVDC.apply(defaultVDC); + protected Supplier provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC, + @org.jclouds.vcloud.endpoints.VDC Supplier defaultVDC) { + return Suppliers.compose(defaultNetworkURIForVDC, defaultVDC); } @Provides diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index 270546727f..ddc950c37d 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -316,8 +316,15 @@ public class VCloudRestClientModule extends RestClientModule cache) { - return checkNotNull(cache.get().getVCloudToken(), "No token present in session"); + @Singleton + Supplier provideVCloudToken(Supplier cache) { + return Suppliers.compose(new Function() { + + @Override + public String apply(VCloudSession input) { + return checkNotNull(input.getVCloudToken(), "No token present in session"); + } + }, cache); } @Provides @@ -419,9 +426,16 @@ public class VCloudRestClientModule extends RestClientModule> orgSupplier, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { - return orgSupplier.get().get(defaultOrg.getName()); + protected Supplier provideOrg(final Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(new Function() { + + @Override + public Org apply(ReferenceType input) { + return orgSupplier.get().get(input.getName()); + + } + }, defaultOrg); } @Provides diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/SetVCloudTokenCookie.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/SetVCloudTokenCookie.java index cacd55862f..62da6224a7 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/SetVCloudTokenCookie.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/SetVCloudTokenCookie.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.filters; import javax.inject.Inject; -import javax.inject.Provider; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; @@ -29,6 +28,8 @@ import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.utils.ModifyRequest; import org.jclouds.vcloud.VCloudToken; +import com.google.common.base.Supplier; + /** * Adds the VCloud Token to the request as a cookie * @@ -37,10 +38,10 @@ import org.jclouds.vcloud.VCloudToken; */ @Singleton public class SetVCloudTokenCookie implements HttpRequestFilter { - private Provider vcloudTokenProvider; + private Supplier vcloudTokenProvider; @Inject - public SetVCloudTokenCookie(@VCloudToken Provider authTokenProvider) { + public SetVCloudTokenCookie(@VCloudToken Supplier authTokenProvider) { this.vcloudTokenProvider = authTokenProvider; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java index 7ced169d91..4ab10367cc 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java @@ -42,12 +42,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndCatalogNameToEndpoint implements Function { private final Supplier> orgMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultCatalog; + private final Supplier defaultOrg; + private final Supplier defaultCatalog; @Inject public OrgNameAndCatalogNameToEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg, + @Catalog Supplier defaultCatalog) { this.orgMap = orgMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -59,9 +60,9 @@ public class OrgNameAndCatalogNameToEndpoint implements Function { Object org = Iterables.get(orgCatalog, 0); Object catalog = Iterables.get(orgCatalog, 1); if (org == null && catalog == null) - return defaultCatalog.getHref(); + return defaultCatalog.get().getHref(); else if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); try { Map catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs(); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java index b34a9a293e..0814fcfcde 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java @@ -42,12 +42,12 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndVDCNameToEndpoint implements Function { private final Supplier> orgNameToVDCEndpoint; - private final ReferenceType defaultOrg; - private final ReferenceType defaultVDC; + private final Supplier defaultOrg; + private final Supplier defaultVDC; @Inject public OrgNameAndVDCNameToEndpoint(Supplier> orgNameToVDCEndpoint, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg, @VDC Supplier defaultVDC) { this.orgNameToVDCEndpoint = orgNameToVDCEndpoint; this.defaultOrg = defaultOrg; this.defaultVDC = defaultVDC; @@ -59,9 +59,9 @@ public class OrgNameAndVDCNameToEndpoint implements Function { Object org = Iterables.get(orgVdc, 0); Object vdc = Iterables.get(orgVdc, 1); if (org == null && vdc == null) - return defaultVDC.getHref(); + return defaultVDC.get().getHref(); else if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); try { Map vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs(); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java index c62d712fac..4a72203bf6 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java @@ -42,13 +42,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameCatalogNameItemNameToEndpoint implements Function { private final Supplier>> orgCatalogMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultCatalog; + private final Supplier defaultOrg; + private final Supplier defaultCatalog; @Inject public OrgNameCatalogNameItemNameToEndpoint( Supplier>> orgCatalogMap, - @Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { + @Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { this.orgCatalogMap = orgCatalogMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -61,9 +61,9 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function catalogs = checkNotNull(orgCatalogMap.get().get(org)); return catalogs.get(catalog).get(catalogItem).getHref(); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java index 01aed9bf5e..dca8f5f2bb 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java @@ -43,13 +43,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function { private final Supplier>>> orgCatalogItemMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultCatalog; + private final Supplier defaultOrg; + private final Supplier defaultCatalog; @Inject public OrgNameCatalogNameVAppTemplateNameToEndpoint( Supplier>>> orgCatalogItemMap, - @Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { + @Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { this.orgCatalogItemMap = orgCatalogItemMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -62,9 +62,9 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function>> orgCatalogItemMap = this.orgCatalogItemMap.get(); if (!orgCatalogItemMap.containsKey(org)) diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java index fc1b37647f..139282c438 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java @@ -38,11 +38,11 @@ import com.google.common.base.Supplier; @Singleton public class OrgNameToEndpoint implements Function { private final Supplier> orgNameToEndpointSupplier; - private final ReferenceType defaultOrg; + private final Supplier defaultOrg; @Inject public OrgNameToEndpoint(@Org Supplier> orgNameToEndpointSupplier, - @Org ReferenceType defaultOrg) { + @Org Supplier defaultOrg) { this.orgNameToEndpointSupplier = orgNameToEndpointSupplier; this.defaultOrg = defaultOrg; } @@ -50,7 +50,7 @@ public class OrgNameToEndpoint implements Function { public URI apply(Object from) { try { Map orgNameToEndpoint = orgNameToEndpointSupplier.get(); - return from == null ? defaultOrg.getHref() : orgNameToEndpoint.get(from).getHref(); + return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref(); } catch (NullPointerException e) { throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet()); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java index f4897da452..bd630218ba 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java @@ -41,11 +41,11 @@ import com.google.common.base.Supplier; @Singleton public class OrgNameToTasksListEndpoint implements Function { private final Supplier> orgMap; - private final ReferenceType defaultTasksList; + private final Supplier defaultTasksList; @Inject public OrgNameToTasksListEndpoint(Supplier> orgMap, - @TasksList ReferenceType defaultTasksList) { + @TasksList Supplier defaultTasksList) { this.orgMap = orgMap; this.defaultTasksList = defaultTasksList; } @@ -53,7 +53,7 @@ public class OrgNameToTasksListEndpoint implements Function { public URI apply(Object from) { Object org = from; if (org == null) - return defaultTasksList.getHref(); + return defaultTasksList.get().getHref(); try { return checkNotNull(orgMap.get().get(org)).getTasksList().getHref(); } catch (NullPointerException e) { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameNetworkNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameNetworkNameToEndpoint.java index e7ed133dfd..a505791e9f 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameNetworkNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameNetworkNameToEndpoint.java @@ -40,7 +40,7 @@ public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceN @Inject public OrgNameVDCNameNetworkNameToEndpoint( Supplier>> orgVDCMap, - @Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { + @Org Supplier defaultOrg, @VDC Supplier defaultVDC) { super(orgVDCMap, defaultOrg, defaultVDC); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java index fc323b35a2..d94a03a892 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java @@ -40,7 +40,7 @@ public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameRe @Inject public OrgNameVDCNameResourceEntityNameToEndpoint( Supplier>> orgVDCMap, - @Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { + @Org Supplier defaultOrg, @VDC Supplier defaultVDC) { super(orgVDCMap, defaultOrg, defaultVDC); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceNameToEndpoint.java index f383a2a026..07147b0245 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceNameToEndpoint.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceNameToEndpoint.java @@ -41,13 +41,13 @@ import com.google.common.collect.Iterables; public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function{ protected final Supplier>> orgVDCMap; - protected final ReferenceType defaultOrg; - protected final ReferenceType defaultVDC; + protected final Supplier defaultOrg; + protected final Supplier defaultVDC; @Inject public OrgNameVDCNameResourceNameToEndpoint( Supplier>> orgVDCMap, - @Org ReferenceType defaultOrg, @org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) { + @Org Supplier defaultOrg, @org.jclouds.vcloud.endpoints.VDC Supplier defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultOrg = defaultOrg; this.defaultVDC = defaultVDC; @@ -60,9 +60,9 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function< Object vDC = Iterables.get(orgVDC, 1); Object resource = Iterables.get(orgVDC, 2); if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); if (vDC == null) - vDC = defaultVDC.getName(); + vDC = defaultVDC.get().getName(); Map> orgToVDCs = orgVDCMap.get(); checkState(orgToVDCs != null, "could not get map of org name to vdcs!"); Map vDCs = orgToVDCs.get(org); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java index c4d3a83e6e..21c30f2c3d 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java @@ -55,15 +55,16 @@ public class DefaultVDC implements ImplicitLocationSupplier { @Singleton public static class IsDefaultVDC implements Predicate { - private final ReferenceType defaultVDC; + private final Supplier defaultVDCSupplier; @Inject - IsDefaultVDC(@VDC ReferenceType defaultVDC) { - this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC"); + IsDefaultVDC(@VDC Supplier defaultVDCSupplier) { + this.defaultVDCSupplier = checkNotNull(defaultVDCSupplier, "defaultVDCSupplier"); } @Override public boolean apply(Location input) { + ReferenceType defaultVDC = defaultVDCSupplier.get(); return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString()); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index c5647b7ce8..1b5151563e 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -49,6 +49,8 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.base.Functions; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -102,9 +104,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { @Network @Provides @Singleton - ReferenceType provideNetwork() { - return new ReferenceTypeImpl(null, null, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")); + Supplier provideNetwork() { + return Suppliers.ofInstance(new ReferenceTypeImpl(null, null, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"))); } })); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/SetVCloudTokenCookieTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/SetVCloudTokenCookieTest.java index 1ee62b9fd1..dd46999749 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/SetVCloudTokenCookieTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/SetVCloudTokenCookieTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals; import java.net.URI; -import javax.inject.Provider; import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpRequest; @@ -30,6 +29,8 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import com.google.common.base.Supplier; + /** * @author Adrian Cole */ @@ -40,7 +41,7 @@ public class SetVCloudTokenCookieTest { @BeforeTest void setUp() { - filter = new SetVCloudTokenCookie(new Provider() { + filter = new SetVCloudTokenCookie(new Supplier() { public String get() { return "token"; } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java index 90ec8dfbd5..96b696cf30 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java @@ -139,9 +139,9 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { } @Override - protected Org provideOrg(Supplier> orgSupplier, - @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { - return ORG; + protected Supplier provideOrg(Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { + return Suppliers.ofInstance(ORG); } @Override @@ -150,14 +150,18 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { @Override protected void configure() { - bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(ORG_REF); - bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( - CATALOG_REF); - bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( - TASKSLIST_REF); - bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(VDC_REF); - bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( - NETWORK_REF); + TypeLiteral> refTypeSupplier = new TypeLiteral>() { + }; + bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance( + Suppliers. ofInstance(ORG_REF)); + bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( + Suppliers. ofInstance(CATALOG_REF)); + bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( + Suppliers. ofInstance(TASKSLIST_REF)); + bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance( + Suppliers. ofInstance(VDC_REF)); + bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( + Suppliers. ofInstance(NETWORK_REF)); } }); diff --git a/common/trmk/pom.xml b/common/trmk/pom.xml index 59710c4a34..f4c3d1e712 100644 --- a/common/trmk/pom.xml +++ b/common/trmk/pom.xml @@ -43,7 +43,7 @@ com.jamesmurty.utils java-xmlbuilder - 0.3 + 0.4 org.jclouds diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index ef0e72acad..cdf12faa03 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -48,6 +48,7 @@ import org.jclouds.trmk.vcloud_0_8.endpoints.Network; import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions; import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.NetworkConfig; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -67,13 +68,13 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder private final BindToStringPayload stringBinder; protected final Map virtualHardwareToInstanceId = ImmutableMap.of(ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9"); - private final ReferenceType defaultNetwork; + private final Supplier defaultNetwork; private final String defaultFenceMode; @Inject public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, - @Network ReferenceType network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) { + @Network Supplier network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) { this.ns = ns; this.schema = schema; this.stringBinder = stringBinder; @@ -93,7 +94,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder SortedMap virtualHardwareQuantity = Maps.newTreeMap(); InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest); - String network = (defaultNetwork != null) ? defaultNetwork.getHref().toASCIIString() : null; + String network = (defaultNetwork != null) ? defaultNetwork.get().getHref().toASCIIString() : null; String fenceMode = defaultFenceMode; String networkName = name; if (options != null) { diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultOrgForUser.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultOrgForUser.java index 090cc2f236..448489b3ab 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultOrgForUser.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultOrgForUser.java @@ -34,13 +34,14 @@ import org.jclouds.trmk.vcloud_0_8.suppliers.OnlyReferenceTypeFirstWithNameMatch import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; /** * * @author Adrian Cole */ @Singleton -public class DefaultOrgForUser implements Function { +public class DefaultOrgForUser implements Function> { private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; private final Supplier sessionSupplier; @@ -55,10 +56,16 @@ public class DefaultOrgForUser implements Function { } @Override - public ReferenceType apply(String user) { - VCloudSession session = sessionSupplier.get(); - checkState(session != null, "could not retrieve Session at %s", user); - return selector.apply(session.getOrgs().values()); + public Supplier apply(final String user) { + return Suppliers.compose(new Function() { + + @Override + public ReferenceType apply(VCloudSession session) { + checkState(session != null, "could not retrieve Session at %s", user); + return selector.apply(session.getOrgs().values()); + } + + }, sessionSupplier); } } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java index 7f8611d8ce..59e765640b 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java @@ -54,7 +54,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.trmk.vcloud_0_8.endpoints.Org @Singleton - protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, + protected Supplier provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, @Named(PROPERTY_IDENTITY) String user) { return defaultOrgURIForUser.apply(user); } @@ -69,9 +69,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.trmk.vcloud_0_8.endpoints.TasksList @Singleton - protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) { - return defaultTasksListURIForOrg.apply(defaultOrg); + protected Supplier provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg, + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(defaultTasksListURIForOrg, defaultOrg); } @Provides @@ -84,9 +84,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.trmk.vcloud_0_8.endpoints.Catalog @Singleton - protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) { - return defaultCatalogURIForOrg.apply(defaultOrg); + protected Supplier provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg, + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg); } @Provides @@ -121,9 +121,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.trmk.vcloud_0_8.endpoints.VDC @Singleton - protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) { - return defaultVDCURIForOrg.apply(defaultOrg); + protected Supplier provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg, + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(defaultVDCURIForOrg, defaultOrg); } @Provides @@ -136,9 +136,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @Provides @org.jclouds.trmk.vcloud_0_8.endpoints.Network @Singleton - protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC, - @org.jclouds.trmk.vcloud_0_8.endpoints.VDC ReferenceType defaultVDC) { - return defaultNetworkURIForVDC.apply(defaultVDC); + protected Supplier provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC, + @org.jclouds.trmk.vcloud_0_8.endpoints.VDC Supplier defaultVDC) { + return Suppliers.compose(defaultNetworkURIForVDC, defaultVDC); } @Provides diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java index 2a6a745efb..2d0c46c4a1 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java @@ -352,10 +352,17 @@ public class TerremarkVCloudRestClientModule> orgSupplier, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) { - return orgSupplier.get().get(defaultOrg.getName()); + protected Supplier provideOrg( + final Supplier> orgSupplier, + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg) { + return Suppliers.compose(new Function() { + + @Override + public org.jclouds.trmk.vcloud_0_8.domain.Org apply(ReferenceType input) { + return orgSupplier.get().get(input.getName()); + + } + }, defaultOrg); } @Provides diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndCatalogNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndCatalogNameToEndpoint.java index cd7c6532e6..9d771e3c40 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndCatalogNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndCatalogNameToEndpoint.java @@ -42,12 +42,12 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndCatalogNameToEndpoint implements Function { private final Supplier> orgMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultCatalog; + private final Supplier defaultOrg; + private final Supplier defaultCatalog; @Inject public OrgNameAndCatalogNameToEndpoint(Supplier> orgMap, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { this.orgMap = orgMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -59,9 +59,9 @@ public class OrgNameAndCatalogNameToEndpoint implements Function { Object org = Iterables.get(orgCatalog, 0); Object catalog = Iterables.get(orgCatalog, 1); if (org == null && catalog == null) - return defaultCatalog.getHref(); + return defaultCatalog.get().getHref(); else if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); try { Map catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java index 31830cc0b2..32f57ca13e 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndTasksListNameToEndpoint.java @@ -42,12 +42,12 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndTasksListNameToEndpoint implements Function { private final Supplier> orgMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultTasksList; + private final Supplier defaultOrg; + private final Supplier defaultTasksList; @Inject public OrgNameAndTasksListNameToEndpoint(Supplier> orgMap, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg, @TasksList ReferenceType defaultTasksList) { + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg, @TasksList Supplier defaultTasksList) { this.orgMap = orgMap; this.defaultOrg = defaultOrg; this.defaultTasksList = defaultTasksList; @@ -59,9 +59,9 @@ public class OrgNameAndTasksListNameToEndpoint implements Function Object org = Iterables.get(orgTasksList, 0); Object tasksList = Iterables.get(orgTasksList, 1); if (org == null && tasksList == null) - return defaultTasksList.getHref(); + return defaultTasksList.get().getHref(); else if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); try { Map tasksLists = checkNotNull(orgMap.get().get(org)).getTasksLists(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndVDCNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndVDCNameToEndpoint.java index 09645d872d..bb3f4316e6 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndVDCNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameAndVDCNameToEndpoint.java @@ -42,12 +42,12 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndVDCNameToEndpoint implements Function { private final Supplier> orgNameToVDCEndpoint; - private final ReferenceType defaultOrg; - private final ReferenceType defaultVDC; + private final Supplier defaultOrg; + private final Supplier defaultVDC; @Inject public OrgNameAndVDCNameToEndpoint(Supplier> orgNameToVDCEndpoint, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultOrg, @VDC Supplier defaultVDC) { this.orgNameToVDCEndpoint = orgNameToVDCEndpoint; this.defaultOrg = defaultOrg; this.defaultVDC = defaultVDC; @@ -59,9 +59,9 @@ public class OrgNameAndVDCNameToEndpoint implements Function { Object org = Iterables.get(orgVdc, 0); Object vdc = Iterables.get(orgVdc, 1); if (org == null && vdc == null) - return defaultVDC.getHref(); + return defaultVDC.get().getHref(); else if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); try { Map vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameItemNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameItemNameToEndpoint.java index b17c78607f..ed3da26fad 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameItemNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameItemNameToEndpoint.java @@ -42,13 +42,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameCatalogNameItemNameToEndpoint implements Function { private final Supplier>> orgCatalogMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultCatalog; + private final Supplier defaultOrg; + private final Supplier defaultCatalog; @Inject public OrgNameCatalogNameItemNameToEndpoint( Supplier>> orgCatalogMap, - @Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { + @Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { this.orgCatalogMap = orgCatalogMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -61,9 +61,9 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function catalogs = checkNotNull(orgCatalogMap.get().get(org)); return catalogs.get(catalog).get(catalogItem).getHref(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java index 792bc045aa..a9ac582958 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java @@ -43,13 +43,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function { private final Supplier>>> orgCatalogItemMap; - private final ReferenceType defaultOrg; - private final ReferenceType defaultCatalog; + private final Supplier defaultOrg; + private final Supplier defaultCatalog; @Inject public OrgNameCatalogNameVAppTemplateNameToEndpoint( Supplier>>> orgCatalogItemMap, - @Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { + @Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { this.orgCatalogItemMap = orgCatalogItemMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -62,9 +62,9 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function>> orgCatalogItemMap = this.orgCatalogItemMap.get(); if (!orgCatalogItemMap.containsKey(org)) diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java index 11737a0261..2bae10e3f6 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameToEndpoint.java @@ -38,11 +38,11 @@ import com.google.common.base.Supplier; @Singleton public class OrgNameToEndpoint implements Function { private final Supplier> orgNameToEndpointSupplier; - private final ReferenceType defaultOrg; + private final Supplier defaultOrg; @Inject public OrgNameToEndpoint(@Org Supplier> orgNameToEndpointSupplier, - @Org ReferenceType defaultOrg) { + @Org Supplier defaultOrg) { this.orgNameToEndpointSupplier = orgNameToEndpointSupplier; this.defaultOrg = defaultOrg; } @@ -50,7 +50,7 @@ public class OrgNameToEndpoint implements Function { public URI apply(Object from) { try { Map orgNameToEndpoint = orgNameToEndpointSupplier.get(); - return from == null ? defaultOrg.getHref() : orgNameToEndpoint.get(from).getHref(); + return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref(); } catch (NullPointerException e) { throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet()); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameNetworkNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameNetworkNameToEndpoint.java index 1454fdefa7..d6ffbee23c 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameNetworkNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameNetworkNameToEndpoint.java @@ -40,7 +40,7 @@ public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceN @Inject public OrgNameVDCNameNetworkNameToEndpoint( Supplier>> orgVDCMap, - @Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { + @Org Supplier defaultOrg, @VDC Supplier defaultVDC) { super(orgVDCMap, defaultOrg, defaultVDC); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java index be098b399d..0aa275ae6d 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java @@ -40,7 +40,7 @@ public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameRe @Inject public OrgNameVDCNameResourceEntityNameToEndpoint( Supplier>> orgVDCMap, - @Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { + @Org Supplier defaultOrg, @VDC Supplier defaultVDC) { super(orgVDCMap, defaultOrg, defaultVDC); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceNameToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceNameToEndpoint.java index 1a0426c244..4255487d28 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceNameToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgNameVDCNameResourceNameToEndpoint.java @@ -41,13 +41,13 @@ import com.google.common.collect.Iterables; public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function{ protected final Supplier>> orgVDCMap; - protected final ReferenceType defaultOrg; - protected final ReferenceType defaultVDC; + protected final Supplier defaultOrg; + protected final Supplier defaultVDC; @Inject public OrgNameVDCNameResourceNameToEndpoint( Supplier>> orgVDCMap, - @Org ReferenceType defaultOrg, @org.jclouds.trmk.vcloud_0_8.endpoints.VDC ReferenceType defaultVDC) { + @Org Supplier defaultOrg, @org.jclouds.trmk.vcloud_0_8.endpoints.VDC Supplier defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultOrg = defaultOrg; this.defaultVDC = defaultVDC; @@ -60,9 +60,9 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function< Object vDC = Iterables.get(orgVDC, 1); Object resource = Iterables.get(orgVDC, 2); if (org == null) - org = defaultOrg.getName(); + org = defaultOrg.get().getName(); if (vDC == null) - vDC = defaultVDC.getName(); + vDC = defaultVDC.get().getName(); Map> orgToVDCs = orgVDCMap.get(); checkState(orgToVDCs != null, "could not get map of org name to vdcs!"); Map vDCs = orgToVDCs.get(org); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java index e160e47122..316d9aa82a 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToEndpoint.java @@ -36,10 +36,10 @@ import com.google.common.collect.Maps; public abstract class OrgURIToEndpoint implements Function { protected final Supplier> orgMap; - protected final ReferenceType defaultOrg; + protected final Supplier defaultOrg; public OrgURIToEndpoint(Supplier> orgMap, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultUri) { + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultUri) { this.orgMap = orgMap; this.defaultOrg = defaultUri; } @@ -54,7 +54,7 @@ public abstract class OrgURIToEndpoint implements Function { }); try { - Org org = uriToOrg.get(from == null ? defaultOrg.getHref() : from); + Org org = uriToOrg.get(from == null ? defaultOrg.get().getHref() : from); return getUriFromOrg(org); } catch (NullPointerException e) { throw new ResourceNotFoundException("org " + from + " not found in: " + uriToOrg, e); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java index 5de013abda..ccc5df350a 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/OrgURIToKeysListEndpoint.java @@ -38,7 +38,7 @@ import com.google.common.base.Supplier; public class OrgURIToKeysListEndpoint extends OrgURIToEndpoint implements Function { @Inject public OrgURIToKeysListEndpoint(Supplier> orgMap, - @org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultUri) { + @org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier defaultUri) { super(orgMap, defaultUri); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java index ca955f92d6..8082750904 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToInternetServicesEndpoint.java @@ -38,18 +38,18 @@ import com.google.common.base.Supplier; @Singleton public class VDCURIToInternetServicesEndpoint implements Function { private final Supplier> orgVDCMap; - private final ReferenceType defaultVDC; + private final Supplier defaultVDC; @Inject public VDCURIToInternetServicesEndpoint( - Supplier> orgVDCMap, @VDC ReferenceType defaultVDC) { + Supplier> orgVDCMap, @VDC Supplier defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultVDC = defaultVDC; } public URI apply(Object from) { try { - return orgVDCMap.get().get(from == null ? defaultVDC.getHref() : from).getInternetServices().getHref(); + return orgVDCMap.get().get(from == null ? defaultVDC.get().getHref() : from).getInternetServices().getHref(); } catch (NullPointerException e) { throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get()); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java index a9a50bc2cb..69e97c599d 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/functions/VDCURIToPublicIPsEndpoint.java @@ -38,18 +38,18 @@ import com.google.common.base.Supplier; @Singleton public class VDCURIToPublicIPsEndpoint implements Function { private final Supplier> orgVDCMap; - private final ReferenceType defaultVDC; + private final Supplier defaultVDC; @Inject public VDCURIToPublicIPsEndpoint(Supplier> orgVDCMap, - @VDC ReferenceType defaultVDC) { + @VDC Supplier defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultVDC = defaultVDC; } public URI apply(Object from) { try { - return orgVDCMap.get().get(from == null ? defaultVDC.getHref() : from).getPublicIps().getHref(); + return orgVDCMap.get().get(from == null ? defaultVDC.get().getHref() : from).getPublicIps().getHref(); } catch (NullPointerException e) { throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get()); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java index 1061fc60c0..e217d1cbb7 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/location/DefaultVDC.java @@ -40,16 +40,16 @@ import com.google.common.base.Supplier; public class DefaultVDC implements ImplicitLocationSupplier { @Singleton public static final class IsDefaultVDC implements Predicate { - private final ReferenceType defaultVDC; + private final Supplier defaultVDC; @Inject - IsDefaultVDC(@VDC ReferenceType defaultVDC) { + IsDefaultVDC(@VDC Supplier defaultVDC) { this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC"); } @Override public boolean apply(Location input) { - return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString()); + return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.get().getHref().toASCIIString()); } @Override diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index aae71237d5..153d472a6c 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -41,6 +41,8 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import org.testng.annotations.Test; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; @@ -68,8 +70,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { @Network @Provides @Singleton - ReferenceType provideNetwork() { - return new ReferenceTypeImpl(null, null, URI.create("https://vcloud.safesecureweb.com/network/1990")); + Supplier provideNetwork() { + return Suppliers.ofInstance(new ReferenceTypeImpl(null, null, URI + .create("https://vcloud.safesecureweb.com/network/1990"))); } })); diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index a67fec02ac..6824f909ee 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -676,8 +676,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'", JBOSS_HOME)), configureSeconds)); - for (Entry download : ImmutableMap. of("jboss7", JBOSS7_URL, "jdk7", InstallJDK.FromURL.JDK7_URL) - .entrySet()) { + for (Entry download : ImmutableMap. of("jboss7", JBOSS7_URL, "jdk7", + URI.create("http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz")).entrySet()) { // note we cannot use nslookup until we've configured the system, as // it may have not been present checking the address of the download // host using the local node's DNS config diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index e22fa6d73b..b085af364d 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -162,26 +198,7 @@ END_OF_JCLOUDS_SCRIPT awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow setupPublicCurl || return 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || return 1 END_OF_JCLOUDS_SCRIPT diff --git a/compute/src/test/resources/initscript_with_jboss.sh b/compute/src/test/resources/initscript_with_jboss.sh index 36216b850d..1a9052097f 100644 --- a/compute/src/test/resources/initscript_with_jboss.sh +++ b/compute/src/test/resources/initscript_with_jboss.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -162,26 +198,7 @@ END_OF_JCLOUDS_SCRIPT awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow setupPublicCurl || return 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || return 1 iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT iptables-save diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 927daac349..844ba16f3c 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -142,26 +178,7 @@ END_OF_JCLOUDS_SCRIPT rm -f $INSTANCE_HOME/rc trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15 setupPublicCurl || exit 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || exit 1 END_OF_JCLOUDS_SCRIPT diff --git a/core/pom.xml b/core/pom.xml index d4b22d5e96..a6abf30d56 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -47,8 +47,8 @@ org.bouncycastle - bcprov-jdk15 - 1.44 + bcprov-jdk16 + 1.46 true @@ -59,7 +59,7 @@ com.sun.jersey jersey-core - 1.11 + 1.12 com.google.inject.extensions @@ -99,7 +99,7 @@ com.google.guava guava - 11.0.1 + 11.0.2 @@ -107,7 +107,7 @@ maven-jar-plugin - 2.3.1 + 2.4 diff --git a/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java b/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java index 73fbbd2c00..5915de99b7 100644 --- a/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java +++ b/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java @@ -106,10 +106,10 @@ public class BackoffLimitedRetryHandler implements HttpRetryHandler, IOException command.incrementFailureCount(); if (!command.isReplayable()) { - logger.warn("Cannot retry after server error, command is not replayable: %1$s", command); + logger.error("Cannot retry after server error, command is not replayable: %1$s", command); return false; } else if (command.getFailureCount() > retryCountLimit) { - logger.warn("Cannot retry after server error, command has exceeded retry limit %1$d: %2$s", retryCountLimit, + logger.error("Cannot retry after server error, command has exceeded retry limit %1$d: %2$s", retryCountLimit, command); return false; } else { diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 25219b9ca7..c8442950b8 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -22,6 +22,9 @@ aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBui aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder +elb.contextbuilder=org.jclouds.elb.ELBContextBuilder +elb.propertiesbuilder=org.jclouds.elb.ELBPropertiesBuilder + aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder @@ -183,6 +186,9 @@ softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder glesys.contextbuilder=org.jclouds.glesys.GleSYSContextBuilder glesys.propertiesbuilder=org.jclouds.glesys.GleSYSPropertiesBuilder +opsource-servers.contextbuilder=org.jclouds.opsource.servers.OpSourceServersContextBuilder +opsource-servers.propertiesbuilder=org.jclouds.opsource.servers.OpSourceServersPropertiesBuilder + savvis-symphonyvpdc.contextbuilder=org.jclouds.savvis.vpdc.VPDCContextBuilder savvis-symphonyvpdc.propertiesbuilder=org.jclouds.savvis.vpdc.VPDCPropertiesBuilder diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index 3c09fd1d24..b5b3d5ae84 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -45,13 +45,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.core.HttpHeaders; -import org.eclipse.jetty.http.ssl.SslContextFactory; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; +import org.eclipse.jetty.util.ssl.SslContextFactory; import org.jclouds.Constants; import org.jclouds.crypto.CryptoStreams; import org.jclouds.io.InputSuppliers; diff --git a/core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java b/core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java index 3ad6a2d4d6..2a06138f36 100644 --- a/core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/BaseRestClientExpectTest.java @@ -39,6 +39,11 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceConstants; +import org.custommonkey.xmlunit.DifferenceListener; +import org.custommonkey.xmlunit.XMLUnit; import org.jclouds.Constants; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.SingleThreaded; @@ -58,14 +63,18 @@ import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.util.Strings2; import org.testng.annotations.Test; +import org.w3c.dom.Node; import com.google.common.annotations.Beta; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Module; @@ -324,7 +333,9 @@ public abstract class BaseRestClientExpectTest { return HttpResponse.builder().statusCode(500).message( String.format("request %s is out of range (%s)", index, requests.size())).payload( Payloads.newStringPayload(renderRequest(input))).build(); - assertEquals(renderRequest(input), renderRequest(requests.get(index))); + if (!httpRequestsAreEqual(input, requests.get(index))) { + assertEquals(renderRequest(input), renderRequest(requests.get(index))); + } return responses.get(index); } }); @@ -342,14 +353,81 @@ public abstract class BaseRestClientExpectTest { return requestsSendResponses(requestToResponse, createModule()); } + protected enum HttpRequestComparisonType { + XML, JSON, DEFAULT; + } + + /** + * How should this HttpRequest be compared with others? + */ + protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) { + return HttpRequestComparisonType.DEFAULT; + } + + /** + * Compare two requests as instructed by {@link #compareHttpRequestAsType(HttpRequest)} - default is to compare using Objects.equal + */ + public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) { + try { + switch (compareHttpRequestAsType(a)) { + case XML: { + if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) { + return false; + } + + Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), + Strings2.toStringAndClose(b.getPayload().getInput())); + + // Ignoring xsi:schemaLocation and differences in namespace prefixes + diff.overrideDifferenceListener(new DifferenceListener() { + @Override + public int differenceFound(Difference difference) { + if (difference.getId() == DifferenceConstants.SCHEMA_LOCATION_ID || + difference.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) { + return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; + } + return RETURN_ACCEPT_DIFFERENCE; + } + + @Override + public void skippedComparison(Node node, Node node1) { + } + }); + + return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders()); + } + case JSON: { + if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) { + return false; + } + JsonParser parser = new JsonParser(); + JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().getInput())); + JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().getInput())); + return Objects.equal(payloadA, payloadB) && Objects.equal(a.getHeaders(), b.getHeaders()); + } + default: { + return Objects.equal(a, b); + } + } + } catch (Exception e) { + throw Throwables.propagate(e); + } + } + public S requestsSendResponses(final Map requestToResponse, Module module) { return createClient(new Function() { ImmutableBiMap bimap = ImmutableBiMap.copyOf(requestToResponse); @Override public HttpResponse apply(HttpRequest input) { - if (!(requestToResponse.containsKey(input))) { + HttpResponse response = null; + for (HttpRequest request : requestToResponse.keySet()) { + if (httpRequestsAreEqual(input, request)) { + response = requestToResponse.get(request); + } + } + if (response == null) { StringBuilder payload = new StringBuilder("\n"); payload.append("the following request is not configured:\n"); payload.append("----------------------------------------\n"); @@ -360,13 +438,14 @@ public abstract class BaseRestClientExpectTest { payload.append("----------------------------------------\n"); payload.append(renderRequest(request)); } - return HttpResponse.builder().statusCode(500).message("no response configured for request").payload( - Payloads.newStringPayload(payload.toString())).build(); + response = HttpResponse.builder().statusCode(500).message("no response configured for request").payload( + Payloads.newStringPayload(payload.toString())).build(); + } else if (compareHttpRequestAsType(input) == HttpRequestComparisonType.DEFAULT) { + // in case hashCode/equals doesn't do a full content check + assertEquals(renderRequest(input), renderRequest(bimap.inverse().get(response))); } - HttpResponse response = requestToResponse.get(input); - // in case hashCode/equals doesn't do a full content check - assertEquals(renderRequest(input), renderRequest(bimap.inverse().get(response))); + return response; } }, module); diff --git a/drivers/apachehc/pom.xml b/drivers/apachehc/pom.xml index e79b28b19e..e04cd53b46 100644 --- a/drivers/apachehc/pom.xml +++ b/drivers/apachehc/pom.xml @@ -60,7 +60,7 @@ org.apache.httpcomponents httpclient - 4.1.1 + 4.1.3 compile diff --git a/drivers/joda/pom.xml b/drivers/joda/pom.xml index 79035012f6..09fcdd4c45 100644 --- a/drivers/joda/pom.xml +++ b/drivers/joda/pom.xml @@ -60,7 +60,7 @@ joda-time joda-time - 1.6.2 + 2.1 compile diff --git a/drivers/jsch/pom.xml b/drivers/jsch/pom.xml index 16d4b46834..fb4803c5e6 100644 --- a/drivers/jsch/pom.xml +++ b/drivers/jsch/pom.xml @@ -78,7 +78,7 @@ ch.qos.logback logback-classic - 0.9.30 + 1.0.0 test diff --git a/drivers/netty/pom.xml b/drivers/netty/pom.xml index 819bcd0359..389db65f34 100644 --- a/drivers/netty/pom.xml +++ b/drivers/netty/pom.xml @@ -33,30 +33,6 @@ jclouds netty payload module bundle - - - - jclouds-sona-snapshots-nexus - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - - - jboss-public-releases - https://repository.jboss.org/nexus/content/groups/public-jboss - - true - - - false - - - - org.jclouds @@ -71,9 +47,9 @@ test - org.jboss.netty + io.netty netty - 3.2.4.Final + 3.3.1.Final compile diff --git a/drivers/slf4j/pom.xml b/drivers/slf4j/pom.xml index 43bbc6ae77..246b846cb5 100644 --- a/drivers/slf4j/pom.xml +++ b/drivers/slf4j/pom.xml @@ -60,7 +60,7 @@ org.slf4j slf4j-api - 1.6.1 + 1.6.4 compile diff --git a/drivers/sshj/pom.xml b/drivers/sshj/pom.xml index 5c4112b500..2f56867cda 100644 --- a/drivers/sshj/pom.xml +++ b/drivers/sshj/pom.xml @@ -71,7 +71,7 @@ ch.qos.logback logback-classic - 0.9.30 + 1.0.0 test diff --git a/sandbox-providers/aws-elb/README.txt b/labs/aws-elb/README.txt similarity index 100% rename from sandbox-providers/aws-elb/README.txt rename to labs/aws-elb/README.txt diff --git a/sandbox-providers/aws-elb/pom.xml b/labs/aws-elb/pom.xml similarity index 98% rename from sandbox-providers/aws-elb/pom.xml rename to labs/aws-elb/pom.xml index 0227cb482c..c4a43951db 100644 --- a/sandbox-providers/aws-elb/pom.xml +++ b/labs/aws-elb/pom.xml @@ -27,7 +27,7 @@ 1.5.0-SNAPSHOT ../../project/pom.xml - org.jclouds.provider + org.jclouds.labs aws-elb jclouds Amazon Elastic Load Balancer provider Elastic Load Balancer implementation targeted to Amazon Web Services @@ -50,13 +50,13 @@ - org.jclouds.api + org.jclouds.labs elb ${project.version} jar - org.jclouds.api + org.jclouds.labs elb ${project.version} test-jar diff --git a/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java similarity index 98% rename from sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java rename to labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java index 759565c7ff..f22894ab4e 100644 --- a/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java +++ b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBPropertiesBuilder.java @@ -69,10 +69,6 @@ public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder { return properties; } - public AWSELBPropertiesBuilder() { - super(); - } - public AWSELBPropertiesBuilder(Properties properties) { super(properties); } diff --git a/sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java similarity index 100% rename from sandbox-providers/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java rename to labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java diff --git a/sandbox-providers/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata similarity index 100% rename from sandbox-providers/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata rename to labs/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java similarity index 100% rename from sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java rename to labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java similarity index 92% rename from sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java rename to labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java index d8aa824f68..25bc4e26af 100644 --- a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBClientLiveTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true, testName = "AWSELBClientLiveTest") +@Test(groups = "live", singleThreaded = true, testName = "AWSELBClientLiveTest") public class AWSELBClientLiveTest extends ELBClientLiveTest { public AWSELBClientLiveTest() { provider = "aws-elb"; @@ -47,7 +47,7 @@ public class AWSELBClientLiveTest extends ELBClientLiveTest { } } - @Test + @Test(dependsOnMethods = "testDescribeLoadBalancers") public void testDeleteLoadBalancer() { for (String region : Region.DEFAULT_REGIONS) { deleteLoadBalancerInRegion(region); diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java similarity index 100% rename from sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java rename to labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java diff --git a/sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java similarity index 100% rename from sandbox-providers/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java rename to labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java diff --git a/sandbox-apis/elb/README.txt b/labs/elb/README.txt similarity index 100% rename from sandbox-apis/elb/README.txt rename to labs/elb/README.txt diff --git a/sandbox-apis/elb/pom.xml b/labs/elb/pom.xml similarity index 95% rename from sandbox-apis/elb/pom.xml rename to labs/elb/pom.xml index 11362160b8..e1cd5f7fbe 100644 --- a/sandbox-apis/elb/pom.xml +++ b/labs/elb/pom.xml @@ -27,7 +27,7 @@ 1.5.0-SNAPSHOT ../../project/pom.xml - org.jclouds.api + org.jclouds.labs elb jcloud elb api jclouds components to access an implementation of Elastic Load Balancer @@ -40,7 +40,7 @@ ${test.aws.identity} ${test.aws.credential} - ec2 + aws-ec2 https://ec2.us-east-1.amazonaws.com 2010-06-15 @@ -75,6 +75,12 @@ test-jar test + + org.jclouds.provider + aws-ec2 + ${project.version} + test + org.jclouds.driver jclouds-sshj diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBAsyncClient.java b/labs/elb/src/main/java/org/jclouds/elb/ELBAsyncClient.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBAsyncClient.java rename to labs/elb/src/main/java/org/jclouds/elb/ELBAsyncClient.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBClient.java b/labs/elb/src/main/java/org/jclouds/elb/ELBClient.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBClient.java rename to labs/elb/src/main/java/org/jclouds/elb/ELBClient.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java rename to labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java similarity index 97% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java rename to labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java index c9be99e5b0..34766fe0a0 100644 --- a/sandbox-apis/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java +++ b/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java @@ -43,9 +43,6 @@ public class ELBPropertiesBuilder extends PropertiesBuilder { return properties; } - public ELBPropertiesBuilder() { - super(); - } public ELBPropertiesBuilder(Properties properties) { super(properties); diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java rename to labs/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java rename to labs/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/binders/BindLoadBalancerNamesToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindLoadBalancerNamesToIndexedFormParams.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/binders/BindLoadBalancerNamesToIndexedFormParams.java rename to labs/elb/src/main/java/org/jclouds/elb/binders/BindLoadBalancerNamesToIndexedFormParams.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java rename to labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java b/labs/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java rename to labs/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java similarity index 95% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java index 4cd265320a..fb4b60df60 100644 --- a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java +++ b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java @@ -30,7 +30,6 @@ public class ELBLoadBalancerContextModule extends BaseLoadBalancerServiceContext @Override protected void configure() { - install(new ELBBindLoadBalancerSuppliersByClass()); install(new ELBBindLoadBalancerStrategiesByClass()); install(new ELBLoadBalancerServiceDependenciesModule()); super.configure(); diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java similarity index 61% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java index 5b5e8e7bd4..dcd09d0a21 100644 --- a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java +++ b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java @@ -18,21 +18,27 @@ */ package org.jclouds.elb.loadbalancer.functions; -import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; import org.jclouds.elb.domain.LoadBalancer; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; +import org.jclouds.logging.Logger; import com.google.common.base.Function; +import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; /** * @@ -40,25 +46,49 @@ import com.google.common.collect.ImmutableSet; */ @Singleton public class LoadBalancerToLoadBalancerMetadata implements Function { - protected final Supplier> locationMap; + @Resource + protected static Logger logger = Logger.NULL; + + protected final Supplier> locations; protected final Supplier defaultLocationSupplier; @Inject public LoadBalancerToLoadBalancerMetadata(Supplier defaultLocationSupplier, - Supplier> locationMap) { - this.locationMap = locationMap; + @Memoized Supplier> locations) { + this.locations = locations; this.defaultLocationSupplier = defaultLocationSupplier; } @Override public LoadBalancerMetadata apply(LoadBalancer input) { - Location location = input.getRegion() != null ? locationMap.get().get(input.getRegion()) - : defaultLocationSupplier.get(); + Location location = input.getRegion() != null ? findLocationWithId(input.getRegion()) : defaultLocationSupplier + .get(); String id = input.getRegion() != null ? input.getRegion() + "/" + input.getName() : input.getName(); // TODO Builder return new LoadBalancerMetadataImpl(LoadBalancerType.LB, input.getName(), input.getName(), id, location, null, - ImmutableMap. of(), ImmutableSet.of(input.getDnsName())); + ImmutableMap. of(), ImmutableSet.of(input.getDnsName())); } + + private Location findLocationWithId(final String locationId) { + if (locationId == null) + return null; + try { + Location location = Iterables.find(locations.get(), new Predicate() { + + @Override + public boolean apply(Location input) { + return input.getId().equals(locationId); + } + + }); + return location; + + } catch (NoSuchElementException e) { + logger.debug("couldn't match instance location %s in: %s", locationId, locations.get()); + return null; + } + } + } \ No newline at end of file diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java similarity index 90% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java index 421d31ded6..65dc2614cf 100644 --- a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java +++ b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java @@ -27,7 +27,6 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; -import javax.annotation.Nullable; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; @@ -44,6 +43,7 @@ import org.jclouds.location.Region; import org.jclouds.logging.Logger; import com.google.common.base.Function; +import com.google.common.base.Supplier; import com.google.common.util.concurrent.ListenableFuture; /** @@ -60,12 +60,12 @@ public class ELBListLoadBalancersStrategy implements ListLoadBalancersStrategy { private final ELBAsyncClient aclient; private final Function converter; private final ExecutorService executor; - private final Set regions; + private final Supplier> regions; @Inject protected ELBListLoadBalancersStrategy(ELBClient client, ELBAsyncClient aclient, - Function converter, - @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Nullable @Region Set regions) { + Function converter, + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Region Supplier> regions) { this.client = checkNotNull(client, "client"); this.aclient = checkNotNull(aclient, "aclient"); this.regions = checkNotNull(regions, "regions"); @@ -76,7 +76,8 @@ public class ELBListLoadBalancersStrategy implements ListLoadBalancersStrategy { @Override public Iterable listLoadBalancers() { Iterable loadBalancers; - if (regions != null) + Set regions = this.regions.get(); + if (regions.size() > 0) loadBalancers = concat(transformParallel(regions, new Function>>() { @Override diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java rename to labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java rename to labs/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResponseHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResponseHandler.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResponseHandler.java rename to labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResponseHandler.java diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandler.java similarity index 100% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandler.java rename to labs/elb/src/main/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandler.java diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java similarity index 94% rename from sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java rename to labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java index 4f82c47869..08dc42a790 100644 --- a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java @@ -179,18 +179,10 @@ public class ELBAsyncClientTest extends RestClientTest { protected String provider = "elb"; - @Override - protected Properties getProperties() { - Properties overrides = new Properties(); - overrides.setProperty(provider + ".endpoint", "https://elasticloadbalancing.us-east-1.amazonaws.com"); - overrides.setProperty(provider + ".propertiesbuilder", ELBPropertiesBuilder.class.getName()); - overrides.setProperty(provider + ".contextbuilder", ELBContextBuilder.class.getName()); - return overrides; - } @Override public RestContextSpec createContextSpec() { - return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential", + return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "identity", "credential", new Properties()); } diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java similarity index 61% rename from sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java rename to labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java index 78c5e8b53a..24b963ca62 100644 --- a/sandbox-apis/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java @@ -24,12 +24,12 @@ import static org.testng.Assert.assertNotNull; import java.util.Properties; import java.util.Set; -import org.jclouds.Constants; import org.jclouds.elb.domain.LoadBalancer; import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory; import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.rest.BaseRestClientLiveTest; import org.jclouds.rest.RestContext; -import org.testng.annotations.AfterTest; +import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -41,53 +41,31 @@ import com.google.inject.Module; * * @author Lili Nader */ -@Test(groups = "live", sequential = true) -public class ELBClientLiveTest { +@Test(groups = "live", singleThreaded = true, testName = "ELBClientLiveTest") +public class ELBClientLiveTest extends BaseRestClientLiveTest { + + public ELBClientLiveTest() { + provider = "elb"; + } private ELBClient client; private RestContext context; - protected String provider = "elb"; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiVersion; + protected String name = "TestLoadBalancer"; - protected void setupCredentials() { - identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider - + ".credential"); - endpoint = System.getProperty("test." + provider + ".endpoint"); - apiVersion = System.getProperty("test." + provider + ".api-version"); - } - - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - overrides.setProperty(provider + ".identity", identity); - if (credential != null) - overrides.setProperty(provider + ".credential", credential); - if (endpoint != null) - overrides.setProperty(provider + ".endpoint", endpoint); - if (apiVersion != null) - overrides.setProperty(provider + ".api-version", apiVersion); - return overrides; - } - - @BeforeGroups(groups = { "live" }) + @BeforeGroups(groups = "live") public void setupClient() { setupCredentials(); Properties overrides = setupProperties(); context = new LoadBalancerServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); + ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); client = context.getApi(); } @Test public void testCreateLoadBalancer() { - createLoadBalancerInRegionZone(null, - checkNotNull(System.getProperty("test." + provider + ".zone"), "test." + provider + ".zone"), name); + createLoadBalancerInRegionZone(null, checkNotNull(System.getProperty("test." + provider + ".zone"), "test." + + provider + ".zone"), name); } protected void createLoadBalancerInRegionZone(String region, String zone, String name) { @@ -107,7 +85,7 @@ public class ELBClientLiveTest { assert (allResults.size() >= 1) : region; } - @Test + @Test(dependsOnMethods = "testDescribeLoadBalancers") public void testDeleteLoadBalancer() { deleteLoadBalancerInRegion(null); } @@ -116,8 +94,12 @@ public class ELBClientLiveTest { client.deleteLoadBalancerInRegion(region, name); } - @AfterTest + @AfterGroups(groups = "live") public void shutdown() { - context.close(); + try { + testDeleteLoadBalancer(); + } finally { + context.close(); + } } } diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java similarity index 96% rename from sandbox-apis/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java rename to labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java index 7c67633484..f218ca619f 100644 --- a/sandbox-apis/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java @@ -37,7 +37,7 @@ import org.testng.annotations.Test; * * @author Lili Nadar */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true, testName = "ELBLoadBalancerServiceLiveTest") public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest { public ELBLoadBalancerServiceLiveTest() { diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/xml/DescribeLoadBalancerResponseHandlerTest.java b/labs/elb/src/test/java/org/jclouds/elb/xml/DescribeLoadBalancerResponseHandlerTest.java similarity index 100% rename from sandbox-apis/elb/src/test/java/org/jclouds/elb/xml/DescribeLoadBalancerResponseHandlerTest.java rename to labs/elb/src/test/java/org/jclouds/elb/xml/DescribeLoadBalancerResponseHandlerTest.java diff --git a/sandbox-apis/elb/src/test/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandlerTest.java b/labs/elb/src/test/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandlerTest.java similarity index 100% rename from sandbox-apis/elb/src/test/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandlerTest.java rename to labs/elb/src/test/java/org/jclouds/elb/xml/RegisterInstancesWithLoadBalancerResponseHandlerTest.java diff --git a/sandbox-apis/elb/src/test/resources/describe_loadbalancers.xml b/labs/elb/src/test/resources/describe_loadbalancers.xml similarity index 100% rename from sandbox-apis/elb/src/test/resources/describe_loadbalancers.xml rename to labs/elb/src/test/resources/describe_loadbalancers.xml diff --git a/sandbox-apis/elb/src/test/resources/log4j.xml b/labs/elb/src/test/resources/log4j.xml similarity index 100% rename from sandbox-apis/elb/src/test/resources/log4j.xml rename to labs/elb/src/test/resources/log4j.xml diff --git a/sandbox-apis/elb/src/test/resources/register_instances_with_loadbalancer.xml b/labs/elb/src/test/resources/register_instances_with_loadbalancer.xml similarity index 100% rename from sandbox-apis/elb/src/test/resources/register_instances_with_loadbalancer.xml rename to labs/elb/src/test/resources/register_instances_with_loadbalancer.xml diff --git a/labs/openstack-nova/pom.xml b/labs/openstack-nova/pom.xml index 6ad9c82ab2..3aebc552d6 100644 --- a/labs/openstack-nova/pom.xml +++ b/labs/openstack-nova/pom.xml @@ -93,7 +93,7 @@ ch.qos.logback logback-classic - 0.9.29 + 1.0.0 test diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java index cd8dd41502..9a1175b301 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java @@ -24,6 +24,10 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.openstack.nova.v1_1.features.FlavorClient; +import org.jclouds.openstack.nova.v1_1.features.FloatingIPClient; +import org.jclouds.openstack.nova.v1_1.features.ImageClient; +import org.jclouds.openstack.nova.v1_1.features.KeyPairClient; +import org.jclouds.openstack.nova.v1_1.features.SecurityGroupClient; import org.jclouds.openstack.nova.v1_1.features.ServerAsyncClient; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; @@ -62,4 +66,32 @@ public interface NovaAsyncClient { FlavorClient getFlavorClientForRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + /** + * Provides asynchronous access to Image features. + */ + @Delegate + ImageClient getImageClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides asynchronous access to Floating IP features. + */ + @Delegate + FloatingIPClient getFloatingIPClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides asynchronous access to Security Group features. + */ + @Delegate + SecurityGroupClient getSecurityGroupClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides asynchronous access to Key Pair features. + */ + @Delegate + KeyPairClient getKeyPairClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java index 8ac771a4d2..3f2dab31d3 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java @@ -26,6 +26,10 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.openstack.nova.v1_1.features.FlavorClient; +import org.jclouds.openstack.nova.v1_1.features.FloatingIPClient; +import org.jclouds.openstack.nova.v1_1.features.ImageClient; +import org.jclouds.openstack.nova.v1_1.features.KeyPairClient; +import org.jclouds.openstack.nova.v1_1.features.SecurityGroupClient; import org.jclouds.openstack.nova.v1_1.features.ServerClient; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; @@ -63,5 +67,33 @@ public interface NovaClient { @Delegate FlavorClient getFlavorClientForRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - + + /** + * Provides synchronous access to Image features. + */ + @Delegate + ImageClient getImageClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Floating IP features. + */ + @Delegate + FloatingIPClient getFloatingIPClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Security Group features. + */ + @Delegate + SecurityGroupClient getSecurityGroupClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Key Pair features. + */ + @Delegate + KeyPairClient getKeyPairClientForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java index 6e3b72e097..3e9ea93bac 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java @@ -30,6 +30,14 @@ import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.features.FlavorAsyncClient; import org.jclouds.openstack.nova.v1_1.features.FlavorClient; +import org.jclouds.openstack.nova.v1_1.features.FloatingIPAsyncClient; +import org.jclouds.openstack.nova.v1_1.features.FloatingIPClient; +import org.jclouds.openstack.nova.v1_1.features.ImageAsyncClient; +import org.jclouds.openstack.nova.v1_1.features.ImageClient; +import org.jclouds.openstack.nova.v1_1.features.KeyPairAsyncClient; +import org.jclouds.openstack.nova.v1_1.features.KeyPairClient; +import org.jclouds.openstack.nova.v1_1.features.SecurityGroupAsyncClient; +import org.jclouds.openstack.nova.v1_1.features.SecurityGroupClient; import org.jclouds.openstack.nova.v1_1.features.ServerAsyncClient; import org.jclouds.openstack.nova.v1_1.features.ServerClient; import org.jclouds.openstack.nova.v1_1.handlers.NovaErrorHandler; @@ -50,6 +58,10 @@ public class NovaRestClientModule extends RestClientModule, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// .put(ServerClient.class, ServerAsyncClient.class)// .put(FlavorClient.class, FlavorAsyncClient.class) + .put(ImageClient.class, ImageAsyncClient.class) + .put(FloatingIPClient.class, FloatingIPAsyncClient.class) + .put(SecurityGroupClient.class, SecurityGroupAsyncClient.class) + .put(KeyPairClient.class, KeyPairAsyncClient.class) .build(); public NovaRestClientModule() { diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/FloatingIP.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/FloatingIP.java new file mode 100644 index 0000000000..ebbbe6eb82 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/FloatingIP.java @@ -0,0 +1,166 @@ +/** + * 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.openstack.nova.v1_1.domain; + +import static com.google.common.base.Objects.toStringHelper; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +/** + * A Floating IP is an IP address that can be created and associated with a Server instance. + * Floating IPs can also be disassociated and deleted from a Server instance. + * + * @author Jeremy Daggett + * @author chamerling + */ +public class FloatingIP implements Comparable { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromFloatingIp(this); + } + + public static class Builder { + private String id; + private String ip; + private String fixedIp; + private String instanceId; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder ip(String ip) { + this.ip = ip; + return this; + } + + public Builder fixedIp(String fixedIp) { + this.fixedIp = fixedIp; + return this; + } + + public Builder instanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public FloatingIP build() { + return new FloatingIP(id, ip, fixedIp, instanceId); + } + + public Builder fromFloatingIp(FloatingIP in) { + return id(in.getId()).ip(in.getIp()).fixedIp(in.getFixedIp()) + .instanceId(in.getInstanceId()); + } + + } + + private String id; + private String ip; + @SerializedName("fixed_ip") + private String fixedIp; + @SerializedName("instance_id") + private String instanceId; + + protected FloatingIP(String id, String ip, @Nullable String fixedIp, + @Nullable String instanceId) { + this.id = id; + this.ip = ip; + this.fixedIp = fixedIp; + this.instanceId = instanceId; + } + + public String getId() { + return this.id; + } + + public String getIp() { + return this.ip; + } + + public String getFixedIp() { + return this.fixedIp; + } + + public String getInstanceId() { + return this.fixedIp; + } + + @Override + public int compareTo(FloatingIP o) { + return this.id.compareTo(o.getId()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fixedIp == null) ? 0 : fixedIp.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + + ((instanceId == null) ? 0 : instanceId.hashCode()); + result = prime * result + ((ip == null) ? 0 : ip.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + FloatingIP other = (FloatingIP) obj; + if (fixedIp == null) { + if (other.fixedIp != null) + return false; + } else if (!fixedIp.equals(other.fixedIp)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (instanceId == null) { + if (other.instanceId != null) + return false; + } else if (!instanceId.equals(other.instanceId)) + return false; + if (ip == null) { + if (other.ip != null) + return false; + } else if (!ip.equals(other.ip)) + return false; + return true; + } + + @Override + public String toString() { + return toStringHelper("").add("id", id).add("ip", ip) + .add("fixedIp", fixedIp).add("instanceId", instanceId).toString(); + } + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java new file mode 100644 index 0000000000..328844d91c --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java @@ -0,0 +1,241 @@ +/** + * 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.openstack.nova.v1_1.domain; + +import static com.google.common.base.Objects.toStringHelper; + +import java.util.Date; +import java.util.Map; +import java.util.Set; + +import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.domain.Resource; + +import com.google.common.collect.Maps; +import com.google.gson.annotations.SerializedName; + +/** + * An image is a collection of files you use to create or rebuild a server. + * Operators provide pre-built OS images by default. You may also create custom + * images. + * + * @author Jeremy Daggett + * @see + */ +public class Image extends Resource { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromImage(this); + } + + public static class Builder extends Resource.Builder { + + private Date updated; + private Date created; + private String tenantId; + private String userId; + private ImageStatus status; + private int progress; + private int minDisk; + private int minRam; + private Resource server; + private Map metadata = Maps.newHashMap(); + + public Builder updated(Date updated) { + this.updated = updated; + return this; + } + + public Builder created(Date created) { + this.created = created; + return this; + } + + public Builder tenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public Builder userId(String userId) { + this.userId = userId; + return this; + } + + public Builder status(ImageStatus status) { + this.status = status; + return this; + } + + public Builder progress(int progress) { + this.progress = progress; + return this; + } + + public Builder minDisk(int minDisk) { + this.minDisk = minDisk; + return this; + } + + public Builder minRam(int minRam) { + this.minRam = minRam; + return this; + } + + public Builder server(Resource server) { + this.server = server; + return this; + } + + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + public Image build() { + return new Image(id, name, links, updated, created, tenantId, userId, + status, progress, minDisk, minRam, server, metadata); + } + + public Builder fromImage(Image in) { + return fromResource(in).status(in.getStatus()) + .updated(in.getUpdated()).created(in.getCreated()) + .progress(in.getProgress()).server(in.getServer()) + .metadata(in.getMetadata()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder id(String id) { + return Builder.class.cast(super.id(id)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder links(Set links) { + return Builder.class.cast(super.links(links)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromResource(Resource in) { + return Builder.class.cast(super.fromResource(in)); + } + } + + private Date updated; + private Date created; + @SerializedName("tenant_id") + private String tenantId; + @SerializedName("user_id") + private String userId; + private ImageStatus status; + private int progress; + private int minDisk; + private int minRam; + private Resource server; + private Map metadata = Maps.newHashMap(); + + protected Image(String id, String name, Set links, Date updated, + Date created, String tenantId, String userId, ImageStatus status, + int progress, int minDisk, int minRam, Resource server, + Map metadata) { + super(id, name, links); + this.updated = updated; + this.created = created; + this.tenantId = tenantId; + this.userId = userId; + this.status = status; + this.progress = progress; + this.minDisk = minDisk; + this.minRam = minRam; + this.server = server; + this.metadata = metadata; + } + + public Date getUpdated() { + return this.updated; + } + + public Date getCreated() { + return this.created; + } + + public String getTenantId() { + return this.tenantId; + } + + public String getUserId() { + return this.userId; + } + + public ImageStatus getStatus() { + return this.status; + } + + public int getProgress() { + return this.progress; + } + + public int getMinDisk() { + return this.minDisk; + } + + public int getMinRam() { + return this.minRam; + } + + public Resource getServer() { + return this.server; + } + + public Map getMetadata() { + return this.metadata; + } + + @Override + public String toString() { + return toStringHelper("").add("id", id).add("name", name) + .add("links", links).add("updated", updated) + .add("created", created).add("tenantId", tenantId) + .add("userId", userId).add("status", status) + .add("progress", progress).add("minDisk", minDisk) + .add("minRam", minRam).add("server", server) + .add("metadata", metadata).toString(); + } + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ImageStatus.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ImageStatus.java new file mode 100644 index 0000000000..3853022f0d --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ImageStatus.java @@ -0,0 +1,47 @@ +/** + * 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.openstack.nova.v1_1.domain; + +/** + * In-flight images will have the status attribute set to SAVING and the + * conditional progress element (0-100% completion) will also be returned. Other + * possible values for the status attribute include: UNKNOWN, ACTIVE, SAVING, + * ERROR, and DELETED. Images with an ACTIVE status are available for install. + * The optional minDisk and minRam attributes set the minimum disk and RAM + * requirements needed to create a server with the image. + * + * @author Adrian Cole + */ +public enum ImageStatus { + + UNRECOGNIZED, UNKNOWN, ACTIVE, SAVING, ERROR, DELETED; + + public String value() { + return name(); + } + + public static ImageStatus fromValue(String v) { + try { + return valueOf(v); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/KeyPair.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/KeyPair.java new file mode 100644 index 0000000000..8deb6529b5 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/KeyPair.java @@ -0,0 +1,125 @@ +/** + * 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.openstack.nova.v1_1.domain; + +import static com.google.common.base.Objects.toStringHelper; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class KeyPair { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromKeyPair(this); + } + + public static class Builder { + + private String publicKey; + private String privateKey; + private String userId; + private String name; + private String fingerprint; + + public Builder publicKey(String publicKey) { + this.publicKey = publicKey; + return this; + } + + public Builder privateKey(String privateKey) { + this.privateKey = privateKey; + return this; + } + + public Builder userId(String userId) { + this.userId = userId; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder fingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + + public KeyPair build() { + return new KeyPair(publicKey, privateKey, userId, name, fingerprint); + } + + public Builder fromKeyPair(KeyPair in) { + return publicKey(in.getPublicKey()).privateKey(in.getPrivateKey()) + .userId(in.getUserId()).name(in.getName()) + .fingerprint(in.getFingerprint()); + } + + } + + @SerializedName("public_key") + String publicKey; + @SerializedName("private_key") + String privateKey; + @SerializedName("user_id") + String userId; + String name; + String fingerprint; + + protected KeyPair(String publicKey, String privateKey, + @Nullable String userId, String name, String fingerprint) { + this.publicKey = publicKey; + this.privateKey = privateKey; + this.userId = userId; + this.name = name; + this.fingerprint = fingerprint; + } + + public String getPublicKey() { + return this.publicKey; + } + + public String getPrivateKey() { + return this.privateKey; + } + + public String getUserId() { + return this.privateKey; + } + + public String getName() { + return this.name; + } + + public String getFingerprint() { + return this.fingerprint; + } + + @Override + public String toString() { + return toStringHelper("").add("publicKey", publicKey) + .add("privateKey", privateKey).add("userId", userId) + .add("name", name).add("fingerprint", fingerprint).toString(); + } +} \ No newline at end of file diff --git a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerSuppliersByClass.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/RebootType.java similarity index 61% rename from sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerSuppliersByClass.java rename to labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/RebootType.java index 51cb313a75..e0e5c13e98 100644 --- a/sandbox-apis/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerSuppliersByClass.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/RebootType.java @@ -16,23 +16,22 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.elb.loadbalancer.config; - -import java.util.Set; - -import org.jclouds.domain.Location; -import org.jclouds.loadbalancer.config.BindLoadBalancerSuppliersByClass; -import org.jclouds.location.suppliers.RegionToProviderOrJustProvider; - -import com.google.common.base.Supplier; +package org.jclouds.openstack.nova.v1_1.domain; /** + * * @author Adrian Cole */ -public class ELBBindLoadBalancerSuppliersByClass extends BindLoadBalancerSuppliersByClass { +public enum RebootType { - @Override - protected Class>> defineLocationSupplier() { - return RegionToProviderOrJustProvider.class; + HARD, SOFT; + + public String value() { + return name(); } -} \ No newline at end of file + + public static RebootType fromValue(String v) { + return valueOf(v); + } + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/SecurityGroup.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/SecurityGroup.java new file mode 100644 index 0000000000..ff0ed5ccff --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/SecurityGroup.java @@ -0,0 +1,181 @@ +/** + * 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.openstack.nova.v1_1.domain; + +import static com.google.common.base.Objects.toStringHelper; + +import java.util.Set; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + + +/** + * Defines a security group + * + */ +public class SecurityGroup { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromSecurityGroup(this); + } + + public static class Builder { + + private String id; + private String tenantId; + private String name; + private String description; + private Set rules; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder tenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder rules(Set rules) { + this.rules = rules; + return this; + } + + public SecurityGroup build() { + return new SecurityGroup(id, tenantId, name, description, rules); + } + + + public Builder fromSecurityGroup(SecurityGroup in) { + return id(in.getId()).tenantId(in.getTenantId()).name(in.getName()) + .description(in.getDescription()).rules(in.getRules()); + } + + } + + protected String id; + @SerializedName("tenant_id") + protected String tenantId; + protected String name; + protected String description; + protected Set rules; + + protected SecurityGroup(String id, String tenantId, @Nullable String name, + @Nullable String description, Set rules) { + this.id = id; + this.tenantId = tenantId; + this.name = name; + this.description = description; + } + + public String getId() { + return this.id; + } + + public String getTenantId() { + return this.tenantId; + } + + public String getName() { + return this.name; + } + + public String getDescription() { + return this.description; + } + + public Set getRules() { + return this.rules; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((rules == null) ? 0 : rules.hashCode()); + result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SecurityGroup other = (SecurityGroup) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (rules == null) { + if (other.rules != null) + return false; + } else if (!rules.equals(other.rules)) + return false; + if (tenantId == null) { + if (other.tenantId != null) + return false; + } else if (!tenantId.equals(other.tenantId)) + return false; + return true; + } + + @Override + public String toString() { + return toStringHelper("").add("id", id).add("name", name) + .add("tenantId", tenantId).add("description", description).add("rules", rules) + .toString(); + } + +} \ No newline at end of file diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/SecurityGroupRule.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/SecurityGroupRule.java new file mode 100644 index 0000000000..c976611e67 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/SecurityGroupRule.java @@ -0,0 +1,251 @@ +/** + * 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.openstack.nova.v1_1.domain; + +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Map; + +import com.google.gson.annotations.SerializedName; + +/** + * Defines a security group rule + * + */ +public class SecurityGroupRule implements Comparable { + + public static enum IpProtocol { + TCP, UDP, ICMP, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + @Override + public String toString() { + return value(); + } + + public static IpProtocol fromValue(String protocol) { + try { + return valueOf(checkNotNull(protocol, "protocol").toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromSecurityGroupRule(this); + } + + public static class Builder { + private String id; + private int fromPort; + private Map group; + // tcp/udp/icmp - move to enum + private IpProtocol ipProtocol; + + private int toPort; + private String parentGroupId; + + private Map ipRange; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder fromPort(int fromPort) { + this.fromPort = fromPort; + return this; + } + + public Builder group(Map group) { + this.group = group; + return this; + } + + public Builder ipProtocol(IpProtocol ipProtocol) { + this.ipProtocol = ipProtocol; + return this; + } + + public Builder toPort(int toPort) { + this.toPort = toPort; + return this; + } + + public Builder parentGroupId(String parentGroupId) { + this.parentGroupId = parentGroupId; + return this; + } + + public Builder ipRange(Map ipRange) { + this.ipRange = ipRange; + return this; + } + + public SecurityGroupRule build() { + return new SecurityGroupRule(id, fromPort, group, ipProtocol, toPort, + parentGroupId, ipRange); + } + + public Builder fromSecurityGroupRule(SecurityGroupRule in) { + return id(in.getId()).fromPort(in.getFromPort()).group(in.getGroup()) + .ipProtocol(in.getIpProtocol()).toPort(in.getToPort()).parentGroupId(in.getParentGroupId()) + .ipRange(in.getIpRange()); + } + } + + + protected String id; + + @SerializedName(value = "from_port") + protected int fromPort; + + protected Map group; + + @SerializedName(value = "ip_protocol") + // tcp/udp/icmp + protected IpProtocol ipProtocol; + + @SerializedName(value = "to_port") + protected int toPort; + + @SerializedName(value = "parent_group_id") + protected String parentGroupId; + + @SerializedName(value = "ip_range") + protected Map ipRange; + + + protected SecurityGroupRule(String id, int fromPort, Map group, + IpProtocol ipProtocol, int toPort, String parentGroupId, Map ipRange) { + this.id = id; + this.fromPort = fromPort; + this.group = group; + this.ipProtocol = ipProtocol; + this.toPort = toPort; + this.parentGroupId = parentGroupId; + this.ipRange = ipRange; + } + + public String getId() { + return this.id; + } + + public int getFromPort() { + return this.fromPort; + } + + public Map getGroup() { + return this.group; + } + + public IpProtocol getIpProtocol() { + return this.ipProtocol; + } + + public int getToPort() { + return this.toPort; + } + + public String getParentGroupId() { + return this.parentGroupId; + } + + public Map getIpRange() { + return this.ipRange; + } + + @Override + public int compareTo(SecurityGroupRule o) { + return this.id.compareTo(o.getId()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + fromPort; + result = prime * result + ((group == null) ? 0 : group.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + + ((ipProtocol == null) ? 0 : ipProtocol.hashCode()); + result = prime * result + ((ipRange == null) ? 0 : ipRange.hashCode()); + result = prime * result + + ((parentGroupId == null) ? 0 : parentGroupId.hashCode()); + result = prime * result + toPort; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SecurityGroupRule other = (SecurityGroupRule) obj; + if (fromPort != other.fromPort) + return false; + if (group == null) { + if (other.group != null) + return false; + } else if (!group.equals(other.group)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (ipProtocol != other.ipProtocol) + return false; + if (ipRange == null) { + if (other.ipRange != null) + return false; + } else if (!ipRange.equals(other.ipRange)) + return false; + if (parentGroupId == null) { + if (other.parentGroupId != null) + return false; + } else if (!parentGroupId.equals(other.parentGroupId)) + return false; + if (toPort != other.toPort) + return false; + return true; + } + + @Override + public String toString() { + return toStringHelper("").add("id", id).add("fromPort", fromPort) + .add("group", group).add("ipProtocol", ipProtocol) + .add("toPort", toPort).add("parentGroupId", parentGroupId) + .add("ipRange", ipRange).toString(); + } + + +} \ No newline at end of file diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java index d3c64f0c27..fa216636cb 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java @@ -21,6 +21,7 @@ package org.jclouds.openstack.nova.v1_1.domain; import static com.google.common.base.Objects.toStringHelper; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Date; import java.util.Map; import java.util.Set; @@ -29,14 +30,17 @@ import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Address.Type; import org.jclouds.util.Multimaps2; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Maps; import com.google.common.collect.Multimap; +import com.google.gson.annotations.SerializedName; /** - * A server is a virtual machine instance in the compute system. Flavor and image are requisite - * elements when creating a server. + * A server is a virtual machine instance in the compute system. Flavor and + * image are requisite elements when creating a server. * * @author Adrian Cole * @see addresses = LinkedHashMultimap.create(); + private String tenantId; + private String userId; + private Date updated; + private Date created; + private String hostId; + private String accessIPv4; + private String accessIPv6; + private ServerStatus status; + private int progress; + private Resource image; + private Resource flavor; + private Map metadata = Maps.newHashMap(); + // TODO: get gson multimap ad + private Multimap addresses = LinkedHashMultimap + .create(); + /** + * @see Server#getTenantId() + */ + public Builder tenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + /** + * @see Server#getUserId() + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + + /** + * @see Server#getUpdated() + */ + public Builder updated(Date updated) { + this.updated = updated; + return this; + } + + /** + * @see Server#getCreated() + */ + public Builder created(Date created) { + this.created = created; + return this; + } + + /** + * @see Server#getHostId() + */ + public Builder hostId(String hostId) { + this.hostId = hostId; + return this; + } + + /** + * @see Server#getAccessIPv4() + */ + public Builder accessIPv4(String accessIPv4) { + this.accessIPv4 = accessIPv4; + return this; + } + + /** + * @see Server#getAccessIPv6() + */ + public Builder accessIPv6(String accessIPv6) { + this.accessIPv6 = accessIPv6; + return this; + } + + /** + * @see Server#getStatus() + */ + public Builder status(ServerStatus status) { + this.status = status; + return this; + } + + /** + * @see Server#getProgress() + */ + public Builder progress(int progress) { + this.progress = progress; + return this; + } + + /** + * @see Server#getImage() + */ + public Builder image(Resource image) { + this.image = image; + return this; + } + + /** + * @see Server#getImage() + */ + public Builder flavor(Resource flavor) { + this.flavor = flavor; + return this; + } + + /** + * @see Server#getMetadata() + */ + public Builder metadata(Map metadata) { + this.metadata = ImmutableMap.copyOf(metadata); + return this; + } + /** * @see Server#getAddresses() */ public Builder addresses(Multimap addresses) { - this.addresses = ImmutableMultimap.copyOf(checkNotNull(addresses, "addresses")); + this.addresses = ImmutableMultimap.copyOf(checkNotNull(addresses, + "addresses")); return this; } @@ -67,15 +182,16 @@ public class Server extends Resource { * @see Server#getPrivateAddresses() */ public Builder privateAddresses(Address... privateAddresses) { - return privateAddresses(ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"))); + return privateAddresses(ImmutableSet.copyOf(checkNotNull( + privateAddresses, "privateAddresses"))); } /** * @see Server#getPrivateAddresses() */ public Builder privateAddresses(Set
privateAddresses) { - this.addresses.replaceValues(Address.Type.PRIVATE, ImmutableSet.copyOf(checkNotNull(privateAddresses, - "privateAddresses"))); + this.addresses.replaceValues(Address.Type.PRIVATE, ImmutableSet + .copyOf(checkNotNull(privateAddresses, "privateAddresses"))); return this; } @@ -83,20 +199,24 @@ public class Server extends Resource { * @see Server#getPublicAddresses() */ public Builder publicAddresses(Address... publicAddresses) { - return publicAddresses(ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"))); + return publicAddresses(ImmutableSet.copyOf(checkNotNull( + publicAddresses, "publicAddresses"))); } /** * @see Server#getPublicAddresses() */ public Builder publicAddresses(Set
publicAddresses) { - this.addresses.replaceValues(Address.Type.PUBLIC, ImmutableSet.copyOf(checkNotNull(publicAddresses, - "publicAddresses"))); + this.addresses.replaceValues(Address.Type.PUBLIC, ImmutableSet + .copyOf(checkNotNull(publicAddresses, "publicAddresses"))); return this; } public Server build() { - return new Server(id, name, links, addresses); + // return new Server(id, name, links, addresses); + return new Server(id, name, links, tenantId, userId, updated, + created, hostId, accessIPv4, accessIPv6, status, progress, + image, flavor, addresses, metadata); } public Builder fromServer(Server in) { @@ -135,15 +255,101 @@ public class Server extends Resource { return Builder.class.cast(super.fromResource(in)); } } - + + @SerializedName("tenant_id") + protected String tenantId; + @SerializedName("user_id") + protected String userId; + protected Date updated; + protected Date created; + protected String hostId; + protected String accessIPv4; + protected String accessIPv6; + protected ServerStatus status; + protected int progress; + protected Resource image; + protected Resource flavor; // TODO: get gson multimap adapter! protected final Map> addresses; + protected Map metadata; + protected String adminPass; - protected Server(String id, String name, Set links, Multimap addresses) { + protected Server(String id, String name, Set links, String tenantId, + String userId, Date updated, Date created, String hostId, + String accessIPv4, String accessIPv6, ServerStatus status, + int progress, Resource image, Resource flavor, + Multimap addresses, Map metadata) { super(id, name, links); - this.addresses = Multimaps2.toOldSchool(ImmutableMultimap.copyOf(checkNotNull(addresses, "addresses"))); + this.tenantId = tenantId; + this.userId = userId; + this.updated = updated; + this.created = created; + this.hostId = hostId; + this.accessIPv4 = accessIPv4; + this.accessIPv6 = accessIPv6; + this.status = status; + this.progress = progress; + this.image = image; + this.flavor = flavor; + this.metadata = Maps.newHashMap(metadata); + this.addresses = Multimaps2.toOldSchool(ImmutableMultimap + .copyOf(checkNotNull(addresses, "addresses"))); + } + public String getTenantId() { + return this.tenantId; + } + + public String getUserId() { + return this.userId; + } + + public Date getUpdated() { + return this.updated; + } + + public Date getCreated() { + return this.created; + } + + public String getHostId() { + return this.hostId; + } + + public String getAccessIPv4() { + return this.accessIPv4; + } + + public String getAccessIPv6() { + return this.accessIPv6; + } + + public ServerStatus getStatus() { + return this.status; + } + + public int getProgress() { + return this.progress; + } + + public Resource getImage() { + return this.image; + } + + public Resource getFlavor() { + return this.flavor; + } + + public Map getMetadata() { + return this.metadata; + } + + + public String getAdminPass() { + return this.adminPass; + } + /** * @return the private ip addresses assigned to the server */ @@ -167,8 +373,14 @@ public class Server extends Resource { @Override public String toString() { - return toStringHelper("").add("id", id).add("name", name).add("links", links).add("addresses", addresses) - .toString(); + return toStringHelper("").add("id", id).add("name", name) + .add("tenantId", tenantId).add("userId", userId).add("hostId", hostId) + .add("updated", updated).add("created", created) + .add("accessIPv4", accessIPv4).add("accessIPv6", accessIPv6) + .add("status", status).add("progress", progress) + .add("image", image).add("flavor", flavor) + .add("metadata", metadata) + .add("links", links).add("addresses", addresses).toString(); } } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerStatus.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerStatus.java new file mode 100644 index 0000000000..77c9531a04 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerStatus.java @@ -0,0 +1,46 @@ +/** + * 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.openstack.nova.v1_1.domain; + +/** + * Servers contain a status attribute that can be used as an indication of the + * current server state. Servers with an ACTIVE status are available for use. + * + * Other possible values for the status attribute include: BUILD, REBUILD, + * SUSPENDED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, + * HARD_REBOOT, DELETED, UNKNOWN, and ERROR. + * + * @author Adrian Cole + */ +public enum ServerStatus { + ACTIVE, BUILD, REBUILD, SUSPENDED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, ERROR, UNRECOGNIZED; + + public String value() { + return name(); + } + + public static ServerStatus fromValue(String v) { + try { + return valueOf(v); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java index 3fb7059934..ffad009fb4 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java @@ -23,17 +23,15 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Flavor; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SkipEncoding; /** * Provides asynchronous access to Flavors via their REST API. *

* * @see FlavorClient - * @see * @author Jeremy Daggett */ @@ -59,7 +57,7 @@ public interface FlavorClient { * * @param id * id of the flavor - * @return flavorr or null if not found + * @return flavor or null if not found */ Flavor getFlavor(String id); diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPAsyncClient.java new file mode 100644 index 0000000000..f296efb019 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPAsyncClient.java @@ -0,0 +1,121 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Floating IPs via the REST API. + *

+ * + * @see FloatingIPClient + * @author Jeremy Daggett + */ +@SkipEncoding({ '/', '=' }) +@RequestFilters(AuthenticateRequest.class) +public interface FloatingIPAsyncClient { + + /** + * @see FloatingIPClient#listFloatingIPs + */ + @GET + @Path("/os-floating-ips") + @SelectJson("floating_ips") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listFloatingIPs(); + + /** + * @see FloatingIPClient#getFloatingIP + */ + @GET + @Path("/os-floating-ips/{id}") + @SelectJson("floating_ip") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getFloatingIP(@PathParam("id") String id); + + /** + * @see FloatingIPClient#allocate + */ + @POST + @Path("/os-floating-ips") + @SelectJson("floating_ip") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Payload("{}") + ListenableFuture allocate(); + + /** + * @see FloatingIPClient#deallocate + */ + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Path("/os-floating-ips/{id}") + ListenableFuture deallocate(@PathParam("id") String id); + + /** + * @see FloatingIPClient#addFloatingIP + */ + @POST + @Path("/servers/{server}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"addFloatingIp\":%7B\"server\":\"{server}\",\"address\":\"{address}\"%7D%7D") + ListenableFuture addFloatingIP( + @PayloadParam("server") String serverId, + @PayloadParam("address") String address); + + /** + * @see FloatingIPClient#removeFloatingIP + */ + @POST + @Path("/servers/{server}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"removeFloatingIp\":%7B\"server\":\"{server}\",\"address\":\"{address}\"%7D%7D") + ListenableFuture removeFloatingIP( + @PayloadParam("server") String serverId, + @PayloadParam("address") String address); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClient.java new file mode 100644 index 0000000000..7c1e72681e --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClient.java @@ -0,0 +1,89 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; + +/** + * Provides synchronous access to Floating IPs. + *

+ * + * @see FloatingIPAsyncClient + * @author Jeremy Daggett + */ +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface FloatingIPClient { + + /** + * List all Floating IP addresses + * + * @return all Floating IPs + */ + Set listFloatingIPs(); + + /** + * Get a specific Floating IP address + * + * @return all Floating IPs + */ + FloatingIP getFloatingIP(String id); + + /** + * Allocate a Floating IP address + * + * @return a newly allocated FloatingIP + */ + FloatingIP allocate(); + + /** + * Deallocate a Floating IP address + * + * @param id + * the Floating IP id + */ + void deallocate(String id); + + /** + * Add a Floating IP address to a Server + * + * @param serverId + * the serverId + * @param address + * the IP address to add + * + * NOTE: Possibly move this to ServerClient? + */ + void addFloatingIP(String serverId, String address); + + /** + * Remove a Floating IP address from a Server + * + * @param serverId + * the serverId + * @param address + * the IP address to remove + * + * NOTE: Possibly move this to ServerClient? + */ + void removeFloatingIP(String serverId, String address); +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java new file mode 100644 index 0000000000..e62354d3e6 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java @@ -0,0 +1,93 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v1_1.domain.Image; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Images via the REST API. + *

+ * + * @see ImageClient + * @author Jeremy Daggett + */ +@SkipEncoding({ '/', '=' }) +@RequestFilters(AuthenticateRequest.class) +public interface ImageAsyncClient { + + /** + * @see ImageClient#listImages + */ + @GET + @SelectJson("images") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/images") + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listImages(); + + /** + * @see ImageClient#listImagesInDetail + */ + @GET + @SelectJson("images") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/images/detail") + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listImagesInDetail(); + + /** + * @see ImageClient#getImage + */ + @GET + @SelectJson("flavor") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/images/{id}") + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getImage(@PathParam("id") String id); + + /** + * @see ImageClient#deleteImage + */ + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/images/{id}") + @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + ListenableFuture deleteImage(@PathParam("id") String id); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java new file mode 100644 index 0000000000..4d12af704a --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java @@ -0,0 +1,71 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.nova.v1_1.domain.Image; + +/** + * Provides synchronous access to Images. + *

+ * + * @see ImageAsyncClient + * @see + * @author Adrian Cole + */ +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface ImageClient { + + /** + * List all images (IDs, names, links) + * + * @return all images (IDs, names, links) + */ + Set listImages(); + + /** + * List all images (all details) + * + * @return all images (all details) + */ + Set listImagesInDetail(); + + /** + * List details of the specified image + * + * @param id + * id of the server + * @return server or null if not found + */ + Image getImage(String id); + + /** + * Delete the specified image + * + * @param id id of the image + * @return server or null if not found + */ + void deleteImage(String id); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/KeyPairAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/KeyPairAsyncClient.java new file mode 100644 index 0000000000..0827db62fa --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/KeyPairAsyncClient.java @@ -0,0 +1,88 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Map; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v1_1.domain.KeyPair; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Key Pairs via the REST API. + *

+ * + * @see KeyPairClient + * @author Jeremy Daggett + */ +@SkipEncoding({ '/', '=' }) +@RequestFilters(AuthenticateRequest.class) +public interface KeyPairAsyncClient { + + @GET + @Path("/os-keypairs") + @SelectJson("keypairs") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture>> listKeyPairs(); + + + @POST + @Path("/os-keypairs") + @SelectJson("keypair") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"keypair\":%7B\"name\":\"{name}\"%7D%7D") + ListenableFuture createKeyPair(@PayloadParam("name") String name); + + @POST + @Path("/os-keypairs") + @SelectJson("keypair") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"keypair\":%7B\"name\":\"{name}\",\"public_key\":\"{publicKey}\"%7D%7D") + ListenableFuture createKeyPairWithPublicKey(@PayloadParam("name") String name, + @PayloadParam("publicKey") String publicKey); + + @DELETE + @Path("/os-keypairs/{name}") + @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Consumes + ListenableFuture deleteKeyPair(@PathParam("name") String name); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/KeyPairClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/KeyPairClient.java new file mode 100644 index 0000000000..7c4cc70094 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/KeyPairClient.java @@ -0,0 +1,66 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.nova.v1_1.domain.KeyPair; + +/** + * Provides synchronous access to Security Groups. + *

+ * + * @see KeyPairAsyncClient + * @author Jeremy Daggett + */ +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface KeyPairClient { + + /** + * List all Key Pairs. + * + * @return all Key Pairs + */ + Set> listKeyPairs(); + + /** + * Create a Key Pair. + * + * @return a Key Pair + */ + KeyPair createKeyPair(String name); + + /** + * Create a Key Pair with a public key. + * + * @return a Key Pair with a public key. + */ + KeyPair createKeyPairWithPublicKey(String name, String publicKey); + + /** + * Delete a Key Pairs. + * + * @return + */ + Boolean deleteKeyPair(String name); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/SecurityGroupAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/SecurityGroupAsyncClient.java new file mode 100644 index 0000000000..2bd3ab2174 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/SecurityGroupAsyncClient.java @@ -0,0 +1,86 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Security Groups via the REST API. + *

+ * + * @see SecurityGroupClient + * @author Jeremy Daggett + */ +@SkipEncoding({ '/', '=' }) +@RequestFilters(AuthenticateRequest.class) +public interface SecurityGroupAsyncClient { + + /** + * @see SecurityGroupClient#listSecurityGroups + */ + @GET + @SelectJson("security_groups") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/os-security-groups") + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listSecurityGroups(); + + /** + * @see SecurityGroupClient#getSecurityGroup + */ + @GET + @Path("/os-security-groups/{id}") + @SelectJson("security_group") + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getSecurityGroup(@PathParam("id") String id); + + + /** + * @see SecurityGroupClient#createSecurityGroup + */ + @POST + @Path("/os-security-groups") + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Payload("name {name}\n") + @Produces(MediaType.TEXT_PLAIN) + ListenableFuture createSecurityGroup(@PayloadParam("name") String name); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/SecurityGroupClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/SecurityGroupClient.java new file mode 100644 index 0000000000..e4fa5ee454 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/SecurityGroupClient.java @@ -0,0 +1,70 @@ +/** + * 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.openstack.nova.v1_1.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; +import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides synchronous access to Security Groups. + *

+ * + * @see SecurityGroupAsyncClient + * @author Jeremy Daggett + */ +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface SecurityGroupClient { + + /** + * List all Security Groups. + * + * @return all Floating IPs + */ + Set listSecurityGroups(); + + /** + * Get a specific Security Group + * + * @return a specific Security Group + */ + SecurityGroup getSecurityGroup(String id); + + /** + * Create a Security Group + * + * @return a new Security Group + */ + SecurityGroup createSecurityGroup(String name); + +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java index 4857db76b4..4ea13135bc 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java @@ -21,19 +21,32 @@ package org.jclouds.openstack.nova.v1_1.features; import java.util.Set; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.domain.RebootType; import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.options.CreateServerOptions; +import org.jclouds.openstack.nova.v1_1.options.RebuildServerOptions; import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; @@ -81,4 +94,94 @@ public interface ServerAsyncClient { @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getServer(@PathParam("id") String id); + + /** + * @see NovaClient#deleteServer + */ + @DELETE + @Consumes + @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Path("/servers/{id}") + ListenableFuture deleteServer(@PathParam("id") String id); + + /** + * @see NovaClient#rebootServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") + ListenableFuture rebootServer(@PathParam("id") String id, @PayloadParam("type") RebootType rebootType); + + /** + * @see NovaClient#resizeServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D") + ListenableFuture resizeServer(@PathParam("id") String id, @PayloadParam("flavorId") String flavorId); + + /** + * @see NovaClient#confirmResizeServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"confirmResize\":null}") + ListenableFuture confirmResizeServer(@PathParam("id") String id); + + /** + * @see NovaClient#revertResizeServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"revertResize\":null}") + ListenableFuture revertResizeServer(@PathParam("id") String id); + + /** + * @see NovaClient#createServer + */ + @POST + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + @Path("/servers") + @MapBinder(CreateServerOptions.class) + ListenableFuture createServer(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef, + @PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options); + + /** + * @see NovaClient#rebuildServer + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @MapBinder(RebuildServerOptions.class) + ListenableFuture rebuildServer(@PathParam("id") String id, RebuildServerOptions... options); + + + /** + * @see NovaClient#changeAdminPass + */ + @POST + @Path("/servers/{id}/action") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") + ListenableFuture changeAdminPass(@PathParam("id") String id, @PayloadParam("adminPass") String adminPass); + + /** + * @see NovaClient#renameServer + */ + @PUT + @Path("/servers/{id}") + @Consumes + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") + ListenableFuture renameServer(@PathParam("id") String id, @PayloadParam("name") String newName); } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java index 0827e1dda2..a281ad941f 100644 --- a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java @@ -21,9 +21,30 @@ package org.jclouds.openstack.nova.v1_1.features; import java.util.Set; import java.util.concurrent.TimeUnit; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.domain.RebootType; import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.options.CreateServerOptions; +import org.jclouds.openstack.nova.v1_1.options.RebuildServerOptions; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; /** * Provides synchronous access to Server. @@ -60,4 +81,50 @@ public interface ServerClient { */ Server getServer(String id); + /** + * @see NovaClient#createServer + */ + Server createServer(String name, String imageRef, + String flavorRef, CreateServerOptions... options); + + /** + * @see NovaClient#deleteServer + */ + Boolean deleteServer(String id); + + /** + * @see NovaClient#rebootServer + */ + void rebootServer(String id, RebootType rebootType); + + /** + * @see NovaClient#resizeServer + */ + void resizeServer(String id, String flavorId); + + /** + * @see NovaClient#confirmResizeServer + */ + void confirmResizeServer(String id); + + /** + * @see NovaClient#revertResizeServer + */ + void revertResizeServer(String id); + + /** + * @see NovaClient#rebuildServer + */ + void rebuildServer(String id, RebuildServerOptions... options); + + /** + * @see NovaClient#changeAdminPass + */ + void changeAdminPass(String id, String adminPass); + + /** + * @see NovaClient#renameServer + */ + void renameServer(String id, String newName); + } diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java new file mode 100644 index 0000000000..5b36ab0a3c --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java @@ -0,0 +1,245 @@ +/** + * 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.openstack.nova.v1_1.options; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.inject.Inject; + +import org.jclouds.encryption.internal.Base64; +import org.jclouds.http.HttpRequest; +import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToJsonPayload; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + * + */ +public class CreateServerOptions implements MapBinder { + @Inject + private BindToJsonPayload jsonBinder; + + static class File { + private final String path; + private final String contents; + + public File(String path, byte[] contents) { + this.path = checkNotNull(path, "path"); + this.contents = Base64.encodeBytes(checkNotNull(contents, "contents")); + checkArgument(path.getBytes().length < 255, String.format( + "maximum length of path is 255 bytes. Path specified %s is %d bytes", path, path.getBytes().length)); + checkArgument(contents.length < 10 * 1024, String.format( + "maximum size of the file is 10KB. Contents specified is %d bytes", contents.length)); + } + + public String getContents() { + return contents; + } + + public String getPath() { + return path; + } + + } + + @SuppressWarnings("unused") + private class ServerRequest { + final String name; + final String imageRef; + final String flavorRef; + String adminPass; + Map metadata; + List personality; + String key_name; + @SerializedName(value="security_groups") + Set securityGroups; + + private ServerRequest(String name, String imageRef, String flavorRef) { + this.name = name; + this.imageRef = imageRef; + this.flavorRef = flavorRef; + } + + } + + private Map metadata = Maps.newHashMap(); + private List files = Lists.newArrayList(); + private Set securityGroups = Sets.newHashSet(); + private String keyName; + private String adminPass; + + @Override + public R bindToRequest(R request, Map postParams) { + ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present"), + checkNotNull(postParams.get("imageRef"), "imageRef parameter not present"), checkNotNull(postParams + .get("flavorRef"), "flavorRef parameter not present")); + if (metadata.size() > 0) + server.metadata = metadata; + if (files.size() > 0) + server.personality = files; + if (keyName != null) + server.key_name = keyName; + if (securityGroups.size() > 0) { + server.securityGroups = Sets.newHashSet(); + for (String groupName : securityGroups) { + SecurityGroup group = SecurityGroup.builder().name(groupName).build(); + server.securityGroups.add(group); + } + } + if (adminPass != null) { + server.adminPass = adminPass; + } + + return bindToRequest(request, ImmutableMap.of("server", server)); + } + + /** + * You may further customize a cloud server by injecting data into the file system of the cloud + * server itself. This is useful, for example, for inserting ssh keys, setting configuration + * files, or storing data that you want to retrieve from within the instance itself. It is + * intended to provide a minimal amount of launch-time personalization. If significant + * customization is required, a custom image should be created. The max size of the file path + * data is 255 bytes while the max size of the file contents is 10KB. Note that the file contents + * should be encoded as a Base64 string and the 10KB limit refers to the number of bytes in the + * decoded data not the number of characters in the encoded data. The maximum number of file + * path/content pairs that can be supplied is 5. Any existing files that match the specified file + * will be renamed to include the extension bak followed by a time stamp. For example, the file + * /etc/passwd will be backed up as /etc/passwd.bak.1246036261.5785. All files will have root and + * the root group as owner and group owner, respectively and will allow user and group read + * access only (-r--r-----). + */ + public CreateServerOptions withFile(String path, byte[] contents) { + checkState(files.size() < 5, "maximum number of files allowed is 5"); + files.add(new File(path, contents)); + return this; + } + + public CreateServerOptions withAdminPass(String adminPass) { + checkNotNull(adminPass, "adminPass"); + this.adminPass = adminPass; + return this; + } + + /** + * Custom cloud server metadata can also be supplied at launch time. This metadata is stored in + * the API system where it is retrievable by querying the API for server status. The maximum size + * of the metadata key and value is each 255 bytes and the maximum number of key-value pairs that + * can be supplied per server is 5. + */ + public CreateServerOptions withMetadata(Map metadata) { + checkNotNull(metadata, "metadata"); + checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values. You specified: " + + metadata.size()); + for (Entry entry : metadata.entrySet()) { + checkArgument(entry.getKey().getBytes().length < 255, String.format( + "maximum length of metadata key is 255 bytes. Key specified %s is %d bytes", entry.getKey(), entry + .getKey().getBytes().length)); + checkArgument(entry.getKey().getBytes().length < 255, String.format( + "maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes", entry + .getKey(), entry.getValue(), entry.getValue().getBytes().length)); + } + this.metadata = metadata; + return this; + } + + /** + * A keypair name can be defined when creating a server. This key will be + * linked to the server and used to SSH connect to the machine + * + * @param keyName + * @return + */ + public CreateServerOptions withKeyName(String keyName) { + checkNotNull(keyName, "keyName"); + this.keyName = keyName; + return this; + } + + /** + * Defines the security group name to be used when creating a server. + * + * @param groupName + * @return + */ + public CreateServerOptions withSecurityGroup(String groupName) { + checkNotNull(groupName, "groupName"); + this.securityGroups.add(groupName); + return this; + } + + public static class Builder { + + /** + * @see CreateServerOptions#withFile(String,byte []) + */ + public static CreateServerOptions withFile(String path, byte[] contents) { + CreateServerOptions options = new CreateServerOptions(); + return options.withFile(path, contents); + } + + public static CreateServerOptions withAdminPass(String adminPass) { + CreateServerOptions options = new CreateServerOptions(); + return options.withAdminPass(adminPass); + } + + /** + * @see CreateServerOptions#withMetadata(Map) + */ + public static CreateServerOptions withMetadata(Map metadata) { + CreateServerOptions options = new CreateServerOptions(); + return options.withMetadata(metadata); + } + + /** + * @see CreateServerOptions#withKeyName(String) + */ + public static CreateServerOptions withKeyName(String keyName) { + CreateServerOptions options = new CreateServerOptions(); + return options.withKeyName(keyName); + } + + /** + * @see CreateServerOptions#withGroupName(String) + */ + public static CreateServerOptions withSecurityGroup(String name) { + CreateServerOptions options = new CreateServerOptions(); + return options.withSecurityGroup(name); + } + } + + @Override + public R bindToRequest(R request, Object input) { + return jsonBinder.bindToRequest(request, input); + } +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java new file mode 100644 index 0000000000..1f922bbbd2 --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java @@ -0,0 +1,109 @@ +/** + * 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.openstack.nova.v1_1.options; + +import java.util.Date; + +import org.jclouds.openstack.options.BaseListOptions; + +/** + * Options used to control the amount of detail in the request. + * + * @see BaseListOptions + * @see + * @author Adrian Cole + */ +public class ListOptions extends BaseListOptions { + + public static final ListOptions NONE = new ListOptions(); + + /** + * unless used, only the name and id will be returned per row. + * + * @return + */ + public ListOptions withDetails() { + this.pathSuffix = "/detail"; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ListOptions changesSince(Date ifModifiedSince) { + super.changesSince(ifModifiedSince); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ListOptions maxResults(int limit) { + super.maxResults(limit); + return this; + + } + + /** + * {@inheritDoc} + */ + @Override + public ListOptions startAt(long offset) { + super.startAt(offset); + return this; + } + + public static class Builder { + + /** + * @see ListOptions#withDetails() + */ + public static ListOptions withDetails() { + ListOptions options = new ListOptions(); + return options.withDetails(); + } + + /** + * @see BaseListOptions#startAt(long) + */ + public static ListOptions startAt(long prefix) { + ListOptions options = new ListOptions(); + return options.startAt(prefix); + } + + /** + * @see BaseListOptions#maxResults(long) + */ + public static ListOptions maxResults(int maxKeys) { + ListOptions options = new ListOptions(); + return options.maxResults(maxKeys); + } + + /** + * @see BaseListOptions#changesSince(Date) + */ + public static ListOptions changesSince(Date since) { + ListOptions options = new ListOptions(); + return options.changesSince(since); + } + + } +} diff --git a/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/RebuildServerOptions.java b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/RebuildServerOptions.java new file mode 100644 index 0000000000..42eee7df4b --- /dev/null +++ b/labs/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/RebuildServerOptions.java @@ -0,0 +1,80 @@ +/** + * 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.openstack.nova.v1_1.options; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToJsonPayload; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; + +/** + * + * + * @author Adrian Cole + * + */ +public class RebuildServerOptions implements MapBinder { + @Inject + private BindToJsonPayload jsonBinder; + String imageRef; + + @Override + public R bindToRequest(R request, Map postParams) { + Map image = Maps.newHashMap(); + if (imageRef != null) + image.put("imageRef", imageRef); + return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image)); + } + + @Override + public R bindToRequest(R request, Object toBind) { + throw new IllegalStateException("RebuildServer is a POST operation"); + } + + /** + * @param ref + * - reference of the image to rebuild the server with. + */ + public RebuildServerOptions withImage(String ref) { + checkNotNull(ref, "image reference should not be null"); + checkArgument(!ref.isEmpty(), "image reference should not be empty"); + this.imageRef = ref; + return this; + } + + public static class Builder { + + /** + * @see RebuildServerOptions#withImage(String) + */ + public static RebuildServerOptions withImage(String ref) { + RebuildServerOptions options = new RebuildServerOptions(); + return options.withImage(ref); + } + } +} diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java index 3073a2699d..bcd103da73 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientExpectTest.java @@ -1,6 +1,7 @@ package org.jclouds.openstack.nova.v1_1.features; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.net.URI; @@ -21,56 +22,102 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Daggett */ -@Test(groups = "unit", testName = "FlavorAsyncClientTest") +@Test(groups = "unit", testName = "FlavorClientExpectTest") public class FlavorClientExpectTest extends BaseNovaRestClientExpectTest { public void testListFlavorsWhenResponseIs2xx() throws Exception { - HttpRequest listServers = HttpRequest.builder().method("GET").endpoint( - URI.create("https://compute.north.host/v1.1/3456/flavors")).headers( - ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", - authToken).build()).build(); + HttpRequest listFlavors = HttpRequest + .builder() + .method("GET") + .endpoint( + URI.create("https://compute.north.host/v1.1/3456/flavors")) + .headers( + ImmutableMultimap. builder() + .put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); - HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200).payload( - payloadFromResource("/flavor_list.json")).build(); + HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/flavor_list.json")).build(); - NovaClient clientWhenFlavorsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, - responseWithKeystoneAccess, listServers, listFlavorsResponse); + NovaClient clientWhenFlavorsExist = requestsSendResponses( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, + listFlavors, listFlavorsResponse); - assertEquals(clientWhenFlavorsExist.getConfiguredRegions(), ImmutableSet.of("North")); + assertEquals(clientWhenFlavorsExist.getConfiguredRegions(), + ImmutableSet.of("North")); - assertEquals(clientWhenFlavorsExist.getFlavorClientForRegion("North").listFlavors().toString(), - new ParseFlavorListTest().expected().toString()); + assertEquals(clientWhenFlavorsExist.getFlavorClientForRegion("North") + .listFlavors().toString(), new ParseFlavorListTest().expected() + .toString()); } public void testListFlavorsWhenReponseIs404IsEmpty() throws Exception { - HttpRequest listFlavors = HttpRequest.builder().method("GET").endpoint( - URI.create("https://compute.north.host/v1.1/3456/flavors")).headers( - ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", - authToken).build()).build(); + HttpRequest listFlavors = HttpRequest + .builder() + .method("GET") + .endpoint( + URI.create("https://compute.north.host/v1.1/3456/flavors")) + .headers( + ImmutableMultimap. builder() + .put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); - HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404).build(); + HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404) + .build(); - NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, - responseWithKeystoneAccess, listFlavors, listFlavorsResponse); + NovaClient clientWhenNoServersExist = requestsSendResponses( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, + listFlavors, listFlavorsResponse); - assertTrue(clientWhenNoServersExist.getFlavorClientForRegion("North").listFlavors().isEmpty()); + assertTrue(clientWhenNoServersExist.getFlavorClientForRegion("North") + .listFlavors().isEmpty()); } // TODO: gson deserializer for Multimap public void testGetFlavorWhenResponseIs2xx() throws Exception { - HttpRequest getFlavor = HttpRequest.builder().method("GET").endpoint( - URI.create("https://compute.north.host/v1.1/3456/flavors/foo")).headers( - ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", - authToken).build()).build(); - HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(200).payload( - payloadFromResource("/flavor_details.json")).build(); + HttpRequest getFlavor = HttpRequest + .builder() + .method("GET") + .endpoint( + URI.create("https://compute.north.host/v1.1/3456/flavors/52415800-8b69-11e0-9b19-734f1195ff37")) + .headers( + ImmutableMultimap. builder() + .put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); - NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, - responseWithKeystoneAccess, getFlavor, getFlavorResponse); + HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/flavor_details.json")).build(); + + NovaClient clientWhenFlavorsExist = requestsSendResponses( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, + getFlavor, getFlavorResponse); + + assertEquals(clientWhenFlavorsExist.getFlavorClientForRegion("North") + .getFlavor("52415800-8b69-11e0-9b19-734f1195ff37").toString(), + new ParseFlavorTest().expected().toString()); + } + + public void testGetFlavorWhenResponseIs404() throws Exception { + HttpRequest getFlavor = HttpRequest + .builder() + .method("GET") + .endpoint( + URI.create("https://compute.north.host/v1.1/3456/flavors/123")) + .headers( + ImmutableMultimap. builder() + .put("Accept", "application/json") + .put("X-Auth-Token", authToken).build()).build(); + + HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(404) + .payload(payloadFromResource("/flavor_details.json")).build(); + + NovaClient clientWhenNoFlavorsExist = requestsSendResponses( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess, + getFlavor, getFlavorResponse); + + assertNull(clientWhenNoFlavorsExist.getFlavorClientForRegion("North").getFlavor("123")); - assertEquals(clientWhenServersExist.getFlavorClientForRegion("North").getFlavor("foo").toString(), - new ParseFlavorTest().expected().toString()); } } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java index 0aa307116a..2a637169fb 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java @@ -36,7 +36,11 @@ import org.testng.annotations.Test; @Test(groups = "live", testName = "FlavorClientLiveTest") public class FlavorClientLiveTest extends BaseNovaClientLiveTest { - + /** + * Tests the listing of Flavors (getFlavor() is tested too!) + * + * @throws Exception + */ @Test public void testListFlavors() throws Exception { for (String regionId : context.getApi().getConfiguredRegions()) { @@ -53,4 +57,29 @@ public class FlavorClientLiveTest extends BaseNovaClientLiveTest { } } + /** + * Tests the listing of Flavors in detail (getFlavor() is tested too!) + * + * @throws Exception + */ + @Test + public void testListFlavorsInDetail() throws Exception { + for (String regionId : context.getApi().getConfiguredRegions()) { + FlavorClient client = context.getApi().getFlavorClientForRegion(regionId); + Set response = client.listFlavorsInDetail(); + assert null != response; + assertTrue(response.size() >= 0); + for (Flavor flavor : response) { + Flavor newDetails = client.getFlavor(flavor.getId()); + assertEquals(newDetails.getId(), flavor.getId()); + assertEquals(newDetails.getName(), flavor.getName()); + assertEquals(newDetails.getLinks(), flavor.getLinks()); + assertEquals(newDetails.getRam(), flavor.getRam()); + assertEquals(newDetails.getDisk(), flavor.getDisk()); + assertEquals(newDetails.getVcpus(), flavor.getVcpus()); + } + } + + } + } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClientExpectTest.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClientLiveTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClientLiveTest.java new file mode 100644 index 0000000000..93115a5735 --- /dev/null +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FloatingIPClientLiveTest.java @@ -0,0 +1,59 @@ +/** + * 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.openstack.nova.v1_1.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; +import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code ServerClient} + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "FloatingIPClientLiveTest") +public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { + + @Test + public void testListFloatingIPs() throws Exception { + for (String regionId : context.getApi().getConfiguredRegions()) { + + FloatingIPClient client = context.getApi().getFloatingIPClientForRegion(regionId); + Set response = client.listFloatingIPs(); + assert null != response; + assertTrue(response.size() >= 0); + for (FloatingIP ip : response) { + FloatingIP newDetails = client.getFloatingIP(ip.getId()); + + + assertEquals(newDetails.getId(), ip.getId()); + assertEquals(newDetails.getIp(), ip.getIp()); + assertEquals(newDetails.getFixedIp(), ip.getFixedIp()); + assertEquals(newDetails.getInstanceId(), ip.getInstanceId()); + + } + } + } +} diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java index 265290a65a..122aea155b 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientExpectTest.java @@ -73,22 +73,4 @@ public class ServerClientExpectTest extends BaseNovaRestClientExpectTest { assertTrue(clientWhenNoServersExist.getServerClientForRegion("North").listServers().isEmpty()); } - - // TODO: gson deserializer for Multimap - public void testGetServerWhenResponseIs2xx() throws Exception { - HttpRequest listServers = HttpRequest.builder().method("GET").endpoint( - URI.create("https://compute.north.host/v1.1/3456/servers/foo")).headers( - ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", - authToken).build()).build(); - - HttpResponse listServersResponse = HttpResponse.builder().statusCode(200).payload( - payloadFromResource("/server_details.json")).build(); - - NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey, - responseWithKeystoneAccess, listServers, listServersResponse); - - assertEquals(clientWhenServersExist.getServerClientForRegion("North").getServer("foo").toString(), - new ParseServerTest().expected().toString()); - } - } diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java new file mode 100644 index 0000000000..da4a4c63bd --- /dev/null +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java @@ -0,0 +1,87 @@ +/** + * 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.openstack.nova.v1_1.parse; + +import java.net.URI; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.json.BaseSetParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; +import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * + * @author Jeremy Daggett + */ +@Test(groups = "unit", testName = "ParseImageListTest") +public class ParseImageListTest extends BaseSetParserTest { + + @Override + public String resource() { + return "/image_list.json"; + } + + @Override + @SelectJson("images") + @Consumes(MediaType.APPLICATION_JSON) + public Set expected() { + return ImmutableSet + .of(Resource + .builder() + .id("52415800-8b69-11e0-9b19-734f6f006e54") + .name("CentOS 5.2") + .links( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"))) + .build(), + Resource + .builder() + .id("52415800-8b69-11e0-9b19-734f5736d2a2") + .name("My Server Backup") + .links( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"))) + .build()); + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } + +} diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java new file mode 100644 index 0000000000..7291cd985f --- /dev/null +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java @@ -0,0 +1,104 @@ +/** + * 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.openstack.nova.v1_1.parse; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.domain.Link.Relation; +import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; +import org.jclouds.openstack.nova.v1_1.domain.Image; +import org.jclouds.openstack.nova.v1_1.domain.ImageStatus; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * @author Jeremy Daggett + */ +@Test(groups = "unit", testName = "ParseImageTest") +public class ParseImageTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/image_details.json"; + } + + @Override + @SelectJson("image") + @Consumes(MediaType.APPLICATION_JSON) + public Image expected() { + return Image + .builder() + .id("52415800-8b69-11e0-9b19-734f5736d2a2") + .name("My Server Backup") + .updated( + new SimpleDateFormatDateService() + .iso8601SecondsDateParse("2010-10-10T12:00:00Z")) + .created( + new SimpleDateFormatDateService() + .iso8601SecondsDateParse("2010-08-10T12:00:00Z")) + .tenantId("12345") + .userId("joe") + .status(ImageStatus.SAVING) + .progress(80) + .minDisk(5) + .minRam(256) + .metadata(new ImmutableMap.Builder() + .put("ImageType", "Gold") + .put("ImageVersion", "1.5").build()) + .server( + Resource + .builder() + .id("52415800-8b69-11e0-9b19-734f335aa7b3") + .name("null") + .links( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3"))) + .build()) + .links( + ImmutableSet.of( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")))) + .build(); + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } +} diff --git a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java index f7556f8697..473df24cad 100644 --- a/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java +++ b/labs/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java @@ -18,17 +18,25 @@ */ package org.jclouds.openstack.nova.v1_1.parse; +import java.net.URI; + import javax.ws.rs.Consumes; import javax.ws.rs.core.MediaType; +import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.domain.Link.Relation; +import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.domain.ServerStatus; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMap; import com.google.inject.Guice; import com.google.inject.Injector; @@ -48,12 +56,56 @@ public class ParseServerTest extends BaseItemParserTest { @Consumes(MediaType.APPLICATION_JSON) public Server expected() { return Server - .builder() - .id("52415800-8b69-11e0-9b19-734f000004d2") - .name("sample-server") - .publicAddresses(Address.createV4("67.23.10.132"), Address.createV6("::babe:67.23.10.132"), - Address.createV4("67.23.10.131"), Address.createV6("::babe:4317:0A83")).privateAddresses( - Address.createV4("10.176.42.16"), Address.createV6("::babe:10.176.42.16")).build(); + .builder() + .id("52415800-8b69-11e0-9b19-734f000004d2") + .tenantId("1234") + .userId("5678") + .name("sample-server") + .updated( + new SimpleDateFormatDateService() + .iso8601SecondsDateParse("2010-10-10T12:00:00Z")) + .created( + new SimpleDateFormatDateService() + .iso8601SecondsDateParse("2010-08-10T12:00:00Z")) + .hostId("e4d909c290d0fb1ca068ffaddf22cbd0") + .accessIPv4("67.23.10.132") + .accessIPv6("::babe:67.23.10.132") + .status(ServerStatus.BUILD) + .progress(60) + .image( + Resource + .builder() + .id("52415800-8b69-11e0-9b19-734f6f006e54") + .name("null") + .links( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"))) + .build()) + .flavor(Resource + .builder() + .id("52415800-8b69-11e0-9b19-734f216543fd") + .name("null") + .links( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"))) + .build()) + .metadata(new ImmutableMap.Builder() + .put("Server Label", "Web Head 1") + .put("Image Version", "2.1").build()) + .publicAddresses(Address.createV4("67.23.10.132"), + Address.createV6("::babe:67.23.10.132"), + Address.createV4("67.23.10.131"), + Address.createV6("::babe:4317:0A83")) + .privateAddresses(Address.createV4("10.176.42.16"), + Address.createV6("::babe:10.176.42.16")).build(); } diff --git a/labs/openstack-nova/src/test/resources/floatingip_details.json b/labs/openstack-nova/src/test/resources/floatingip_details.json new file mode 100644 index 0000000000..c2411fd65f --- /dev/null +++ b/labs/openstack-nova/src/test/resources/floatingip_details.json @@ -0,0 +1,9 @@ +{ + "floating_ip" : + { + "id" : 1, + "ip" : "10.0.0.3", + "fixed_ip" : "10.0.0.2", + "instance_id" : 123 + } +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/floatingip_list.json b/labs/openstack-nova/src/test/resources/floatingip_list.json new file mode 100644 index 0000000000..27d251926a --- /dev/null +++ b/labs/openstack-nova/src/test/resources/floatingip_list.json @@ -0,0 +1,16 @@ +{ + "floating_ips" : [ + { + "instance_id": 12, + "ip" : "10.0.0.3", + "fixed_ip": "11.0.0.1", + "id" : 1 + }, + { + "instance_id": null, + "ip": "10.0.0.5", + "fixed_ip": null, + "id": 2 + } + ] +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/image_details.json b/labs/openstack-nova/src/test/resources/image_details.json new file mode 100644 index 0000000000..b75d94c8db --- /dev/null +++ b/labs/openstack-nova/src/test/resources/image_details.json @@ -0,0 +1,41 @@ +{ + "image" : { + "id" : "52415800-8b69-11e0-9b19-734f5736d2a2", + "name" : "My Server Backup", + "updated" : "2010-10-10T12:00:00Z", + "created" : "2010-08-10T12:00:00Z", + "tenant_id" : "12345", + "user_id" : "joe", + "status" : "SAVING", + "progress" : 80, + "minDisk" : 5, + "minRam" : 256, + "metadata" : { + "ImageType" : "Gold", + "ImageVersion" : "1.5" + }, + "server" : { + "id": "52415800-8b69-11e0-9b19-734f335aa7b3", + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" + } + ] + }, + "links": [ + { + "rel" : "self", + "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + }, + { + "rel" : "bookmark", + "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + } + ] + } +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/image_list.json b/labs/openstack-nova/src/test/resources/image_list.json new file mode 100644 index 0000000000..afecf34dac --- /dev/null +++ b/labs/openstack-nova/src/test/resources/image_list.json @@ -0,0 +1,32 @@ +{ + "images": [ + { + "id": "52415800-8b69-11e0-9b19-734f6f006e54", + "name": "CentOS 5.2", + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" + } + ] + }, + { + "id" : "52415800-8b69-11e0-9b19-734f5736d2a2", + "name" : "My Server Backup", + "links": [ + { + "rel" : "self", + "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + }, + { + "rel" : "bookmark", + "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + } + ] + } + ] +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/keypair_created.json b/labs/openstack-nova/src/test/resources/keypair_created.json new file mode 100644 index 0000000000..188f9296ae --- /dev/null +++ b/labs/openstack-nova/src/test/resources/keypair_created.json @@ -0,0 +1,9 @@ +{ + "keypair": { + "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n", + "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIAAAKBgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABAC\nE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumA\nDSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQIDAQAB\nAoGAW8Ww+KbpQK8smcgCTr/RqcmsSI8VeL2hXjJvDq0L5WbyYuFdkanDvCztUVZn\nsmyfDtwAqZXB4Ct/dN1tY7m8QpdyRaKRW4Q+hghGCAQpsG7rYDdvwdEyvMaW5RA4\ntucQyajMNyQ/tozU3wMx/v8A7RvGcE9tqoG0WK1C3kBu95UCQQDrOd+joYDkvccz\nFIVu5gNPMXEh3fGGzDxk225UlvESquYLzfz4TfmuUjH4Z1BL3wRiwfJsrrjFkm33\njIidDE8PAkEA1qHjxuaIS1yz/rfzErmcOVNlbFHMP4ihjGTTvh1ZctXlNeLwzENQ\nEDaQV3IpUY1KQR6rxcWb5AXgfF9D9PYFpwJBANucAqGAbRgh3lJgPFtXP4u2O0tF\nLPOOxmvbOdybt6KYD4LB5AXmts77SlACFMNhCXUyYaT6UuOSXDyb5gfJsB0CQQC3\nFaGXKU9Z+doQjhlq/6mjvN/nZl80Uvh7Kgb1RVPoAU1kihGeLE0/h0vZTCiyyDNv\nGRqtucMg32J+tUTi0HpBAkAwHiCZMHMeJWHUwIwlRQY/dnR86FWobRl98ViF2rCL\nDHkDVOeIser3Q6zSqU5/m99lX6an5g8pAh/R5LqnOQZC\n-----END RSA PRIVATE KEY-----\n", + "user_id": "65649731189278", + "name": "testkeypair", + "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4" + } +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/keypair_list.json b/labs/openstack-nova/src/test/resources/keypair_list.json new file mode 100644 index 0000000000..1c14e2fbe1 --- /dev/null +++ b/labs/openstack-nova/src/test/resources/keypair_list.json @@ -0,0 +1,18 @@ +{ + "keypairs": [ + { + "keypair": { + "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001\n", + "name": "default", + "fingerprint": "ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c" + } + }, + { + "keypair": { + "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n", + "name": "testkeypair", + "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4" + } + } + ] +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/securitygroup_details.json b/labs/openstack-nova/src/test/resources/securitygroup_details.json new file mode 100644 index 0000000000..840de6ce54 --- /dev/null +++ b/labs/openstack-nova/src/test/resources/securitygroup_details.json @@ -0,0 +1,34 @@ +{ + "security_group": + { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 28, + "ip_range": { + "cidr": "10.2.6.0/24" + }, + "id": 108 + }, + { + "from_port": 22, + "group": { + "tenant_id": "admin", + "name": "11111" + }, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 28, + "ip_range": {}, + "id": 109 + } + ], + "tenant_id": "tenant0", + "id": 0, + "name": "name0", + "description": "description0" + } +} \ No newline at end of file diff --git a/labs/openstack-nova/src/test/resources/securitygroup_list.json b/labs/openstack-nova/src/test/resources/securitygroup_list.json new file mode 100644 index 0000000000..b5a1ed1bfc --- /dev/null +++ b/labs/openstack-nova/src/test/resources/securitygroup_list.json @@ -0,0 +1,51 @@ +{ + "security_groups":[ + { + "rules":[ + { + "from_port":22, + "group":{ + + }, + "ip_protocol":"tcp", + "to_port":22, + "parent_group_id":3, + "ip_range":{ + "cidr":"0.0.0.0/0" + }, + "id":107 + }, + { + "from_port":7600, + "group":{ + + }, + "ip_protocol":"tcp", + "to_port":7600, + "parent_group_id":3, + "ip_range":{ + "cidr":"0.0.0.0/0" + }, + "id":118 + }, + { + "from_port":8084, + "group":{ + + }, + "ip_protocol":"tcp", + "to_port":8084, + "parent_group_id":3, + "ip_range":{ + "cidr":"0.0.0.0/0" + }, + "id":119 + } + ], + "tenant_id":"tenant1", + "id":1, + "name":"name1", + "description":"description1" + } + ] +} \ No newline at end of file diff --git a/labs/opsource-servers/pom.xml b/labs/opsource-servers/pom.xml new file mode 100644 index 0000000000..ef4eb9cb8a --- /dev/null +++ b/labs/opsource-servers/pom.xml @@ -0,0 +1,137 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + opsource-servers + jcloud opsource-servers api + jclouds components to access an implementation of OpSource Cloud Servers + bundle + + + https://api.opsourcecloud.net/oec/${jclouds.api-version} + 0.9 + + FIXME_USERNAME + FIXME_PASSWORD + + + + + + + + org.jclouds + jclouds-compute + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-sshj + ${project.version} + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.opsource-servers.endpoint} + ${test.opsource-servers.api-version} + ${test.opsource-servers.build-version} + ${test.opsource-servers.identity} + ${test.opsource-servers.credential} + ${test.opsource-servers.image-id} + ${test.opsource-servers.image.login-user} + ${test.opsource-servers.image.authenticate-sudo} + + + + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jclouds.vcloud.director.v1_5*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + + + diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceNameSpaces.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceNameSpaces.java new file mode 100644 index 0000000000..474dd6d3a1 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceNameSpaces.java @@ -0,0 +1,28 @@ +/* + * 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.opsource.servers; + + +/** + * + * @author Adrian Cole + */ +public interface OpSourceNameSpaces { + public static final String DIRECTORY = "http://oec.api.opsource.net/schemas/directory"; +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersAsyncClient.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersAsyncClient.java new file mode 100644 index 0000000000..2b07e18972 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersAsyncClient.java @@ -0,0 +1,38 @@ +/** + * 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.opsource.servers; + +import org.jclouds.opsource.servers.features.AccountAsyncClient; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides asynchronous access to OpSourceServers via their REST API. + * + * @see OpSourceServersClient + * @author Adrian Cole + */ +public interface OpSourceServersAsyncClient { + + /** + * @return asynchronous access to {@link Account} features + */ + @Delegate + AccountAsyncClient getAccountClient(); + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersClient.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersClient.java new file mode 100644 index 0000000000..16822419ff --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersClient.java @@ -0,0 +1,42 @@ +/** + * 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.opsource.servers; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.opsource.servers.features.AccountClient; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides synchronous access to OpSourceServers. + * + * @see OpSourceServersAsyncClient + * @author Adrian Cole + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface OpSourceServersClient { + + /** + * @return synchronous access to {@link Account} features + */ + @Delegate + AccountClient getAccountClient(); + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java new file mode 100644 index 0000000000..5c8cf97d26 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java @@ -0,0 +1,43 @@ +/** + * 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.opsource.servers; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.rest.RestContextBuilder; +import org.jclouds.opsource.servers.config.OpSourceServersRestClientModule; + +import com.google.inject.Module; + +/** + * @author Adrian Cole + */ +public class OpSourceServersContextBuilder extends RestContextBuilder { + + public OpSourceServersContextBuilder(Properties props) { + super(OpSourceServersClient.class, OpSourceServersAsyncClient.class, props); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new OpSourceServersRestClientModule()); + } + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java new file mode 100644 index 0000000000..28cc359507 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersPropertiesBuilder.java @@ -0,0 +1,47 @@ +/* + * 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.opsource.servers; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; + +import java.util.Properties; + +import org.jclouds.PropertiesBuilder; + +/** + * Builds properties used in OpSourceServers clients + * + * @author Adrian Cole + */ +public class OpSourceServersPropertiesBuilder extends PropertiesBuilder { + + @Override + public Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ENDPOINT, "https://api.opsourcecloud.net/oec/${jclouds.api-version}"); + properties.setProperty(PROPERTY_API_VERSION, "0.9"); + return properties; + } + + public OpSourceServersPropertiesBuilder(Properties properties) { + super(properties); + } + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java new file mode 100644 index 0000000000..736526e296 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java @@ -0,0 +1,69 @@ +/** + * 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.opsource.servers.config; + +import java.util.Map; + +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.RequiresHttp; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.http.annotation.Redirection; +import org.jclouds.http.annotation.ServerError; +import org.jclouds.location.suppliers.ImplicitLocationSupplier; +import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone; +import org.jclouds.opsource.servers.OpSourceServersAsyncClient; +import org.jclouds.opsource.servers.OpSourceServersClient; +import org.jclouds.opsource.servers.features.AccountAsyncClient; +import org.jclouds.opsource.servers.features.AccountClient; +import org.jclouds.opsource.servers.handlers.OpSourceServersErrorHandler; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.config.RestClientModule; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Scopes; + +/** + * Configures the OpSourceServers connection. + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class OpSourceServersRestClientModule extends + RestClientModule { + + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// + .put(AccountClient.class, AccountAsyncClient.class).build(); + + public OpSourceServersRestClientModule() { + super(OpSourceServersClient.class, OpSourceServersAsyncClient.class, DELEGATE_MAP); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(OpSourceServersErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(OpSourceServersErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(OpSourceServersErrorHandler.class); + } + + @Override + protected void installLocations() { + super.installLocations(); + bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON); + } +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/domain/Account.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/domain/Account.java new file mode 100644 index 0000000000..43d8e88b3f --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/domain/Account.java @@ -0,0 +1,105 @@ +/* + * 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.opsource.servers.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.opsource.servers.OpSourceNameSpaces.DIRECTORY; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * + * + */ +@XmlRootElement(name = "Account", namespace = DIRECTORY) +public class Account { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromAccount(this); + } + + public static class Builder { + + private String orgId; + + /** + * @see Account#getOrgId() + */ + public Builder orgId(String orgId) { + this.orgId = orgId; + return this; + } + + public Account build() { + return new Account(orgId); + } + + public Builder fromAccount(Account in) { + return orgId(in.getOrgId()); + } + } + + private Account() { + // For JAXB and builder use + } + + @XmlElement(namespace = DIRECTORY) + protected String orgId; + + private Account(String orgId) { + this.orgId = orgId; + } + + /** + * + * @return your Organization ID that will be used as the basis for subsequent + * API interactions + * + */ + public String getOrgId() { + return orgId; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Account that = Account.class.cast(o); + return equal(orgId, that.orgId); + } + + @Override + public int hashCode() { + return Objects.hashCode(orgId); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("orgId", orgId).toString(); + } + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/features/AccountAsyncClient.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/features/AccountAsyncClient.java new file mode 100644 index 0000000000..7c3f8fbb9c --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/features/AccountAsyncClient.java @@ -0,0 +1,48 @@ +/** + * 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.opsource.servers.features; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +import org.jclouds.http.filters.BasicAuthentication; +import org.jclouds.opsource.servers.domain.Account; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.RequestFilters; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * @see AccountClient + * @author Adrian Cole + */ +@RequestFilters(BasicAuthentication.class) +public interface AccountAsyncClient { + + /** + * @see AccountClient#getMyAccount() + */ + @GET + @Path("/myaccount") + @Consumes + @JAXBResponseParser + ListenableFuture getMyAccount(); + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/features/AccountClient.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/features/AccountClient.java new file mode 100644 index 0000000000..1495a87924 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/features/AccountClient.java @@ -0,0 +1,44 @@ +/** + * 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.opsource.servers.features; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.opsource.servers.domain.Account; + +/** + * Provides synchronous access to Account. + *

+ * + * @see AccountAsyncClient + * @author Adrian Cole + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface AccountClient { + + /** + * Before you can begin using the range of Server, Network and Image APIs, + * you will need to first obtain your organization details. + * + * @return the user's details, including their organization ID. + */ + Account getMyAccount(); + +} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/handlers/OpSourceServersErrorHandler.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/handlers/OpSourceServersErrorHandler.java new file mode 100644 index 0000000000..d3d905b400 --- /dev/null +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/handlers/OpSourceServersErrorHandler.java @@ -0,0 +1,66 @@ +/** + * 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.opsource.servers.handlers; + +import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; + +import javax.inject.Singleton; + +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.ResourceNotFoundException; + +/** + * This will parse and set an appropriate exception on the command object. + * + * @author Adrian Cole + * + */ +@Singleton +public class OpSourceServersErrorHandler implements HttpErrorHandler { + + public void handleError(HttpCommand command, HttpResponse response) { + // it is important to always read fully and close streams + byte[] data = closeClientButKeepContentStream(response); + String message = data != null ? new String(data) : null; + + Exception exception = message != null ? new HttpResponseException(command, response, message) + : new HttpResponseException(command, response); + message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), + response.getStatusLine()); + switch (response.getStatusCode()) { + case 401: + exception = new AuthorizationException(message, exception); + break; + case 404: + if (!command.getCurrentRequest().getMethod().equals("DELETE")) { + exception = new ResourceNotFoundException(message, exception); + } + break; + default: + exception = new HttpResponseException(command, response, message); + break; + } + command.setException(exception); + } + +} diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java new file mode 100644 index 0000000000..584a74709d --- /dev/null +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/OpSourceServersClientExperimentLiveTest.java @@ -0,0 +1,37 @@ +/** + * 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.opsource.servers; + +import org.jclouds.opsource.servers.domain.Account; +import org.jclouds.opsource.servers.internal.BaseOpSourceServersClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "OpSourceServersClientExperimentLiveTest") +public class OpSourceServersClientExperimentLiveTest extends BaseOpSourceServersClientLiveTest { + + public void testImplicitSession() { + Account account = context.getApi().getAccountClient().getMyAccount(); + assert account.getOrgId() != null; + } + +} diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientExpectTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientExpectTest.java new file mode 100644 index 0000000000..c0e759c0ee --- /dev/null +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientExpectTest.java @@ -0,0 +1,60 @@ +/* + * 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.opsource.servers.features; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.opsource.servers.OpSourceServersClient; +import org.jclouds.opsource.servers.domain.Account; +import org.jclouds.opsource.servers.internal.BaseOpSourceServersRestClientExpectTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; + +/** + * Allows us to test the {@link AccountClient} via its side effects. + * + * @author Adrian Cole + */ +@Test(groups = { "unit" }, singleThreaded = true, testName = "AccountClientExpectTest") +public class AccountClientExpectTest extends BaseOpSourceServersRestClientExpectTest { + + @Test + public void testGetMyAccount() { + OpSourceServersClient client = requestSendsResponse( + HttpRequest + .builder() + .method("GET") + .endpoint(URI.create("https://api.opsourcecloud.net/oec/0.9/myaccount")) + .headers( + ImmutableMultimap. builder().put("Accept", "*/*") + .put("Authorization", "Basic dXNlcjpwYXNzd29yZA==").build()).build(), + + HttpResponse.builder().statusCode(200).payload(payloadFromResource("/myaccount.xml")).build()); + + Account expected = Account.builder().orgId("8a8f6abc-2745-4d8a-9cbc-8dabe5a7d0e4").build(); + + assertEquals(client.getAccountClient().getMyAccount(), expected); + } + +} diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java new file mode 100644 index 0000000000..a2c2bf3ccb --- /dev/null +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/features/AccountClientLiveTest.java @@ -0,0 +1,38 @@ +/* + * 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.opsource.servers.features; + +import org.jclouds.opsource.servers.domain.Account; +import org.jclouds.opsource.servers.internal.BaseOpSourceServersClientLiveTest; +import org.testng.annotations.Test; + +/** + * Tests live behavior of {@link AccountClient}. + * + * @author Adrian Cole + */ +@Test(groups = { "live" }, singleThreaded = true, testName = "AccountClientLiveTest") +public class AccountClientLiveTest extends BaseOpSourceServersClientLiveTest { + + public void testGetMyAccount() { + Account account = context.getApi().getAccountClient().getMyAccount(); + assert account.getOrgId() != null; + } + +} diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/handlers/OpSourceServersErrorHandlerTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/handlers/OpSourceServersErrorHandlerTest.java new file mode 100644 index 0000000000..9022e802b9 --- /dev/null +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/handlers/OpSourceServersErrorHandlerTest.java @@ -0,0 +1,105 @@ +/** + * 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.opsource.servers.handlers; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.reportMatcher; +import static org.easymock.EasyMock.verify; + +import java.net.URI; + +import org.easymock.IArgumentMatcher; +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.io.Payloads; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.util.Strings2; +import org.testng.annotations.Test; + +import com.google.inject.Guice; + +/** + * + * @author Adrian Cole + */ +@Test(groups = { "unit" }) +public class OpSourceServersErrorHandlerTest { + + @Test + public void test401MakesAuthorizationException() { + assertCodeMakes("GET", URI.create("https://api.opsourcecloud.net/oec/0.9/foo"), 401, "", "Unauthorized", + AuthorizationException.class); + } + + @Test + public void test404MakesResourceNotFoundException() { + assertCodeMakes("GET", URI.create("https://api.opsourcecloud.net/oec/0.9/foo"), 404, "", "Not Found", + ResourceNotFoundException.class); + } + + private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, + Class expected) { + assertCodeMakes(method, uri, statusCode, message, "text/xml", content, expected); + } + + private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, + String content, Class expected) { + + OpSourceServersErrorHandler function = Guice.createInjector().getInstance(OpSourceServersErrorHandler.class); + + HttpCommand command = createMock(HttpCommand.class); + HttpRequest request = new HttpRequest(method, uri); + HttpResponse response = new HttpResponse(statusCode, message, Payloads.newInputStreamPayload(Strings2 + .toInputStream(content))); + response.getPayload().getContentMetadata().setContentType(contentType); + + expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); + command.setException(classEq(expected)); + + replay(command); + + function.handleError(command, response); + + verify(command); + } + + public static Exception classEq(final Class in) { + reportMatcher(new IArgumentMatcher() { + + @Override + public void appendTo(StringBuffer buffer) { + buffer.append("classEq("); + buffer.append(in); + buffer.append(")"); + } + + @Override + public boolean matches(Object arg) { + return arg.getClass() == in; + } + + }); + return null; + } + +} diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java new file mode 100644 index 0000000000..9aba439acb --- /dev/null +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java @@ -0,0 +1,64 @@ +/** + * 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.opsource.servers.internal; + +import java.util.Properties; + +import org.jclouds.compute.BaseVersionedServiceLiveTest; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.opsource.servers.OpSourceServersAsyncClient; +import org.jclouds.opsource.servers.OpSourceServersClient; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * Tests behavior of {@link OpSourceServersClient} and acts as parent for other + * client live tests. + * + * @author Adrian Cole + */ +@Test(groups = "live") +public abstract class BaseOpSourceServersClientLiveTest extends BaseVersionedServiceLiveTest { + + protected BaseOpSourceServersClientLiveTest() { + provider = "opsource-servers"; + } + + protected RestContext context; + + @BeforeClass(groups = { "live" }) + public void setupContext() { + setupCredentials(); + Properties overrides = setupProperties(); + + context = new RestContextFactory().createContext(provider, identity, credential, + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); + } + + protected void tearDown() { + if (context != null) + context.close(); + } +} diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java new file mode 100644 index 0000000000..c5720cd222 --- /dev/null +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java @@ -0,0 +1,37 @@ +/** + * 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.opsource.servers.internal; + +import org.jclouds.opsource.servers.OpSourceServersClient; +import org.jclouds.rest.BaseRestClientExpectTest; + +/** + * Base class for writing OpSourceServersClient Expect tests + * + * @author Adrian Cole + */ +public class BaseOpSourceServersRestClientExpectTest extends BaseRestClientExpectTest { + + public BaseOpSourceServersRestClientExpectTest() { + provider = "opsource-servers"; + identity = "user"; + credential = "password"; + } + +} diff --git a/labs/opsource-servers/src/test/resources/log4j.xml b/labs/opsource-servers/src/test/resources/log4j.xml new file mode 100644 index 0000000000..63810d3ca0 --- /dev/null +++ b/labs/opsource-servers/src/test/resources/log4j.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/labs/opsource-servers/src/test/resources/myaccount.xml b/labs/opsource-servers/src/test/resources/myaccount.xml new file mode 100644 index 0000000000..afc9b1107c --- /dev/null +++ b/labs/opsource-servers/src/test/resources/myaccount.xml @@ -0,0 +1,32 @@ + + + testuser + Test User + Test + User + test@example.com + 8a8f6abc-2745-4d8a-9cbc-8dabe5a7d0e4 + + + create image + + + reports + + + server + + + primary administrator + + + network + + + \ No newline at end of file diff --git a/labs/pom.xml b/labs/pom.xml index 62213128e1..cc9ecba707 100644 --- a/labs/pom.xml +++ b/labs/pom.xml @@ -36,5 +36,8 @@ virtualbox vcloud-director glesys + opsource-servers + elb + aws-elb diff --git a/labs/vcloud-director/pom.xml b/labs/vcloud-director/pom.xml index 0b4b80631c..29028bcc02 100644 --- a/labs/vcloud-director/pom.xml +++ b/labs/vcloud-director/pom.xml @@ -84,7 +84,7 @@ ch.qos.logback logback-classic - 0.9.29 + 1.0.0 test diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java index cf1c90c09d..1c0cfd16c9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java @@ -18,19 +18,24 @@ */ package org.jclouds.vcloud.director.v1_5; -import org.jclouds.ovf.Network; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; +import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; import com.google.inject.Provides; - /** * Provides asynchronous access to VCloudDirector via their REST API. * @@ -80,4 +85,17 @@ public interface VCloudDirectorAsyncClient { */ @Delegate CatalogAsyncClient getMediaClient(); + + /** + * @return asynchronous access to {@link Vdc} features + */ + @Delegate + VdcAsyncClient getVdcClient(); + + /** + * @return asynchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features + */ + @Delegate + VAppTemplateAsyncClient getVAppTemplateClient(); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java index 89c53a663b..0dade36531 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java @@ -21,16 +21,22 @@ package org.jclouds.vcloud.director.v1_5; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.ovf.Network; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; +import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MediaClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient; +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; +import org.jclouds.vcloud.director.v1_5.features.VdcClient; import com.google.inject.Provides; @@ -83,4 +89,17 @@ public interface VCloudDirectorClient { */ @Delegate MediaClient getMediaClient(); + + /** + * @return synchronous access to {@link Vdc} features + */ + @Delegate + VdcClient getVdcClient(); + + /* + * @return synchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features + */ + @Delegate + VAppTemplateClient getVAppTemplateClient(); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java index 3bd358e433..c42c0bcc8f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorConstants.java @@ -29,6 +29,10 @@ public class VCloudDirectorConstants { /** The XML namespace used by the clients. */ public static final String VCLOUD_1_5_NS = "http://www.vmware.com/vcloud/v1.5"; + public static final String VCLOUD_OVF_NS = "http://schemas.dmtf.org/ovf/envelope/1"; + + public static final String VCLOUD_CIM_NS = "http://schemas.dmtf.org/wbem/wscim/1/common"; + /** The property used to configure the timeout for task completion. */ public static final String PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud-director.timeout.task-complete"; @@ -51,7 +55,7 @@ public class VCloudDirectorConstants { /** TODO javadoc */ public static final String PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE = "jclouds.vcloud-director.xml.ns"; - + /** TODO javadoc */ public static final String PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA = "jclouds.vcloud-director.xml.schema"; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java index aca63b8e36..a2f87e8062 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java @@ -44,7 +44,7 @@ public class VCloudDirectorMediaType { public static final String METADATA_ENTRY = "*/*"; // No media type (?) - public static final String METADATA_VALUE = "application/vnd.vmware.vcloud.metadata.value+xml";; + public static final String METADATA_VALUE = "application/vnd.vmware.vcloud.metadata.value+xml"; public static final String ORG = "application/vnd.vmware.vcloud.org+xml"; @@ -71,18 +71,64 @@ public class VCloudDirectorMediaType { public static final String OWNER = "application/vnd.vmware.vcloud.owner+xml"; public static final String VDC = "application/vnd.vmware.vcloud.vdc+xml"; - - public static final String ADMIN_USER = "application/vnd.vmware.admin.user+xml"; + public static final String ADMIN_USER = "application/vnd.vmware.admin.user+xml"; + + public static final String V_APP = "application/vnd.vmware.vcloud.vApp+xml"; + + public static final String V_APP_TEMPLATE = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String CAPTURE_VAPP_PARAMS = + "application/vnd.vmware.vcloud.captureVAppParams+xml"; + + public static final String CLONE_MEDIA_PARAMS = + "application/vnd.vmware.vcloud.cloneMediaParams+xml"; + + public static final String CLONE_V_APP_PARAMS = + "application/vnd.vmware.vcloud.cloneVAppParams+xml"; + + public static final String CLONE_V_APP_TEMPLATE_PARAMS = + "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml"; + + public static final String COMPOSE_VAPP_PARAMS = + "application/vnd.vmware.vcloud.composeVAppParams+xml"; + + public static final String INSTANTIATE_VAPP_TEMPLATE_PARAMS = + "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml"; + + public static final String UPLOAD_VAPP_TEMPLATE_PARAMS = + "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml"; + public static final String QUERY_RESULT_RECORDS = "application/vnd.vmware.vcloud.query.records+xml"; public static final String QUERY_RESULT_REFERENCES = "application/vnd.vmware.vcloud.query.references+xml"; - public static final String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml"; - + public static final String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml"; + public static final String CONTROL_ACCESS = "application/vnd.vmware.vcloud.controlAccess+xml"; + public static final String VAPP_TEMPLATE = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String CUSTOMIZATION_SECTION = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String GUEST_CUSTOMIZATION_SECTION = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String NETWORK_SECTION = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String NETWORK_CONFIG_SECTION = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String NETWORK_CONNECTION_SECTION = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String PRODUCT_SECTION_LIST = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + + public static final String RELOCATE_TEMPLATE = "application/vnd.vmware.vcloud.relocateTemplate+xml"; + + public static final String LEASE_SETTINGS_SECTION = "application/vnd.vmware.vcloud.leastSettingsSection+xml"; + + public static final String ENVELOPE = "application/vnd.???"; + /** + * * All acceptable media types. * * This list must be updated whenever a new media type constant is added. @@ -91,8 +137,14 @@ public class VCloudDirectorMediaType { SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, METADATA_VALUE, ORG, TASKS_LIST, TASK, NETWORK, ORG_NETWORK, CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY, - MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS, - QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, - CONTROL_ACCESS + MEDIA, OWNER, VDC, ADMIN_USER, V_APP, V_APP_TEMPLATE, + CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_TEMPLATE_PARAMS, + COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, + UPLOAD_VAPP_TEMPLATE_PARAMS, + QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, + VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION, + CONTROL_ACCESS + , + LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE ); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 6dd7be580f..3aa3d05ea6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -42,18 +42,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.annotations.Login; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; -import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.CatalogClient; -import org.jclouds.vcloud.director.v1_5.features.MediaAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MediaClient; -import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.NetworkClient; -import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.OrgClient; -import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.QueryClient; -import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.TaskClient; +import org.jclouds.vcloud.director.v1_5.features.*; import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword; import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose; import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler; @@ -87,6 +76,8 @@ public class VCloudDirectorRestClientModule extends RestClientModule + *

+ *

Java class for AvailableNetworks complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="AvailableNetworks">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Network" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "AvailableNetworks", propOrder = { + "networks" +}) +public class AvailableNetworks { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromAvailableNetworks(this); + } + + public static class Builder { + private Set networks = Sets.newLinkedHashSet(); + + /** + * @see AvailableNetworks#getNetworks() + */ + public Builder networks(Collection networks) { + this.networks = Sets.newLinkedHashSet(checkNotNull(networks, "networks")); + return this; + } + + /** + * @see AvailableNetworks#getNetworks() + */ + public Builder network(Reference network) { + networks.add(checkNotNull(network, "network")); + return this; + } + + public AvailableNetworks build() { + AvailableNetworks availableNetworks = new AvailableNetworks(networks); + return availableNetworks; + } + + + public Builder fromAvailableNetworks(AvailableNetworks in) { + return networks(in.getNetworks()); + } + } + + @XmlElement(name = "Network") + protected Set networks = Sets.newLinkedHashSet(); + + private AvailableNetworks(Set networks) { + this.networks = networks; + } + + private AvailableNetworks() { + // For JAXB + } + + /** + * Gets the value of the network property. + */ + public Set getNetworks() { + return this.networks; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + AvailableNetworks that = AvailableNetworks.class.cast(o); + return equal(networks, that.networks); + } + + @Override + public int hashCode() { + return Objects.hashCode(networks); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("network", networks).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java new file mode 100644 index 0000000000..b6b21fa2e0 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java @@ -0,0 +1,129 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Collection of supported hardware capabilities. + *

+ *

+ *

Java class for Capabilities complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="Capabilities">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="SupportedHardwareVersions" type="{http://www.vmware.com/vcloud/v1.5}SupportedHardwareVersionsType" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "Capabilities", propOrder = { + "supportedHardwareVersions" +}) +public class Capabilities { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCapabilities(this); + } + + public static class Builder { + + private SupportedHardwareVersions supportedHardwareVersions; + + /** + * @see Capabilities#getSupportedHardwareVersions() + */ + public Builder supportedHardwareVersions(SupportedHardwareVersions supportedHardwareVersions) { + this.supportedHardwareVersions = supportedHardwareVersions; + return this; + } + + + public Capabilities build() { + return new Capabilities(supportedHardwareVersions); + } + + + public Builder fromCapabilities(Capabilities in) { + return supportedHardwareVersions(in.getSupportedHardwareVersions()); + } + } + + private Capabilities(SupportedHardwareVersions supportedHardwareVersions) { + this.supportedHardwareVersions = supportedHardwareVersions; + } + + private Capabilities() { + // For JAXB + } + + + @XmlElement(name = "SupportedHardwareVersions") + protected SupportedHardwareVersions supportedHardwareVersions; + + /** + * Gets the value of the supportedHardwareVersions property. + * + * @return possible object is + * {@link SupportedHardwareVersions } + */ + public SupportedHardwareVersions getSupportedHardwareVersions() { + return supportedHardwareVersions; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Capabilities that = Capabilities.class.cast(o); + return equal(supportedHardwareVersions, that.supportedHardwareVersions); + } + + @Override + public int hashCode() { + return Objects.hashCode(supportedHardwareVersions); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("supportedHardwareVersions", supportedHardwareVersions).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java new file mode 100644 index 0000000000..887410d52e --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java @@ -0,0 +1,186 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents a capacity of a given resource. + *

+ *

+ *

Java class for Capacity complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="Capacity">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Units" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Allocated" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/>
+ *         <element name="Limit" type="{http://www.w3.org/2001/XMLSchema}Long"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "Capacity", propOrder = { + "units", + "allocated", + "limit" +}) +@XmlSeeAlso({ + CapacityWithUsage.class +}) +public class CapacityType> { + + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCapacityType(this); + } + + public static class Builder> { + + protected String units; + protected Long allocated; + protected Long limit; + + /** + * @see CapacityType#getUnits() + */ + public Builder units(String units) { + this.units = units; + return this; + } + + /** + * @see CapacityType#getAllocated() + */ + public Builder allocated(Long allocated) { + this.allocated = allocated; + return this; + } + + /** + * @see CapacityType#getLimit() + */ + public Builder limit(Long limit) { + this.limit = limit; + return this; + } + + + public CapacityType build() { + return new CapacityType(units, allocated, limit); + } + + + public Builder fromCapacityType(CapacityType in) { + return units(in.getUnits()) + .allocated(in.getAllocated()) + .limit(in.getLimit()); + } + } + + protected CapacityType(String units, Long allocated, Long limit) { + this.units = units; + this.allocated = allocated; + this.limit = limit; + } + + protected CapacityType() { + // For JAXB and builder use + } + + @XmlElement(name = "Units", required = true) + protected String units; + @XmlElement(name = "Allocated") + protected Long allocated; + @XmlElement(name = "Limit") + protected Long limit; + + /** + * Gets the value of the units property. + * + * @return possible object is + * {@link String } + */ + public String getUnits() { + return units; + } + + /** + * Gets the value of the allocated property. + * + * @return possible object is + * {@link Long } + */ + public Long getAllocated() { + return allocated; + } + + /** + * Gets the value of the limit property. + */ + public Long getLimit() { + return limit; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CapacityType that = CapacityType.class.cast(o); + return equal(units, that.units) && + equal(allocated, that.allocated) && + equal(limit, that.limit); + } + + @Override + public int hashCode() { + return Objects.hashCode(units, + allocated, + limit); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("units", units) + .add("allocated", allocated) + .add("limit", limit).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java new file mode 100644 index 0000000000..2c4ad4dd91 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java @@ -0,0 +1,190 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents a capacity and usage of a given resource. + *

+ *

+ *

Java class for CapacityWithUsage complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="CapacityWithUsage">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}CapacityType">
+ *       <sequence>
+ *         <element name="Used" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/>
+ *         <element name="Overhead" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "CapacityWithUsage", propOrder = { + "used", + "overhead" +}) +public class CapacityWithUsage extends CapacityType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCapacityWithUsage(this); + } + + public static class Builder extends CapacityType.Builder { + + private Long used; + private Long overhead; + + /** + * @see CapacityWithUsage#getUsed() + */ + public Builder used(Long used) { + this.used = used; + return this; + } + + /** + * @see CapacityWithUsage#getOverhead() + */ + public Builder overhead(Long overhead) { + this.overhead = overhead; + return this; + } + + + public CapacityWithUsage build() { + return new CapacityWithUsage(units, allocated, limit, used, overhead); + } + + /** + * @see CapacityType#getUnits() + */ + public Builder units(String units) { + this.units = units; + return this; + } + + /** + * @see CapacityType#getAllocated() + */ + public Builder allocated(Long allocated) { + this.allocated = allocated; + return this; + } + + /** + * @see CapacityType#getLimit() + */ + public Builder limit(Long limit) { + this.limit = limit; + return this; + } + + + @Override + public Builder fromCapacityType(CapacityType in) { + return Builder.class.cast(super.fromCapacityType(in)); + } + + public Builder fromCapacityWithUsage(CapacityWithUsage in) { + return fromCapacityType(in) + .used(in.getUsed()) + .overhead(in.getOverhead()); + } + } + + private CapacityWithUsage(String units, Long allocated, Long limit, Long used, Long overhead) { + super(units, allocated, limit); + this.used = used; + this.overhead = overhead; + } + + private CapacityWithUsage() { + // For JAXB and builder use + } + + @XmlElement(name = "Used") + protected Long used; + @XmlElement(name = "Overhead") + protected Long overhead; + + /** + * Gets the value of the used property. + * + * @return possible object is + * {@link Long } + */ + public Long getUsed() { + return used; + } + + /** + * Gets the value of the overhead property. + * + * @return possible object is + * {@link Long } + */ + public Long getOverhead() { + return overhead; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CapacityWithUsage that = CapacityWithUsage.class.cast(o); + return equal(used, that.used) && + equal(overhead, that.overhead); + } + + @Override + public int hashCode() { + return Objects.hashCode(used, + overhead); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("used", used) + .add("overhead", overhead).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java new file mode 100644 index 0000000000..32b9c72159 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -0,0 +1,218 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.ovf.DeploymentOptionSection; +import org.jclouds.ovf.DiskSection; +import org.jclouds.ovf.OperatingSystemSection; +import org.jclouds.ovf.ProductSection; +import org.jclouds.ovf.Section; +import org.jclouds.ovf.VirtualHardwareSection; +import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents the parameters for capturing a vApp to a vApp template. + *

+ *

+ *

Java class for CaptureVAppParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="CaptureVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element ref="{http://schemas.dmtf.org/ovf/envelope/1}Section" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "CaptureVAppParams", propOrder = { + "source", + "section" +}) +public class CaptureVAppParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCaptureVAppParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private Reference source; + private Set> sections = ImmutableSet.of(); + + /** + * @see CaptureVAppParams#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see CaptureVAppParams#getSections() + */ + public Builder sections(Set> sections) { + this.sections = checkNotNull(sections, "sections"); + return this; + } + + + public CaptureVAppParams build() { + return new CaptureVAppParams(description, name, source, sections); + } + + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + + public Builder fromCaptureVAppParams(CaptureVAppParams in) { + return fromParamsType(in) + .source(in.getSource()) + .sections(in.getSections()); + } + } + + private CaptureVAppParams(String description, String name, Reference source, Set> sections) { + super(description, name); + this.source = source; + this.sections = sections; + } + + private CaptureVAppParams() { + // For JAXB and builder use + } + + private CaptureVAppParams(Set> sections) { + this.sections = ImmutableSet.copyOf(sections); + } + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElementRef + protected Set> sections = Sets.newLinkedHashSet(); + + /** + * Gets the value of the source property. + * + * @return possible object is + * {@link Reference } + */ + public Reference getSource() { + return source; + } + + /** + * An ovf:Section to configure the captured vAppTemplate. + * Gets the value of the section property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the section property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+    *    getSection().add(newItem);
+    * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link Section> }{@code >} + * {@link JAXBElement }{@code <}{@link VirtualHardwareSection > }{@code >} + * {@link JAXBElement }{@code <}{@link LeaseSettingsSection> }{@code >} + * {@link JAXBElement }{@code <}{@link EulaSection> }{@code >} + * {@link JAXBElement }{@code <}{@link RuntimeInfoSection> }{@code >} + * {@link JAXBElement }{@code <}{@link AnnotationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link DeploymentOptionSection > }{@code >} + * {@link JAXBElement }{@code <}{@link StartupSection> }{@code >} + * {@link JAXBElement }{@code <}{@link ResourceAllocationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkConnectionSection> }{@code >} + * {@link JAXBElement }{@code <}{@link CustomizationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link ProductSection > }{@code >} + * {@link JAXBElement }{@code <}{@link GuestCustomizationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link OperatingSystemSection > }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkConfigSection> }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkSection > }{@code >} + * {@link JAXBElement }{@code <}{@link DiskSection > }{@code >} + * {@link JAXBElement }{@code <}{@link InstallSection> }{@code >} + */ + public Set> getSections() { + return this.sections; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CaptureVAppParams that = CaptureVAppParams.class.cast(o); + return equal(source, that.source) && + equal(sections, that.sections); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + sections); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("sections", sections).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java index c7d0d92773..4495669a1d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Catalog.java @@ -19,11 +19,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -33,14 +31,14 @@ import com.google.common.collect.Sets; /** * Container for references to VappTemplate and Media objects. - * + *

*

  * <complexType name="CatalogType" />
  * 
* * @author grkvlt@apache.org */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Catalog") +@XmlRootElement(name = "Catalog") public class Catalog extends EntityType { public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG; @@ -95,16 +93,7 @@ public class Catalog extends EntityType { @Override public Catalog build() { - Catalog catalog = new Catalog(href, name); - catalog.setOwner(owner); - catalog.setCatalogItems(catalogItems); - catalog.setIsPublished(isPublished); - catalog.setDescription(description); - catalog.setId(id); - catalog.setType(type); - catalog.setLinks(links); - catalog.setTasksInProgress(tasksInProgress); - return catalog; + return new Catalog(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, isPublished); } /** @@ -162,7 +151,7 @@ public class Catalog extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -171,7 +160,7 @@ public class Catalog extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -189,12 +178,16 @@ public class Catalog extends EntityType { } } - private Catalog() { - // For JAXB and builder use + public Catalog(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, + String name, Entity owner, CatalogItems catalogItems, Boolean published) { + super(href, type, links, description, tasksInProgress, id, name); + this.owner = owner; + this.catalogItems = catalogItems; + this.isPublished = published; } - private Catalog(URI href, String name) { - super(href, name); + private Catalog() { + // For JAXB and builder use } @XmlElement(name = "Owner") @@ -211,10 +204,6 @@ public class Catalog extends EntityType { return owner; } - public void setOwner(Entity value) { - this.owner = value; - } - /** * Gets the value of the catalogItems property. */ @@ -222,10 +211,6 @@ public class Catalog extends EntityType { return catalogItems; } - public void setCatalogItems(CatalogItems value) { - this.catalogItems = value; - } - /** * Gets the value of the isPublished property. */ @@ -233,7 +218,4 @@ public class Catalog extends EntityType { return isPublished; } - public void setIsPublished(Boolean value) { - this.isPublished = value; - } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java index 4d42e39cc8..7720193d3b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java @@ -19,31 +19,27 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; -import java.util.List; +import java.util.Collections; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; /** - * * Contains a reference to a VappTemplate or Media object and related metadata. - * + *

*

  * <complexType name="CatalogItemType" />
  * 
* * @author grkvlt@apache.org */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogItem") +@XmlRootElement(name = "CatalogItem") public class CatalogItem extends EntityType { public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEM; @@ -61,7 +57,7 @@ public class CatalogItem extends EntityType { public static class Builder extends EntityType.Builder { private Reference entity; - private List properties = Lists.newArrayList(); + private Set properties = Sets.newLinkedHashSet(); /** * @see CatalogItem#getEntity() @@ -74,8 +70,8 @@ public class CatalogItem extends EntityType { /** * @see CatalogItem#getProperties() */ - public Builder properties(List properties) { - this.properties = Lists.newArrayList(checkNotNull(properties, "properties")); + public Builder properties(Set properties) { + this.properties = Sets.newLinkedHashSet(checkNotNull(properties, "properties")); return this; } @@ -89,14 +85,7 @@ public class CatalogItem extends EntityType { @Override public CatalogItem build() { - CatalogItem catalog = new CatalogItem(href, name, entity); - catalog.setProperties(properties); - catalog.setDescription(description); - catalog.setId(id); - catalog.setType(type); - catalog.setLinks(links); - catalog.setTasksInProgress(tasksInProgress); - return catalog; + return new CatalogItem(href, type, links, description, tasksInProgress, id, name, entity, properties); } /** @@ -154,7 +143,7 @@ public class CatalogItem extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -163,7 +152,7 @@ public class CatalogItem extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -181,20 +170,20 @@ public class CatalogItem extends EntityType { } } - private CatalogItem() { - // For JAXB and builder use + private CatalogItem(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, String name, Reference entity, Set properties) { + super(href, type, links, description, tasksInProgress, id, name); + this.entity = entity; + this.properties = properties; } - private CatalogItem(URI href, String name, Reference entity) { - super(href, name); - this.entity = entity; - this.setProperties(properties); + private CatalogItem() { + // For JAXB and builder use } @XmlElement(name = "Entity", required = true) private Reference entity; @XmlElement(name = "Property") - private List properties = Lists.newArrayList(); + private Set properties = Sets.newLinkedHashSet(); /** * A reference to a VappTemplate or Media object. @@ -205,18 +194,10 @@ public class CatalogItem extends EntityType { /** * User-specified key/value pair. - * + *

* This element has been superseded by the {@link Metadata} element, which is the preferred way to specify key/value pairs for objects. */ - public List getProperties() { - return this.properties; - } - - public void setProperties(List properties) { - this.properties = Lists.newArrayList(checkNotNull(properties, "properties")); - } - - public void addProperty(Property property) { - this.properties.add(checkNotNull(property, "property")); + public Set getProperties() { + return Collections.unmodifiableSet(this.properties); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java index 96ff754e8c..01037a1dfa 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java @@ -19,31 +19,27 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.util.Collection; -import java.util.List; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; +import java.util.Collections; +import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import com.google.common.collect.Lists; +import com.google.common.collect.Sets; /** * Represents a list of catalog item references. - * + *

*

  * <complexType name="CatalogItemsType" />
  * 
* * @author grkvlt@apache.org */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogItems") +@XmlRootElement(name = "CatalogItems") public class CatalogItems { public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEMS; @@ -58,13 +54,13 @@ public class CatalogItems { public static class Builder { - private List catalogItems = Lists.newArrayList(); + private Set catalogItems = Sets.newLinkedHashSet(); /** * @see CatalogItems#getCatalogItems() */ - public Builder items(List catalogItems) { - this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems")); + public Builder items(Collection catalogItems) { + this.catalogItems = Sets.newLinkedHashSet(checkNotNull(catalogItems, "catalogItems")); return this; } @@ -90,24 +86,16 @@ public class CatalogItems { } private CatalogItems(Collection tasks) { - this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems")); + this.catalogItems = catalogItems; } @XmlElement(name = "CatalogItem") - private List catalogItems = Lists.newArrayList(); + private Set catalogItems = Sets.newLinkedHashSet(); /** * Gets the value of the catalogItems property. */ - public List getCatalogItems() { - return this.catalogItems; - } - - public void setCatalogItems(List catalogItems) { - this.catalogItems = Lists.newArrayList(checkNotNull(catalogItems, "catalogItems")); - } - - public void addCatalogItem(Reference catalogItem) { - this.catalogItems.add(checkNotNull(catalogItem, "catalogItem")); + public Set getCatalogItems() { + return Collections.unmodifiableSet(this.catalogItems); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java index 1bbc50dc03..91179152d6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java @@ -1,12 +1,9 @@ package org.jclouds.vcloud.director.v1_5.domain; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; - import java.net.URI; - import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogReference") +@XmlRootElement(name = "CatalogReference") public class CatalogReference extends ReferenceType { @SuppressWarnings("unchecked") @@ -23,11 +20,7 @@ public class CatalogReference extends ReferenceType { @Override public CatalogReference build() { - CatalogReference reference = new CatalogReference(href); - reference.setId(id); - reference.setName(name); - reference.setType(type); - return reference; + return new CatalogReference(href, id, name, type); } /** @@ -76,8 +69,8 @@ public class CatalogReference extends ReferenceType { } } - protected CatalogReference(URI href) { - super(href); + public CatalogReference(URI href, String id, String name, String type) { + super(href, id, name, type); } protected CatalogReference() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java index 52e0b471e7..bd4ec005ed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java @@ -19,31 +19,27 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.util.Collection; -import java.util.List; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; +import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** * Container for ReferenceType elements that reference catalogs. - * + *

*

  * <complexType name="CatalogsListType" />
  * 
* * @author grkvlt@apache.org */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogsList") +@XmlRootElement(name = "CatalogsList") public class CatalogsList { public static final String MEDIA_TYPE = VCloudDirectorMediaType.CATALOG_ITEMS; @@ -58,13 +54,13 @@ public class CatalogsList { public static class Builder { - private List catalogReferences = Lists.newArrayList(); + private Set catalogReferences = Sets.newLinkedHashSet(); /** * @see CatalogsList#getCatalogItems() */ - public Builder catalogs(List catalogReferences) { - this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences")); + public Builder catalogs(Collection catalogReferences) { + this.catalogReferences = Sets.newLinkedHashSet(checkNotNull(catalogReferences, "catalogReferences")); return this; } @@ -81,7 +77,7 @@ public class CatalogsList { } public Builder fromCatalogsList(CatalogsList in) { - return catalogs(in.getCatalogsList()); + return catalogs(in.getCatalogItems()); } } @@ -89,25 +85,18 @@ public class CatalogsList { // For JAXB and builder use } - private CatalogsList(Collection tasks) { - this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences")); + private CatalogsList(Set tasks) { + this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences")); } @XmlElement(name = "CatalogReference") - private List catalogReferences = Lists.newArrayList(); + private Set catalogReferences = Sets.newLinkedHashSet(); /** * Gets the value of the catalogReferences property. */ - public List getCatalogsList() { + public Set getCatalogItems() { return this.catalogReferences; } - public void setCatalogsList(List catalogReferences) { - this.catalogReferences = Lists.newArrayList(checkNotNull(catalogReferences, "catalogReferences")); - } - - public void addCatalog(Reference catalog) { - this.catalogReferences.add(checkNotNull(catalog, "catalog")); - } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java new file mode 100644 index 0000000000..f55c034512 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java @@ -0,0 +1,167 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents parameters for copying a media resource and optionally + * deleting the source. + *

+ *

+ *

Java class for CloneMediaParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="CloneMediaParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="IsSourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "CloneMediaParams", propOrder = { + "source", + "isSourceDelete" +}) +public class CloneMediaParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCloneMediaParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private Reference source; + private Boolean isSourceDelete; + + /** + * @see CloneMediaParams#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see CloneMediaParams#isSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + this.isSourceDelete = isSourceDelete; + return this; + } + + public CloneMediaParams build() { + return new CloneMediaParams(description, name, source, isSourceDelete); + } + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + + public Builder fromCloneMediaParams(CloneMediaParams in) { + return fromParamsType(in) + .source(in.getSource()) + .isSourceDelete(in.isSourceDelete()); + } + } + + private CloneMediaParams(String description, String name, Reference source, Boolean sourceDelete) { + super(description, name); + this.source = source; + isSourceDelete = sourceDelete; + } + + private CloneMediaParams() { + // For JAXB and builder use + } + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "IsSourceDelete") + protected Boolean isSourceDelete; + + /** + * Gets the value of the source property. + * + * @return possible object is + * {@link Reference } + */ + public Reference getSource() { + return source; + } + + /** + * Gets the value of the isSourceDelete property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isSourceDelete() { + return isSourceDelete; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CloneMediaParams that = CloneMediaParams.class.cast(o); + return equal(source, that.source) && + equal(isSourceDelete, that.isSourceDelete); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + isSourceDelete); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("isSourceDelete", isSourceDelete).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java new file mode 100644 index 0000000000..8ccfc0575a --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java @@ -0,0 +1,173 @@ +/** + * 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.domain; + +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents parameters for copying a vApp and optionally deleting the source. + *

+ *

+ *

Java class for CloneVAppParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="CloneVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}InstantiateVAppParamsType">
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "CloneVAppParams") +public class CloneVAppParams + extends InstantiateVAppParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCloneVAppParams(this); + } + + public static class Builder extends InstantiateVAppParamsType.Builder { + + + public CloneVAppParams build() { + CloneVAppParams cloneVAppParams = new CloneVAppParams(); + return cloneVAppParams; + } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#getDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#getPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } + + /** + * @see InstantiateVAppParamsType#getSource() + */ + public Builder source(Reference source) { + super.source(source); + return this; + } + + /** + * @see InstantiateVAppParamsType#getIsSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + super.isSourceDelete(isSourceDelete); + return this; + } + + /** + * @see InstantiateVAppParamsType#getLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + super.linkedClone(linkedClone); + return this; + } + + @Override + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + return Builder.class.cast(super.fromInstantiateVAppParamsType(in)); + } + + public Builder fromCloneVAppParams(CloneVAppParams in) { + return fromInstantiateVAppParamsType(in); + } + } + + private CloneVAppParams() { + // For JAXB and builder use + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CloneVAppParams that = CloneVAppParams.class.cast(o); + return super.equals(that); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(""); + } + + @Override + public String toString() { + return Objects.toStringHelper("").toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java new file mode 100644 index 0000000000..14a61345ab --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java @@ -0,0 +1,167 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents parameters for copying a vApp template and optionally + * deleting the source. + *

+ *

+ *

Java class for CloneVAppTemplateParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="CloneVAppTemplateParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="IsSourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "CloneVAppTemplateParams", propOrder = { + "source", + "isSourceDelete" +}) +public class CloneVAppTemplateParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCloneVAppTemplateParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private Reference source; + private Boolean isSourceDelete; + + /** + * @see CloneVAppTemplateParams#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see CloneVAppTemplateParams#isSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + this.isSourceDelete = isSourceDelete; + return this; + } + + public CloneVAppTemplateParams build() { + return new CloneVAppTemplateParams(description, name, source, isSourceDelete); + } + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + + public Builder fromCloneVAppTemplateParams(CloneVAppTemplateParams in) { + return fromParamsType(in) + .source(in.getSource()) + .isSourceDelete(in.isSourceDelete()); + } + } + + public CloneVAppTemplateParams(String description, String name, Reference source, Boolean sourceDelete) { + super(description, name); + this.source = source; + isSourceDelete = sourceDelete; + } + + private CloneVAppTemplateParams() { + // For JAXB and builder use + } + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "IsSourceDelete") + protected Boolean isSourceDelete; + + /** + * Gets the value of the source property. + * + * @return possible object is + * {@link Reference } + */ + public Reference getSource() { + return source; + } + + /** + * Gets the value of the isSourceDelete property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isSourceDelete() { + return isSourceDelete; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CloneVAppTemplateParams that = CloneVAppTemplateParams.class.cast(o); + return equal(source, that.source) && + equal(isSourceDelete, that.isSourceDelete); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + isSourceDelete); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("isSourceDelete", isSourceDelete).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java new file mode 100644 index 0000000000..e9ebb23274 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java @@ -0,0 +1,224 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents vApp composition parameters. + *

+ *

+ *

Java class for ComposeVAppParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="ComposeVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VAppCreationParamsType">
+ *       <sequence>
+ *         <element name="SourcedItem" type="{http://www.vmware.com/vcloud/v1.5}SourcedCompositionItemParamType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{http://www.vmware.com/vcloud/v1.5}AllEULAsAccepted" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="linkedClone" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "ComposeVAppParams", propOrder = { + "sourcedItem", + "allEULAsAccepted" +}) +@XmlSeeAlso({ +// RecomposeVAppParamsType.class +}) +public class ComposeVAppParams + extends VAppCreationParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromComposeVAppParams(this); + } + + public static class Builder extends VAppCreationParamsType.Builder { + + private Set sourcedItem = Sets.newLinkedHashSet(); + private Boolean allEULAsAccepted; + private Boolean linkedClone; + + /** + * @see ComposeVAppParams#getSourcedItem() + */ + public Builder sourcedItem(Set sourcedItem) { + this.sourcedItem = checkNotNull(sourcedItem, "sourcedItem"); + return this; + } + + /** + * @see ComposeVAppParams#isAllEULAsAccepted() + */ + public Builder allEULAsAccepted(Boolean allEULAsAccepted) { + this.allEULAsAccepted = allEULAsAccepted; + return this; + } + + /** + * @see ComposeVAppParams#isLinkedClone() () + */ + public Builder linkedClone(Boolean linkedClone) { + this.linkedClone = linkedClone; + return this; + } + + + public ComposeVAppParams build() { + return new ComposeVAppParams(description, name, vAppParent, instantiationParams, deploy, powerOn, + sourcedItem, allEULAsAccepted, linkedClone); + } + + + @Override + public Builder fromVAppCreationParamsType(VAppCreationParamsType in) { + return Builder.class.cast(super.fromVAppCreationParamsType(in)); + } + + public Builder fromComposeVAppParams(ComposeVAppParams in) { + return fromVAppCreationParamsType(in) + .sourcedItem(in.getSourcedItem()) + .allEULAsAccepted(in.isAllEULAsAccepted()) + .linkedClone(in.isLinkedClone()); + } + } + + public ComposeVAppParams(String description, String name, Reference vAppParent, InstantiationParams instantiationParams, + Boolean deploy, Boolean powerOn, Set sourcedItem, Boolean allEULAsAccepted, Boolean linkedClone) { + super(description, name, vAppParent, instantiationParams, deploy, powerOn); + this.sourcedItem = ImmutableSet.copyOf(sourcedItem); + this.allEULAsAccepted = allEULAsAccepted; + this.linkedClone = linkedClone; + } + + private ComposeVAppParams() { + // For JAXB and builder use + } + + + @XmlElement(name = "SourcedItem") + protected Set sourcedItem = Sets.newLinkedHashSet(); + @XmlElement(name = "AllEULAsAccepted") + protected Boolean allEULAsAccepted; + @XmlAttribute + protected Boolean linkedClone; + + /** + * Gets the value of the sourcedItem property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the sourcedItem property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+    *    getSourcedItem().add(newItem);
+    * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link SourcedCompositionItemParam } + */ + public Set getSourcedItem() { + return this.sourcedItem; + } + + /** + * Used to confirm acceptance of all EULAs in a + * vApp template. Instantiation fails if this + * element is missing, empty, or set to false + * and one or more EulaSection elements are + * present. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isAllEULAsAccepted() { + return allEULAsAccepted; + } + + /** + * Gets the value of the linkedClone property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isLinkedClone() { + return linkedClone; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ComposeVAppParams that = ComposeVAppParams.class.cast(o); + return equal(sourcedItem, that.sourcedItem) && + equal(allEULAsAccepted, that.allEULAsAccepted) && + equal(linkedClone, that.linkedClone); + } + + @Override + public int hashCode() { + return Objects.hashCode(sourcedItem, + allEULAsAccepted, + linkedClone); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("sourcedItem", sourcedItem) + .add("allEULAsAccepted", allEULAsAccepted) + .add("linkedClone", linkedClone).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java new file mode 100644 index 0000000000..5d0556740c --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java @@ -0,0 +1,155 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents a compute capacity with units. + *

+ *

+ *

Java class for ComputeCapacity complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="ComputeCapacity">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Cpu" type="{http://www.vmware.com/vcloud/v1.5}CapacityWithUsageType"/>
+ *         <element name="Memory" type="{http://www.vmware.com/vcloud/v1.5}CapacityWithUsageType"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "ComputeCapacity", propOrder = { + "cpu", + "memory" +}) +public class ComputeCapacity { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromComputeCapacity(this); + } + + public static class Builder { + + private CapacityWithUsage cpu; + private CapacityWithUsage memory; + + /** + * @see ComputeCapacity#getCpu() + */ + public Builder cpu(CapacityWithUsage cpu) { + this.cpu = cpu; + return this; + } + + /** + * @see ComputeCapacity#getMemory() + */ + public Builder memory(CapacityWithUsage memory) { + this.memory = memory; + return this; + } + + public ComputeCapacity build() { + return new ComputeCapacity(cpu, memory); + } + + public Builder fromComputeCapacity(ComputeCapacity in) { + return cpu(in.getCpu()) + .memory(in.getMemory()); + } + } + + private ComputeCapacity(CapacityWithUsage cpu, CapacityWithUsage memory) { + this.cpu = cpu; + this.memory = memory; + } + + private ComputeCapacity() { + // For JAXB and builder use + } + + + @XmlElement(name = "Cpu", required = true) + protected CapacityWithUsage cpu; + @XmlElement(name = "Memory", required = true) + protected CapacityWithUsage memory; + + /** + * Gets the value of the cpu property. + * + * @return possible object is + * {@link CapacityWithUsage } + */ + public CapacityWithUsage getCpu() { + return cpu; + } + + /** + * Gets the value of the memory property. + * + * @return possible object is + * {@link CapacityWithUsage } + */ + public CapacityWithUsage getMemory() { + return memory; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ComputeCapacity that = ComputeCapacity.class.cast(o); + return equal(cpu, that.cpu) && + equal(memory, that.memory); + } + + @Override + public int hashCode() { + return Objects.hashCode(cpu, + memory); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("cpu", cpu) + .add("memory", memory).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java new file mode 100644 index 0000000000..6e0b618691 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java @@ -0,0 +1,246 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents a vApp template customization settings section. + *

+ *

+ *

Java class for CustomizationSection complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="CustomizationSection">
+ *   <complexContent>
+ *     <extension base="{http://schemas.dmtf.org/ovf/envelope/1}Section_Type">
+ *       <sequence>
+ *         <element name="CustomizeOnInstantiate" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="Link" type="{http://www.vmware.com/vcloud/v1.5}LinkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlRootElement(name = "CustomizationSection") +@XmlType(propOrder = { + "customizeOnInstantiate", + "links" +}) +public class CustomizationSection extends SectionType { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCustomizationSection(this); + } + + public static class Builder extends SectionType.Builder { + private boolean customizeOnInstantiate; + private Set links = Sets.newLinkedHashSet(); + private URI href; + private String type; + + /** + * @see CustomizationSection#isCustomizeOnInstantiate() + */ + public Builder customizeOnInstantiate(boolean customizeOnInstantiate) { + this.customizeOnInstantiate = customizeOnInstantiate; + return this; + } + + /** + * @see CustomizationSection#getLinks() + */ + public Builder links(Set links) { + this.links = checkNotNull(links, "links"); + return this; + } + + /** + * @see CustomizationSection#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see CustomizationSection#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + + public CustomizationSection build() { + return new CustomizationSection(info, required, customizeOnInstantiate, links, href, type); + } + + public Builder fromCustomizationSection(CustomizationSection in) { + return fromSection(in) + .customizeOnInstantiate(in.isCustomizeOnInstantiate()) + .links(in.getLinks()) + .href(in.getHref()) + .type(in.getType()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromSection(SectionType in) { + return Builder.class.cast(super.fromSection(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder info(String info) { + return Builder.class.cast(super.info(info)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder required(Boolean required) { + return Builder.class.cast(super.required(required)); + } + } + + private CustomizationSection(@Nullable String info, @Nullable Boolean required, boolean customizeOnInstantiate, Set links, + URI href, String type) { + super(info, required); + this.customizeOnInstantiate = customizeOnInstantiate; + this.links = ImmutableSet.copyOf(links); + this.href = href; + this.type = type; + } + + private CustomizationSection() { + // For JAXB + } + + @XmlElement(name = "CustomizeOnInstantiate") + protected boolean customizeOnInstantiate; + @XmlElement(name = "Link") + protected Set links = Sets.newLinkedHashSet(); + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected URI href; + @XmlAttribute + protected String type; + + /** + * Gets the value of the customizeOnInstantiate property. + */ + public boolean isCustomizeOnInstantiate() { + return customizeOnInstantiate; + } + + /** + * Gets the value of the links property. + */ + public Set getLinks() { + return this.links; + } + + /** + * Gets the value of the href property. + * + * @return possible object is + * {@link String } + */ + public URI getHref() { + return href; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CustomizationSection that = CustomizationSection.class.cast(o); + return super.equals(that) && + equal(customizeOnInstantiate, that.customizeOnInstantiate) && + equal(links, that.links) && + equal(href, that.href) && + equal(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode( + super.hashCode(), + customizeOnInstantiate, + links, + href, + type); + } + + @Override + public Objects.ToStringHelper string() { + return super.string() + .add("customizeOnInstantiate", customizeOnInstantiate) + .add("links", links) + .add("href", href) + .add("type", type); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java index 4410fb0649..801375b9c0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Entity.java @@ -29,10 +29,10 @@ import com.google.common.collect.Sets; * An entity. * * @author grkvlt@apache.org + * @author Adam Lowe */ public class Entity extends EntityType { - @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } @@ -46,13 +46,7 @@ public class Entity extends EntityType { @Override public Entity build() { - Entity entity = new Entity(href, name); - entity.setDescription(description); - entity.setTasksInProgress(tasksInProgress); - entity.setId(id); - entity.setType(type); - entity.setLinks(links); - return entity; + return new Entity(href, type, links, description, tasksInProgress, id, name); } /** @@ -110,7 +104,7 @@ public class Entity extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -119,7 +113,7 @@ public class Entity extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -137,21 +131,11 @@ public class Entity extends EntityType { } } - protected Entity(URI href, String name) { - super(href, name); + private Entity(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, String name) { + super(href, type, links, description, tasksInProgress, id, name); } - protected Entity() { + private Entity() { // For JAXB } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Entity that = Entity.class.cast(o); - return super.equals(that); - } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java index 62208ab026..077e4ad1e0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/EntityType.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -34,27 +32,19 @@ import com.google.common.collect.Sets; /** * Basic entity type in the vCloud object model. - * + *

* Includes a name, an optional description, and an optional list of links - * + *

*

  * <xs:complexType name="EntityType">
  * 
* * @author grkvlt@apache.org + * @author Adam Lowe */ -public class EntityType> extends ResourceType { +public abstract class EntityType> extends ResourceType { - public static > Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return new Builder().fromEntityType(this); - } - - public static class Builder> extends ResourceType.Builder { + public static abstract class Builder> extends ResourceType.Builder { protected String description; protected TasksInProgress tasksInProgress; @@ -93,17 +83,6 @@ public class EntityType> extends ResourceType { return this; } - @Override - public EntityType build() { - EntityType entity = new EntityType(href, name); - entity.setDescription(description); - entity.setTasksInProgress(tasksInProgress); - entity.setId(id); - entity.setType(type); - entity.setLinks(links); - return entity; - } - /** * @see ResourceType#getHref() */ @@ -151,22 +130,25 @@ public class EntityType> extends ResourceType { public Builder fromEntityType(EntityType in) { return fromResourceType(in) - .description(in.getDescription()).tasksInProgress(in.getTasksInProgress()) - .id(in.getId()).name(in.getName()); + .description(in.getDescription()).tasksInProgress(in.getTasksInProgress()) + .id(in.getId()).name(in.getName()); } } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Description") + @XmlElement(name = "Description") private String description; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "TasksInProgress") + @XmlElement(name = "TasksInProgress") private TasksInProgress tasksInProgress; @XmlAttribute private String id; @XmlAttribute(required = true) private String name; - protected EntityType(URI href, String name) { - super(href); + public EntityType(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, String name) { + super(href, type, links); + this.description = description; + this.tasksInProgress = tasksInProgress; + this.id = id; this.name = name; } @@ -181,10 +163,6 @@ public class EntityType> extends ResourceType { return description; } - public void setDescription(String description) { - this.description = description; - } - /** * A list of queued, running, or recently completed tasks associated with this entity. */ @@ -192,13 +170,9 @@ public class EntityType> extends ResourceType { return tasksInProgress; } - public void setTasksInProgress(TasksInProgress tasksInProgress) { - this.tasksInProgress = tasksInProgress; - } - /** * The resource identifier, expressed in URN format. - * + *

* The value of this attribute uniquely identifies the resource, persists for the life of the * resource, and is never reused. */ @@ -206,20 +180,12 @@ public class EntityType> extends ResourceType { return id; } - public void setId(String id) { - this.id = id; - } - /** * Contains the name of the the entity. */ public String getName() { return name; } - - public void setName(String name) { - this.name = name; - } @Override public boolean equals(Object o) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java index 17891e8c45..b167f7f108 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Error.java @@ -20,10 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; @@ -33,17 +30,16 @@ import com.google.common.base.Objects; /** * The standard error message type used in the vCloud REST API. - * + *

*

  * <xs:complexType name="ErrorType">
  * 
* * @author grkvlt@apache.org */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Error") -@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "Error") public class Error { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.ERROR; public static Builder builder() { @@ -103,10 +99,7 @@ public class Error { } public Error build() { - Error error = new Error(message, majorErrorCode, minorErrorCode); - error.setVendorSpecificErrorCode(vendorSpecificErrorCode); - error.setStackTrace(stackTrace); - return error; + return new Error(message, majorErrorCode, minorErrorCode, vendorSpecificErrorCode, stackTrace); } public Builder fromError(Error in) { @@ -129,10 +122,12 @@ public class Error { @XmlAttribute private String stackTrace; - private Error(String message, Integer majorErrorCode, String minorErrorCode) { + private Error(String message, Integer majorErrorCode, String minorErrorCode, String vendorSpecificErrorCode, String stackTrace) { this.message = checkNotNull(message, "message"); this.majorErrorCode = checkNotNull(majorErrorCode, "majorErrorCode"); this.minorErrorCode = checkNotNull(minorErrorCode, "minorErrorCode"); + this.vendorSpecificErrorCode = vendorSpecificErrorCode; + this.stackTrace = stackTrace; } private Error() { @@ -155,7 +150,7 @@ public class Error { /** * Specific API error code. - * + *

* For example - can indicate that vApp power on failed by some reason. */ public String getMinorErrorCode() { @@ -170,10 +165,6 @@ public class Error { return vendorSpecificErrorCode; } - public void setVendorSpecificErrorCode(String vendorSpecificErrorCode) { - this.vendorSpecificErrorCode = vendorSpecificErrorCode; - } - /** * The stack trace of the exception which when examined might make problem * diagnostics easier. @@ -182,10 +173,6 @@ public class Error { return stackTrace; } - public void setStackTrace(String stackTrace) { - this.stackTrace = stackTrace; - } - @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java index ea9369ecb1..b9e455dcb0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/File.java @@ -24,9 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; @@ -38,14 +35,13 @@ import com.google.common.collect.Sets; /** - * - * Represents a file to be transferred (uploaded or downloaded). - * - * + * Represents a file to be transferred (uploaded or downloaded). + *

+ *

*

Java class for File complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType name="File">
  *   <complexContent>
@@ -58,26 +54,21 @@ import com.google.common.collect.Sets;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ -@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "File") -public class File - extends EntityType - -{ +public class File extends EntityType { @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder().fromFile(this); } public static class Builder extends EntityType.Builder { - + private Long size; private Long bytesTransferred; private String checksum; @@ -106,16 +97,10 @@ public class File return this; } - public File build() { - File file = new File(); - file.setSize(size); - file.setBytesTransferred(bytesTransferred); - file.setChecksum(checksum); - return file; + return new File(href, type, links, description, tasksInProgress, id, name, size, bytesTransferred, checksum); } - /** * @see EntityType#getId() */ @@ -153,7 +138,7 @@ public class File } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -162,7 +147,7 @@ public class File } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -173,120 +158,86 @@ public class File @Override public Builder fromEntityType(EntityType in) { - return Builder.class.cast(super.fromEntityType(in)); + return Builder.class.cast(super.fromEntityType(in)); } + public Builder fromFile(File in) { return fromEntityType(in) - .size(in.getSize()) - .bytesTransferred(in.getBytesTransferred()) - .checksum(in.getChecksum()); + .size(in.getSize()) + .bytesTransferred(in.getBytesTransferred()) + .checksum(in.getChecksum()); } } + public File(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, + String name, Long size, Long bytesTransferred, String checksum) { + super(href, type, links, description, tasksInProgress, id, name); + this.size = size; + this.bytesTransferred = bytesTransferred; + this.checksum = checksum; + } + private File() { // For JAXB and builder use } + @XmlAttribute + protected Long size; + @XmlAttribute + protected Long bytesTransferred; + @XmlAttribute + @XmlJavaTypeAdapter(NormalizedStringAdapter.class) + @XmlSchemaType(name = "normalizedString") + protected String checksum; - @XmlAttribute - protected Long size; - @XmlAttribute - protected Long bytesTransferred; - @XmlAttribute - @XmlJavaTypeAdapter(NormalizedStringAdapter.class) - @XmlSchemaType(name = "normalizedString") - protected String checksum; + /** + * Gets the value of the size property. + * + * @return possible object is + * {@link Long } + */ + public Long getSize() { + return size; + } - /** - * Gets the value of the size property. - * - * @return - * possible object is - * {@link Long } - * - */ - public Long getSize() { - return size; - } + /** + * Gets the value of the bytesTransferred property. + * + * @return possible object is + * {@link Long } + */ + public Long getBytesTransferred() { + return bytesTransferred; + } - /** - * Sets the value of the size property. - * - * @param value - * allowed object is - * {@link Long } - * - */ - public void setSize(Long value) { - this.size = value; - } - - /** - * Gets the value of the bytesTransferred property. - * - * @return - * possible object is - * {@link Long } - * - */ - public Long getBytesTransferred() { - return bytesTransferred; - } - - /** - * Sets the value of the bytesTransferred property. - * - * @param value - * allowed object is - * {@link Long } - * - */ - public void setBytesTransferred(Long value) { - this.bytesTransferred = value; - } - - /** - * Gets the value of the checksum property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getChecksum() { - return checksum; - } - - /** - * Sets the value of the checksum property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setChecksum(String value) { - this.checksum = value; - } + /** + * Gets the value of the checksum property. + * + * @return possible object is + * {@link String } + */ + public String getChecksum() { + return checksum; + } @Override public boolean equals(Object o) { if (this == o) - return true; + return true; if (o == null || getClass() != o.getClass()) return false; File that = File.class.cast(o); - return equal(size, that.size) && - equal(bytesTransferred, that.bytesTransferred) && - equal(checksum, that.checksum); + return equal(size, that.size) && + equal(bytesTransferred, that.bytesTransferred) && + equal(checksum, that.checksum); } @Override public int hashCode() { - return Objects.hashCode(size, - bytesTransferred, - checksum); + return Objects.hashCode(size, + bytesTransferred, + checksum); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java index 6a196bde57..050ecd1d86 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java @@ -21,27 +21,24 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; +import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; /** - * - * Represents a list of files to be transferred (uploaded - * or downloaded). - * - * + * Represents a list of files to be transferred (uploaded + * or downloaded). + *

+ *

*

Java class for FilesList complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType name="FilesList">
  *   <complexContent>
@@ -54,12 +51,9 @@ import com.google.common.base.Objects;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ -@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "FilesList", propOrder = { - "files" + "files" }) public class FilesList { public static Builder builder() { @@ -71,14 +65,14 @@ public class FilesList { } public static class Builder { - - private List files; + + private Set files = Sets.newLinkedHashSet(); /** * @see FilesList#getFiles() */ - public Builder file(List file) { - this.files = file; + public Builder files(Set files) { + this.files = files; return this; } @@ -90,7 +84,7 @@ public class FilesList { public Builder fromFilesList(FilesList in) { - return file(in.getFiles()); + return files(in.getFiles()); } } @@ -98,47 +92,25 @@ public class FilesList { // For JAXB and builder use } - private FilesList(List files) { - this.files = files; + private FilesList(Set files) { + this.files = ImmutableSet.copyOf(files); } - @XmlElement(name = "File", required = true) - protected List files; + @XmlElement(name = "File", required = true) + protected Set files = Sets.newLinkedHashSet(); - /** - * Gets the value of the file property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the file property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getFile().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link FileType } - * - * - */ - public List getFiles() { - if (files == null) { - files = new ArrayList(); - } - return this.files; - } + /** + * Gets the value of the file property. + */ + public Set getFiles() { + return this.files; + } @Override public boolean equals(Object o) { if (this == o) - return true; + return true; if (o == null || getClass() != o.getClass()) return false; FilesList that = FilesList.class.cast(o); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java new file mode 100644 index 0000000000..e10406e68f --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java @@ -0,0 +1,623 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Collections; +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents a guest customization settings. + *

+ *

+ *

Java class for GuestCustomizationSection complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="GuestCustomizationSection">
+ *   <complexContent>
+ *     <extension base="{http://schemas.dmtf.org/ovf/envelope/1}Section_Type">
+ *       <sequence>
+ *         <element name="Enabled" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="ChangeSid" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="VirtualMachineId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="JoinDomainEnabled" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="UseOrgSettings" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="DomainName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="DomainUserName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="DomainUserPassword" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="AdminPasswordEnabled" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="AdminPasswordAuto" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="AdminPassword" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="ResetPasswordRequired" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *         <element name="CustomizationScript" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="ComputerName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="Link" type="{http://www.vmware.com/vcloud/v1.5}LinkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlRootElement(name = "GuestCustomizationSection") +@XmlType(propOrder = { + "enabled", + "changeSid", + "virtualMachineId", + "joinDomainEnabled", + "useOrgSettings", + "domainName", + "domainUserName", + "domainUserPassword", + "adminPasswordEnabled", + "adminPasswordAuto", + "adminPassword", + "resetPasswordRequired", + "customizationScript", + "computerName", + "links" +}) +public class GuestCustomizationSection extends SectionType { + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromGuestCustomizationSection(this); + } + + public static class Builder extends SectionType.Builder { + private Boolean enabled; + private Boolean changeSid; + private String virtualMachineId; + private Boolean joinDomainEnabled; + private Boolean useOrgSettings; + private String domainName; + private String domainUserName; + private String domainUserPassword; + private Boolean adminPasswordEnabled; + private Boolean adminPasswordAuto; + private String adminPassword; + private Boolean resetPasswordRequired; + private String customizationScript; + private String computerName; + private Set links = Sets.newLinkedHashSet(); + private URI href; + private String type; + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isEnabled() + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isChangeSid() + */ + public Builder changeSid(Boolean changeSid) { + this.changeSid = changeSid; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getVirtualMachineId() + */ + public Builder virtualMachineId(String virtualMachineId) { + this.virtualMachineId = virtualMachineId; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isJoinDomainEnabled() + */ + public Builder joinDomainEnabled(Boolean joinDomainEnabled) { + this.joinDomainEnabled = joinDomainEnabled; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isUseOrgSettings() + */ + public Builder useOrgSettings(Boolean useOrgSettings) { + this.useOrgSettings = useOrgSettings; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getDomainName() + */ + public Builder domainName(String domainName) { + this.domainName = domainName; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getDomainUserName() + */ + public Builder domainUserName(String domainUserName) { + this.domainUserName = domainUserName; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getDomainUserPassword() + */ + public Builder domainUserPassword(String domainUserPassword) { + this.domainUserPassword = domainUserPassword; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isAdminPasswordEnabled() + */ + public Builder adminPasswordEnabled(Boolean adminPasswordEnabled) { + this.adminPasswordEnabled = adminPasswordEnabled; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isAdminPasswordAuto() + */ + public Builder adminPasswordAuto(Boolean adminPasswordAuto) { + this.adminPasswordAuto = adminPasswordAuto; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getAdminPassword() + */ + public Builder adminPassword(String adminPassword) { + this.adminPassword = adminPassword; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#isResetPasswordRequired() + */ + public Builder resetPasswordRequired(Boolean resetPasswordRequired) { + this.resetPasswordRequired = resetPasswordRequired; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getCustomizationScript() + */ + public Builder customizationScript(String customizationScript) { + this.customizationScript = customizationScript; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getComputerName() + */ + public Builder computerName(String computerName) { + this.computerName = computerName; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getLink() + */ + public Builder links(Set links) { + this.links = checkNotNull(links, "links"); + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + + public GuestCustomizationSection build() { + return new GuestCustomizationSection(info, required, enabled, changeSid, virtualMachineId, + joinDomainEnabled, useOrgSettings, domainName, domainUserName, + domainUserPassword, adminPasswordEnabled, adminPasswordAuto, + adminPassword, resetPasswordRequired, customizationScript, + computerName, links, href, type); + } + + public Builder fromGuestCustomizationSection(GuestCustomizationSection in) { + return fromSection(in) + .enabled(in.isEnabled()) + .changeSid(in.isChangeSid()) + .virtualMachineId(in.getVirtualMachineId()) + .joinDomainEnabled(in.isJoinDomainEnabled()) + .useOrgSettings(in.isUseOrgSettings()) + .domainName(in.getDomainName()) + .domainUserName(in.getDomainUserName()) + .domainUserPassword(in.getDomainUserPassword()) + .adminPasswordEnabled(in.isAdminPasswordEnabled()) + .adminPasswordAuto(in.isAdminPasswordAuto()) + .adminPassword(in.getAdminPassword()) + .resetPasswordRequired(in.isResetPasswordRequired()) + .customizationScript(in.getCustomizationScript()) + .computerName(in.getComputerName()) + .links(in.getLink()) + .href(in.getHref()) + .type(in.getType()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromSection(SectionType in) { + return Builder.class.cast(super.fromSection(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder info(String info) { + return Builder.class.cast(super.info(info)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder required(Boolean required) { + return Builder.class.cast(super.required(required)); + } + } + + private GuestCustomizationSection(@Nullable String info, @Nullable Boolean required, Boolean enabled, Boolean changeSid, String virtualMachineId, + Boolean joinDomainEnabled, Boolean useOrgSettings, String domainName, String domainUserName, + String domainUserPassword, Boolean adminPasswordEnabled, Boolean adminPasswordAuto, + String adminPassword, Boolean resetPasswordRequired, String customizationScript, + String computerName, Set links, URI href, String type) { + super(info, required); + this.enabled = enabled; + this.changeSid = changeSid; + this.virtualMachineId = virtualMachineId; + this.joinDomainEnabled = joinDomainEnabled; + this.useOrgSettings = useOrgSettings; + this.domainName = domainName; + this.domainUserName = domainUserName; + this.domainUserPassword = domainUserPassword; + this.adminPasswordEnabled = adminPasswordEnabled; + this.adminPasswordAuto = adminPasswordAuto; + this.adminPassword = adminPassword; + this.resetPasswordRequired = resetPasswordRequired; + this.customizationScript = customizationScript; + this.computerName = computerName; + this.links = ImmutableSet.copyOf(links); + this.href = href; + this.type = type; + } + + private GuestCustomizationSection() { + // For JAXB and builder use + } + + + @XmlElement(name = "Enabled") + private Boolean enabled; + @XmlElement(name = "ChangeSid") + private Boolean changeSid; + @XmlElement(name = "VirtualMachineId") + private String virtualMachineId; + @XmlElement(name = "JoinDomainEnabled") + private Boolean joinDomainEnabled; + @XmlElement(name = "UseOrgSettings") + private Boolean useOrgSettings; + @XmlElement(name = "DomainName") + private String domainName; + @XmlElement(name = "DomainUserName") + private String domainUserName; + @XmlElement(name = "DomainUserPassword") + private String domainUserPassword; + @XmlElement(name = "AdminPasswordEnabled") + private Boolean adminPasswordEnabled; + @XmlElement(name = "AdminPasswordAuto") + private Boolean adminPasswordAuto; + @XmlElement(name = "AdminPassword") + private String adminPassword; + @XmlElement(name = "ResetPasswordRequired") + private Boolean resetPasswordRequired; + @XmlElement(name = "CustomizationScript") + private String customizationScript; + @XmlElement(name = "ComputerName") + private String computerName; + @XmlElement(name = "Link") + private Set links = Sets.newLinkedHashSet(); + @XmlAttribute + @XmlSchemaType(name = "anyURI") + private URI href; + @XmlAttribute + private String type; + + /** + * Gets the value of the enabled property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isEnabled() { + return enabled; + } + + /** + * Gets the value of the changeSid property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isChangeSid() { + return changeSid; + } + + /** + * Gets the value of the virtualMachineId property. + * + * @return possible object is + * {@link String } + */ + public String getVirtualMachineId() { + return virtualMachineId; + } + + /** + * Gets the value of the joinDomainEnabled property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isJoinDomainEnabled() { + return joinDomainEnabled; + } + + /** + * Gets the value of the useOrgSettings property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isUseOrgSettings() { + return useOrgSettings; + } + + + /** + * Gets the value of the domainName property. + * + * @return possible object is + * {@link String } + */ + public String getDomainName() { + return domainName; + } + + /** + * Gets the value of the domainUserName property. + * + * @return possible object is + * {@link String } + */ + public String getDomainUserName() { + return domainUserName; + } + + /** + * Gets the value of the domainUserPassword property. + * + * @return possible object is + * {@link String } + */ + public String getDomainUserPassword() { + return domainUserPassword; + } + + /** + * Gets the value of the adminPasswordEnabled property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isAdminPasswordEnabled() { + return adminPasswordEnabled; + } + + /** + * Gets the value of the adminPasswordAuto property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isAdminPasswordAuto() { + return adminPasswordAuto; + } + + /** + * Gets the value of the adminPassword property. + * + * @return possible object is + * {@link String } + */ + public String getAdminPassword() { + return adminPassword; + } + + /** + * Gets the value of the resetPasswordRequired property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isResetPasswordRequired() { + return resetPasswordRequired; + } + + /** + * Gets the value of the customizationScript property. + * + * @return possible object is + * {@link String } + */ + public String getCustomizationScript() { + return customizationScript; + } + + /** + * Gets the value of the computerName property. + * + * @return possible object is + * {@link String } + */ + public String getComputerName() { + return computerName; + } + + /** + * Gets the value of the link property. + *

+ * Objects of the following type(s) are allowed in the list + * {@link Link } + */ + public Set getLink() { + return Collections.unmodifiableSet(this.links); + } + + /** + * Gets the value of the href property. + */ + public URI getHref() { + return href; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + GuestCustomizationSection that = GuestCustomizationSection.class.cast(o); + return super.equals(that) && + equal(enabled, that.enabled) && + equal(changeSid, that.changeSid) && + equal(virtualMachineId, that.virtualMachineId) && + equal(joinDomainEnabled, that.joinDomainEnabled) && + equal(useOrgSettings, that.useOrgSettings) && + equal(domainName, that.domainName) && + equal(domainUserName, that.domainUserName) && + equal(domainUserPassword, that.domainUserPassword) && + equal(adminPasswordEnabled, that.adminPasswordEnabled) && + equal(adminPasswordAuto, that.adminPasswordAuto) && + equal(adminPassword, that.adminPassword) && + equal(resetPasswordRequired, that.resetPasswordRequired) && + equal(customizationScript, that.customizationScript) && + equal(computerName, that.computerName) && + equal(links, that.links) && + equal(href, that.href) && + equal(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), + enabled, + changeSid, + virtualMachineId, + joinDomainEnabled, + useOrgSettings, + domainName, + domainUserName, + domainUserPassword, + adminPasswordEnabled, + adminPasswordAuto, + adminPassword, + resetPasswordRequired, + customizationScript, + computerName, + links, + href, + type); + } + + @Override + public Objects.ToStringHelper string() { + return super.string() + .add("enabled", enabled) + .add("changeSid", changeSid) + .add("virtualMachineId", virtualMachineId) + .add("joinDomainEnabled", joinDomainEnabled) + .add("useOrgSettings", useOrgSettings) + .add("domainName", domainName) + .add("domainUserName", domainUserName) + .add("domainUserPassword", domainUserPassword) + .add("adminPasswordEnabled", adminPasswordEnabled) + .add("adminPasswordAuto", adminPasswordAuto) + .add("adminPassword", adminPassword) + .add("resetPasswordRequired", resetPasswordRequired) + .add("customizationScript", customizationScript) + .add("computerName", computerName) + .add("links", links) + .add("href", href) + .add("type", type); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java new file mode 100644 index 0000000000..7612a61cf4 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java @@ -0,0 +1,153 @@ +/** + * 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.domain; + + +/** + * Parameters for Instantiating a vApp + * + * @author danikov + */ +public class InstantiateVAppParams + extends InstantiateVAppParamsType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder(); + } + + public static class Builder + extends InstantiateVAppParamsType.Builder { + + public InstantiateVAppParams build() { + return new InstantiateVAppParams(description, name, vAppParent, instantiationParams, deploy, powerOn, source, isSourceDelete, linkedClone); + } + + /** + * @see InstantiateVAppParams#getSource() + */ + public Builder source(Reference source) { + super.source(source); + return this; + } + + /** + * @see InstantiateVAppParams#isSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + super.isSourceDelete(isSourceDelete); + return this; + } + + /** + * @see InstantiateVAppParams#isLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + super.linkedClone(linkedClone); + return this; + } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#isDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#isPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromInstantiateVAppParamsType( + InstantiateVAppParamsType in) { + return Builder.class.cast(super.fromVAppCreationParamsType(in)); + } + + public Builder fromInstantiateVAppParams(InstantiateVAppParams in) { + return fromInstantiateVAppParamsType(in); + } + } + + private InstantiateVAppParams(String description, String name, Reference vAppParent, InstantiationParams instantiationParams, + Boolean deploy, Boolean powerOn, Reference source, Boolean sourceDelete, Boolean linkedClone) { + super(description, name, vAppParent, instantiationParams, deploy, powerOn, source, sourceDelete, linkedClone); + } + + protected InstantiateVAppParams() { + // For JAXB and builder use + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiateVAppParams that = InstantiateVAppParams.class.cast(o); + return super.equals(that); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java new file mode 100644 index 0000000000..1cc06daf5d --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java @@ -0,0 +1,251 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents vApp instantiation parameters. + *

+ *

+ *

Java class for InstantiateVAppParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="InstantiateVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VAppCreationParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="IsSourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="linkedClone" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "InstantiateVAppParams", propOrder = { + "source", + "isSourceDelete" +}) +@XmlSeeAlso({ +// InstantiateVAppTemplateParamsType.class, +// CloneVAppParamsType.class +}) +public class InstantiateVAppParamsType> + extends VAppCreationParamsType + +{ + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromInstantiateVAppParamsType(this); + } + + public static class Builder> extends VAppCreationParamsType.Builder { + + protected Reference source; + protected Boolean isSourceDelete; + protected Boolean linkedClone; + + /** + * @see InstantiateVAppParamsType#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see InstantiateVAppParamsType#isSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + this.isSourceDelete = isSourceDelete; + return this; + } + + /** + * @see InstantiateVAppParamsType#isLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + this.linkedClone = linkedClone; + return this; + } + + public InstantiateVAppParamsType build() { + return new InstantiateVAppParamsType(description, name, vAppParent, instantiationParams, deploy, powerOn, source, isSourceDelete, linkedClone); + } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#isDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#isPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public Builder fromVAppCreationParamsType(VAppCreationParamsType in) { + return Builder.class.cast(super.fromVAppCreationParamsType(in)); + } + + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + return fromVAppCreationParamsType(in) + .source(in.getSource()) + .isSourceDelete(in.isSourceDelete()) + .linkedClone(in.isLinkedClone()); + } + } + + public InstantiateVAppParamsType(String description, String name, Reference vAppParent, InstantiationParams instantiationParams, + Boolean deploy, Boolean powerOn, Reference source, Boolean sourceDelete, Boolean linkedClone) { + super(description, name, vAppParent, instantiationParams, deploy, powerOn); + this.source = source; + isSourceDelete = sourceDelete; + this.linkedClone = linkedClone; + } + + protected InstantiateVAppParamsType() { + // For JAXB and builder use + } + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "IsSourceDelete") + protected Boolean isSourceDelete; + @XmlAttribute + protected Boolean linkedClone; + + /** + * Gets the value of the source property. + * + * @return possible object is + * {@link Reference } + */ + public Reference getSource() { + return source; + } + + /** + * Gets the value of the isSourceDelete property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isSourceDelete() { + return isSourceDelete; + } + + /** + * Gets the value of the linkedClone property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isLinkedClone() { + return linkedClone; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiateVAppParamsType that = InstantiateVAppParamsType.class.cast(o); + return equal(source, that.source) && + equal(isSourceDelete, that.isSourceDelete) && + equal(linkedClone, that.linkedClone); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + isSourceDelete, + linkedClone); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("isSourceDelete", isSourceDelete) + .add("linkedClone", linkedClone).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java new file mode 100644 index 0000000000..cedbfba1cc --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java @@ -0,0 +1,193 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents vApp template instantiation parameters. + *

+ *

+ *

Java class for InstantiateVAppTemplateParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="InstantiateVAppTemplateParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}InstantiateVAppParamsType">
+ *       <sequence>
+ *         <element ref="{http://www.vmware.com/vcloud/v1.5}AllEULAsAccepted" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "InstantiateVAppTemplateParams", propOrder = { + "allEULAsAccepted" +}) +public class InstantiateVAppTemplateParams + extends InstantiateVAppParamsType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromInstantiateVAppTemplateParams(this); + } + + public static class Builder extends InstantiateVAppParamsType.Builder { + + private Boolean allEULAsAccepted; + + /** + * @see InstantiateVAppTemplateParams#isAllEULAsAccepted() + */ + public Builder allEULAsAccepted(Boolean allEULAsAccepted) { + this.allEULAsAccepted = allEULAsAccepted; + return this; + } + + public InstantiateVAppTemplateParams build() { + return new InstantiateVAppTemplateParams(description, name, vAppParent, instantiationParams, deploy, powerOn, source, isSourceDelete, linkedClone, allEULAsAccepted); + } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#isDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#isPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + return Builder.class.cast(super.fromInstantiateVAppParamsType(in)); + } + + public Builder fromInstantiateVAppTemplateParams(InstantiateVAppTemplateParams in) { + return fromInstantiateVAppParamsType(in) + .allEULAsAccepted(in.isAllEULAsAccepted()); + } + } + + public InstantiateVAppTemplateParams(String description, String name, Reference vAppParent, InstantiationParams instantiationParams, + Boolean deploy, Boolean powerOn, Reference source, Boolean sourceDelete, Boolean linkedClone, Boolean allEULAsAccepted) { + super(description, name, vAppParent, instantiationParams, deploy, powerOn, source, sourceDelete, linkedClone); + this.allEULAsAccepted = allEULAsAccepted; + } + + private InstantiateVAppTemplateParams() { + // For JAXB and builder use + } + + + @XmlElement(name = "AllEULAsAccepted") + protected Boolean allEULAsAccepted; + + /** + * Used to confirm acceptance of all EULAs in a + * vApp template. Instantiation fails if this + * element is missing, empty, or set to false + * and one or more EulaSection elements are + * present. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isAllEULAsAccepted() { + return allEULAsAccepted; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiateVAppTemplateParams that = InstantiateVAppTemplateParams.class.cast(o); + return equal(allEULAsAccepted, that.allEULAsAccepted); + } + + @Override + public int hashCode() { + return Objects.hashCode(allEULAsAccepted); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("allEULAsAccepted", allEULAsAccepted).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java new file mode 100644 index 0000000000..6154a70e67 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -0,0 +1,175 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.vcloud.director.v1_5.domain.ovf.DeploymentOptionSection; +import org.jclouds.vcloud.director.v1_5.domain.ovf.DiskSection; +import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection; +import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection; +import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; +import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection; + +import com.google.common.base.Objects; +import com.google.common.collect.Sets; + + +/** + * Represents a list of ovf:Section to configure for instantiating a VApp. + *

+ *

+ *

Java class for InstantiationParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="InstantiationParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element ref="{http://schemas.dmtf.org/ovf/envelope/1}Section" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "InstantiationParams", propOrder = { + "section" +}) +public class InstantiationParams { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromInstantiationParams(this); + } + + public static class Builder { + private Set> sections = Sets.newLinkedHashSet(); + + /** + * @see InstantiationParams#getSections() + */ + public Builder sections(Set> sections) { + this.sections = checkNotNull(sections, "sections"); + return this; + } + + + public InstantiationParams build() { + InstantiationParams instantiationParams = new InstantiationParams(sections); + return instantiationParams; + } + + + public Builder fromInstantiationParams(InstantiationParams in) { + return sections(in.getSections()); + } + } + + private InstantiationParams() { + // For JAXB and builder use + } + + private InstantiationParams(Set> sections) { + this.sections = sections; + } + + + @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) + protected Set> sections = Sets.newLinkedHashSet(); + + /** + * An ovf:Section to configure for instantiation. + *

+ * Gets the value of the section property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the section property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+    *    getSection().add(newItem);
+    * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link SectionType }{@code >} + * {@link JAXBElement }{@code <}{@link VirtualHardwareSection }{@code >} + * {@link JAXBElement }{@code <}{@link LeaseSettingsSection }{@code >} + * {@link JAXBElement }{@code <}{@link EulaSection }{@code >} + * {@link JAXBElement }{@code <}{@link RuntimeInfoSection }{@code >} + * {@link JAXBElement }{@code <}{@link AnnotationSection }{@code >} + * {@link JAXBElement }{@code <}{@link DeploymentOptionSection }{@code >} + * {@link JAXBElement }{@code <}{@link StartupSection }{@code >} + * {@link JAXBElement }{@code <}{@link ResourceAllocationSection }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkConnectionSection }{@code >} + * {@link JAXBElement }{@code <}{@link CustomizationSection }{@code >} + * {@link JAXBElement }{@code <}{@link ProductSection }{@code >} + * {@link JAXBElement }{@code <}{@link GuestCustomizationSection }{@code >} + * {@link JAXBElement }{@code <}{@link org.jclouds.ovf.OperatingSystemSection }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkConfigSection }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkSection }{@code >} + * {@link JAXBElement }{@code <}{@link DiskSection }{@code >} + * {@link JAXBElement }{@code <}{@link InstallSection }{@code >} + */ + public Set> getSections() { + return this.sections; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiationParams that = InstantiationParams.class.cast(o); + return equal(sections, that.sections); + } + + @Override + public int hashCode() { + return Objects.hashCode(sections); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("sections", sections).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java index b2ade6616f..0d2d4b1302 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java @@ -20,10 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -33,10 +31,10 @@ import com.google.common.collect.Sets; /** * A list of IpAddresses. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpAddresses") +@XmlRootElement(name = "IpAddresses") public class IpAddresses { public static Builder builder() { @@ -83,7 +81,7 @@ public class IpAddresses { this.ipAddresses = ImmutableSet.copyOf(orgs); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IpAddress") + @XmlElement(name = "IpAddress") private Set ipAddresses = Sets.newLinkedHashSet(); public Set getIpAddresses() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java index fa4a45a456..43941e6981 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -28,12 +27,12 @@ import com.google.common.base.Objects; /** * Represents a range of IP addresses, start and end inclusive. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpRange") +@XmlRootElement(name = "IpRange") public class IpRange { - + public static Builder builder() { return new Builder(); } @@ -43,7 +42,7 @@ public class IpRange { } public static class Builder { - + private String startAddress; private String endAddress; @@ -71,7 +70,7 @@ public class IpRange { return startAddress(in.getStartAddress()).endAddress(in.getEndAddress()); } } - + private IpRange() { // For JAXB and builder use } @@ -80,27 +79,26 @@ public class IpRange { this.startAddress = startAddress; this.endAddress = endAddress; } - - - @XmlElement(namespace = VCLOUD_1_5_NS, name = "StartAddress") + + @XmlElement(name = "StartAddress") private String startAddress; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "EndAddress") + @XmlElement(name = "EndAddress") private String endAddress; - + /** * @return Start address of the IP range. */ public String getStartAddress() { return startAddress; } - + /** * @return End address of the IP range. */ public String getEndAddress() { return endAddress; } - + @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java index 4b44ca5deb..f1dd1b0165 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; @@ -33,10 +31,10 @@ import com.google.common.collect.Sets; /** * A list of IpAddresses. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpRanges") +@XmlRootElement(name = "IpRanges") public class IpRanges { public static Builder builder() { @@ -83,7 +81,7 @@ public class IpRanges { this.ipRanges = ImmutableSet.copyOf(ipRanges); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IpRange") + @XmlElementRef private Set ipRanges = Sets.newLinkedHashSet(); public Set getIpRanges() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java index ba8db803a5..c1acd7ff5b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java @@ -19,10 +19,7 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -30,13 +27,12 @@ import com.google.common.base.Objects; /** * Specify network settings like gateway, network mask, DNS servers, IP ranges, etc. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "IpScope") -@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "IpScope") public class IpScope { - + public static Builder builder() { return new Builder(); } @@ -46,7 +42,7 @@ public class IpScope { } public static class Builder { - + private boolean isInherited; private String gateway; private String netmask; @@ -111,7 +107,7 @@ public class IpScope { this.ipRanges = ipRanges; return this; } - + /** * @see IpScope#getAllocatedIpAddresses() */ @@ -121,15 +117,7 @@ public class IpScope { } public IpScope build() { - IpScope ipScope = new IpScope(isInherited); - ipScope.setGateway(gateway); - ipScope.setNetmask(netmask); - ipScope.setDns1(dns1); - ipScope.setDns2(dns2); - ipScope.setDnsSuffix(dnsSuffix); - ipScope.setIpRanges(ipRanges); - ipScope.setAllocatedIpAddresses(allocatedIpAddresses); - return ipScope; + return new IpScope(isInherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses); } public Builder fromIpScope(IpScope in) { @@ -142,30 +130,39 @@ public class IpScope { .allocatedIpAddresses(in.getAllocatedIpAddresses()); } } - + private IpScope() { // For JAXB and builder use } - private IpScope(boolean isInherited) { - this.isInherited = isInherited; + public IpScope(boolean inherited, String gateway, String netmask, String dns1, String dns2, String dnsSuffix, + IpRanges ipRanges, IpAddresses allocatedIpAddresses) { + this.isInherited = inherited; + this.gateway = gateway; + this.netmask = netmask; + this.dns1 = dns1; + this.dns2 = dns2; + this.dnsSuffix = dnsSuffix; + this.ipRanges = ipRanges; + this.allocatedIpAddresses = allocatedIpAddresses; } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IsInherited") + + @XmlElement(name = "IsInherited") private boolean isInherited; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Gateway") + @XmlElement(name = "Gateway") private String gateway; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Netmask") + @XmlElement(name = "Netmask") private String netmask; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Dns1") + @XmlElement(name = "Dns1") private String dns1; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Dns2") + @XmlElement(name = "Dns2") private String dns2; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "DnsSuffix") + @XmlElement(name = "DnsSuffix") private String dnsSuffix; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IpRanges") + @XmlElement(name = "IpRanges") private IpRanges ipRanges; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "AllocatedIpAddresses") + @XmlElement(name = "AllocatedIpAddresses") private IpAddresses allocatedIpAddresses; /** @@ -174,17 +171,13 @@ public class IpScope { public boolean isInherited() { return isInherited; } - + /** * @return Gateway of the network.. */ public String getGateway() { return gateway; } - - public void setGateway(String gateway) { - this.gateway = gateway; - } /** * @return Network mask. @@ -192,10 +185,6 @@ public class IpScope { public String getNetmask() { return netmask; } - - public void setNetmask(String netmask) { - this.netmask = netmask; - } /** * @return Primary DNS server. @@ -203,21 +192,13 @@ public class IpScope { public String getDns1() { return dns1; } - - public void setDns1(String dns1) { - this.dns1 = dns1; - } - + /** * @return Secondary DNS server. */ public String getDns2() { return dns2; } - - public void setDns2(String dns2) { - this.dns2 = dns2; - } /** * @return DNS suffix. @@ -225,33 +206,21 @@ public class IpScope { public String getDnsSuffix() { return dnsSuffix; } - - public void setDnsSuffix(String dnsSuffix) { - this.dnsSuffix = dnsSuffix; - } - + /** * @return IP ranges used for static pool allocation in the network. */ public IpRanges getIpRanges() { return ipRanges; } - - public void setIpRanges(IpRanges ipRanges) { - this.ipRanges = ipRanges; - } - + /** * @return Read-only list of allocated IP addresses in the network. */ public IpAddresses getAllocatedIpAddresses() { return allocatedIpAddresses; } - - public void setAllocatedIpAddresses(IpAddresses allocatedIpAddresses) { - this.allocatedIpAddresses = allocatedIpAddresses; - } - + @Override public boolean equals(Object o) { if (this == o) @@ -285,5 +254,5 @@ public class IpScope { .add("ipRanges", ipRanges) .add("allocatedIpAddresses", allocatedIpAddresses).toString(); } - + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java new file mode 100644 index 0000000000..84a905f3a9 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java @@ -0,0 +1,352 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Collections; +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; + +import com.google.common.base.Objects; +import com.google.common.collect.Sets; + + +/** + * Represents the lease settings section for a vApp. + *

+ *

+ *

Java class for LeaseSettingsSection complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="LeaseSettingsSection">
+ *   <complexContent>
+ *     <extension base="{http://schemas.dmtf.org/ovf/envelope/1}Section_Type">
+ *       <sequence>
+ *         <element name="Link" type="{http://www.vmware.com/vcloud/v1.5}LinkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="DeploymentLeaseInSeconds" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
+ *         <element name="StorageLeaseInSeconds" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
+ *         <element name="DeploymentLeaseExpiration" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
+ *         <element name="StorageLeaseExpiration" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
+ *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlRootElement(name = "LeaseSettingsSection") +@XmlType(propOrder = { + "links", + "deploymentLeaseInSeconds", + "storageLeaseInSeconds", + "deploymentLeaseExpiration", + "storageLeaseExpiration" +}) +public class LeaseSettingsSection extends SectionType { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromLeaseSettingsSection(this); + } + + public static class Builder extends SectionType.Builder { + private Set links = Sets.newLinkedHashSet(); + private Integer deploymentLeaseInSeconds; + private Integer storageLeaseInSeconds; + private XMLGregorianCalendar deploymentLeaseExpiration; + private XMLGregorianCalendar storageLeaseExpiration; + private URI href; + private String type; + + /** + * @see LeaseSettingsSection#getLinks() + */ + public Builder links(Set links) { + this.links = checkNotNull(links, "links"); + return this; + } + + /** + * @see LeaseSettingsSection#getDeploymentLeaseInSeconds() + */ + public Builder deploymentLeaseInSeconds(Integer deploymentLeaseInSeconds) { + this.deploymentLeaseInSeconds = deploymentLeaseInSeconds; + return this; + } + + /** + * @see LeaseSettingsSection#getStorageLeaseInSeconds() + */ + public Builder storageLeaseInSeconds(Integer storageLeaseInSeconds) { + this.storageLeaseInSeconds = storageLeaseInSeconds; + return this; + } + + /** + * @see LeaseSettingsSection#getDeploymentLeaseExpiration() + */ + public Builder deploymentLeaseExpiration(XMLGregorianCalendar deploymentLeaseExpiration) { + this.deploymentLeaseExpiration = deploymentLeaseExpiration; + return this; + } + + /** + * @see LeaseSettingsSection#getStorageLeaseExpiration() + */ + public Builder storageLeaseExpiration(XMLGregorianCalendar storageLeaseExpiration) { + this.storageLeaseExpiration = storageLeaseExpiration; + return this; + } + + /** + * @see LeaseSettingsSection#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see LeaseSettingsSection#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + + public LeaseSettingsSection build() { + return new LeaseSettingsSection(info, required, links, deploymentLeaseInSeconds, + storageLeaseInSeconds, deploymentLeaseExpiration, + storageLeaseExpiration, href, type); + } + + public Builder fromLeaseSettingsSection(LeaseSettingsSection in) { + return fromSection(in) + .links(in.getLinks()) + .deploymentLeaseInSeconds(in.getDeploymentLeaseInSeconds()) + .storageLeaseInSeconds(in.getStorageLeaseInSeconds()) + .deploymentLeaseExpiration(in.getDeploymentLeaseExpiration()) + .storageLeaseExpiration(in.getStorageLeaseExpiration()) + .href(in.getHref()) + .type(in.getType()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromSection(SectionType in) { + return Builder.class.cast(super.fromSection(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder info(String info) { + return Builder.class.cast(super.info(info)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder required(Boolean required) { + return Builder.class.cast(super.required(required)); + } + } + + @XmlElement(name = "Link") + protected Set links; + @XmlElement(name = "DeploymentLeaseInSeconds") + protected Integer deploymentLeaseInSeconds; + @XmlElement(name = "StorageLeaseInSeconds") + protected Integer storageLeaseInSeconds; + @XmlElement(name = "DeploymentLeaseExpiration") + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar deploymentLeaseExpiration; + @XmlElement(name = "StorageLeaseExpiration") + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar storageLeaseExpiration; + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected URI href; + @XmlAttribute + protected String type; + + private LeaseSettingsSection(@Nullable String info, @Nullable Boolean required, Set links, Integer deploymentLeaseInSeconds, + Integer storageLeaseInSeconds, XMLGregorianCalendar deploymentLeaseExpiration, + XMLGregorianCalendar storageLeaseExpiration, URI href, String type) { + super(info, required); + this.links = links; + this.deploymentLeaseInSeconds = deploymentLeaseInSeconds; + this.storageLeaseInSeconds = storageLeaseInSeconds; + this.deploymentLeaseExpiration = deploymentLeaseExpiration; + this.storageLeaseExpiration = storageLeaseExpiration; + this.href = href; + this.type = type; + } + + private LeaseSettingsSection() { + // For JAXB + } + + /** + * Gets the value of the link property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the link property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+    *    getLink().add(newItem);
+    * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Link } + */ + public Set getLinks() { + return Collections.unmodifiableSet(this.links); + } + + /** + * Gets the value of the deploymentLeaseInSeconds property. + * + * @return possible object is + * {@link Integer } + */ + public Integer getDeploymentLeaseInSeconds() { + return deploymentLeaseInSeconds; + } + + /** + * Gets the value of the storageLeaseInSeconds property. + * + * @return possible object is + * {@link Integer } + */ + public Integer getStorageLeaseInSeconds() { + return storageLeaseInSeconds; + } + + /** + * Gets the value of the deploymentLeaseExpiration property. + * + * @return possible object is + * {@link XMLGregorianCalendar } + */ + public XMLGregorianCalendar getDeploymentLeaseExpiration() { + return deploymentLeaseExpiration; + } + + /** + * Gets the value of the storageLeaseExpiration property. + * + * @return possible object is + * {@link XMLGregorianCalendar } + */ + public XMLGregorianCalendar getStorageLeaseExpiration() { + return storageLeaseExpiration; + } + + /** + * @return the value of the href property. + */ + public URI getHref() { + return href; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + LeaseSettingsSection that = LeaseSettingsSection.class.cast(o); + return super.equals(that) && + equal(links, that.links) && + equal(deploymentLeaseInSeconds, that.deploymentLeaseInSeconds) && + equal(storageLeaseInSeconds, that.storageLeaseInSeconds) && + equal(deploymentLeaseExpiration, that.deploymentLeaseExpiration) && + equal(storageLeaseExpiration, that.storageLeaseExpiration) && + equal(href, that.href) && + equal(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), + links, + deploymentLeaseInSeconds, + storageLeaseInSeconds, + deploymentLeaseExpiration, + storageLeaseExpiration, + href, + type); + } + + @Override + public Objects.ToStringHelper string() { + return super.string() + .add("links", links) + .add("deploymentLeaseInSeconds", deploymentLeaseInSeconds) + .add("storageLeaseInSeconds", storageLeaseInSeconds) + .add("deploymentLeaseExpiration", deploymentLeaseExpiration) + .add("storageLeaseExpiration", storageLeaseExpiration) + .add("href", href) + .add("type", type); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index 28a0aa253a..9ccebe4d19 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -25,21 +25,22 @@ import java.net.URI; import java.util.Arrays; import java.util.List; import java.util.Map; - import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; /** * A link. - * + *

*

  * <xs:complexType name="LinkType">
  * 
* * @author Adrian Cole */ +@XmlRootElement(name = "Link") public class Link extends ReferenceType { public static final class Rel { @@ -58,16 +59,16 @@ public class Link extends ReferenceType { public static final String FIRST_PAGE = "firstPage"; public static final String CONTROL_ACCESS = "controlAccess"; - /** - * All acceptable {@link Link#getRel()} values. - * - * This list must be updated whenever a new relationship is added. - */ - public static final List ALL = Arrays.asList( - UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL, - ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE, - CONTROL_ACCESS - ); + /** + * All acceptable {@link Link#getRel()} values. + *

+ * This list must be updated whenever a new relationship is added. + */ + public static final List ALL = Arrays.asList( + UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL, + ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE, + CONTROL_ACCESS + ); } @SuppressWarnings("unchecked") @@ -97,11 +98,7 @@ public class Link extends ReferenceType { @Override public Link build() { - Link link = new Link(href, rel); - link.setId(id); - link.setName(name); - link.setType(type); - return link; + return new Link(href, id, name, type, rel); } /** @@ -166,8 +163,8 @@ public class Link extends ReferenceType { @XmlAttribute(required = true) private String rel; - private Link(URI href, String rel) { - super(href); + private Link(URI href, String id, String name, String type, String rel) { + super(href, id, name, type); this.rel = checkNotNull(rel, "rel"); } @@ -180,7 +177,7 @@ public class Link extends ReferenceType { * name of an operation on the object, a reference to a contained or containing object, or a * reference to an alternate representation of the object. The relationship value implies the * HTTP verb to use when you use the link's href value as a request URL. - * + * * @return relationship of the link to the object that contains it. */ public String getRel() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java index aadde7aedb..8c794d3e54 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Media.java @@ -19,13 +19,11 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Arrays; import java.util.List; import java.util.Set; - import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -35,12 +33,12 @@ import com.google.common.base.Objects.ToStringHelper; /** * Represents a media. - * + *

*

  * <complexType name="Media" />
  * 
*/ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Media") +@XmlRootElement(name = "Media") public class Media extends ResourceEntityType { public static final class ImageType { @@ -92,11 +90,7 @@ public class Media extends ResourceEntityType { @Override public Media build() { - Media media = new Media(); - media.setOwner(owner); - media.setImageType(imageType); - media.setSize(size); - return media; + return new Media(href, type, links, description, tasksInProgress, id, name, files, status, owner, imageType, size); } /** @@ -172,7 +166,7 @@ public class Media extends ResourceEntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -181,7 +175,7 @@ public class Media extends ResourceEntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -199,11 +193,20 @@ public class Media extends ResourceEntityType { } } - public Media() { - super(); + + public Media(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, + String name, FilesList files, Integer status, Owner owner, String imageType, long size) { + super(href, type, links, description, tasksInProgress, id, name, files, status); + this.owner = owner; + this.imageType = imageType; + this.size = size; } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Owner") + private Media() { + // for JAXB + } + + @XmlElement(name = "Owner") protected Owner owner; @XmlAttribute(required = true) protected String imageType; @@ -217,10 +220,6 @@ public class Media extends ResourceEntityType { return owner; } - public void setOwner(Owner value) { - this.owner = value; - } - /** * Gets the value of the imageType property. */ @@ -228,10 +227,6 @@ public class Media extends ResourceEntityType { return imageType; } - public void setImageType(String value) { - this.imageType = value; - } - /** * Gets the value of the size property. */ @@ -239,10 +234,6 @@ public class Media extends ResourceEntityType { return size; } - public void setSize(long value) { - this.size = value; - } - @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java index 2b59c1ae76..b0580abca5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -37,16 +35,16 @@ import com.google.common.collect.Sets; /** * Represents a set of metadata - * + *

*

  * <xs:complexType name="Metadata">
  * 
* * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Metadata") +@XmlRootElement(name = "Metadata") public class Metadata extends ResourceType { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA; @SuppressWarnings("unchecked") @@ -78,15 +76,12 @@ public class Metadata extends ResourceType { metadataEntries.add(checkNotNull(metadataEntry, "metadataEntry")); return this; } - + @Override public Metadata build() { - Metadata metadata = new Metadata(href, metadataEntries); - metadata.setType(type); - metadata.setLinks(links); - return metadata; + return new Metadata(href, type, links, metadataEntries); } - + /** * @see ResourceType#getHref() */ @@ -137,15 +132,16 @@ public class Metadata extends ResourceType { } private Metadata() { - // For JAXB and builder use + // For JAXB } - private Metadata(URI href, Set metadataEntries) { - super(href); + private Metadata(URI href, String type, Set links, Set metadataEntries) { + super(href, type, links); this.metadataEntries = ImmutableSet.copyOf(metadataEntries); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "MetadataEntry") + + @XmlElement(name = "MetadataEntry") private Set metadataEntries = Sets.newLinkedHashSet(); public Set getMetadataEntries() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java index 362e48a635..aa4193abd4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataEntry.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -36,16 +34,16 @@ import com.google.common.collect.Sets; /** * Represents a metadata entry - * + *

*

  * <xs:complexType name="MetadataType">
  * 
* * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "MetadataEntry") +@XmlRootElement(name = "MetadataEntry") public class MetadataEntry extends ResourceType { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA_ENTRY; @SuppressWarnings("unchecked") @@ -53,7 +51,6 @@ public class MetadataEntry extends ResourceType { return new Builder(); } - @Override public Builder toBuilder() { return new Builder().fromMetadataEntry(this); } @@ -87,15 +84,12 @@ public class MetadataEntry extends ResourceType { this.value = value; return this; } - + @Override public MetadataEntry build() { - MetadataEntry metadataEntry = new MetadataEntry(href, key, value); - metadataEntry.setType(type); - metadataEntry.setLinks(links); - return metadataEntry; + return new MetadataEntry(href, type, links, key, value); } - + /** * @see ResourceType#getHref() */ @@ -149,15 +143,15 @@ public class MetadataEntry extends ResourceType { // For JAXB and builder use } - private MetadataEntry(URI href, String key, String value) { - super(href); + public MetadataEntry(URI href, String type, Set links, String key, String value) { + super(href, type, links); this.key = checkNotNull(key, "key"); this.value = checkNotNull(value, "value"); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Key") + @XmlElement(name = "Key") private String key; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Value") + @XmlElement(name = "Value") private String value; /** @@ -173,7 +167,7 @@ public class MetadataEntry extends ResourceType { public String getValue() { return value; } - + @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java index 2150e8db9a..7f9cd87b79 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/MetadataValue.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -36,16 +34,16 @@ import com.google.common.collect.Sets; /** * Represents a metadata entry - * + *

*

  * <xs:complexType name="MetadataType">
  * 
* * @author grkvlt@apache.org */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "MetadataValue") +@XmlRootElement(name = "MetadataValue") public class MetadataValue extends ResourceType { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.METADATA_ENTRY; @SuppressWarnings("unchecked") @@ -68,15 +66,12 @@ public class MetadataValue extends ResourceType { this.value = value; return this; } - + @Override public MetadataValue build() { - MetadataValue metadataValue = new MetadataValue(href, value); - metadataValue.setType(type); - metadataValue.setLinks(links); - return metadataValue; + return new MetadataValue(href, type, links, value); } - + /** * @see ResourceType#getHref() */ @@ -127,15 +122,15 @@ public class MetadataValue extends ResourceType { } private MetadataValue() { - // For JAXB and builder use + // For JAXB } - private MetadataValue(URI href, String value) { - super(href); + private MetadataValue(URI href, String type, Set links, String value) { + super(href, type, links); this.value = checkNotNull(value, "value"); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Value", required = true) + @XmlElement(name = "Value", required = true) private String value; /** @@ -144,7 +139,7 @@ public class MetadataValue extends ResourceType { public String getValue() { return value; } - + @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java new file mode 100644 index 0000000000..9bee51fce8 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java @@ -0,0 +1,153 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents mapping between a VM and vApp network. + *

+ *

+ *

Java class for NetworkAssignment complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="NetworkAssignment">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <attribute name="innerNetwork" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="containerNetwork" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "NetworkAssignment") +public class NetworkAssignment + + +{ + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkAssignment(this); + } + + public static class Builder { + + private String innerNetwork; + private String containerNetwork; + + /** + * @see NetworkAssignment#getInnerNetwork() + */ + public Builder innerNetwork(String innerNetwork) { + this.innerNetwork = innerNetwork; + return this; + } + + /** + * @see NetworkAssignment#getContainerNetwork() + */ + public Builder containerNetwork(String containerNetwork) { + this.containerNetwork = containerNetwork; + return this; + } + + public NetworkAssignment build() { + return new NetworkAssignment(innerNetwork, containerNetwork); + } + + public Builder fromNetworkAssignment(NetworkAssignment in) { + return innerNetwork(in.getInnerNetwork()) + .containerNetwork(in.getContainerNetwork()); + } + } + + private NetworkAssignment(String innerNetwork, String containerNetwork) { + this.innerNetwork = innerNetwork; + this.containerNetwork = containerNetwork; + } + + private NetworkAssignment() { + // For JAXB and builder use + } + + + @XmlAttribute(required = true) + protected String innerNetwork; + @XmlAttribute(required = true) + protected String containerNetwork; + + /** + * Gets the value of the innerNetwork property. + * + * @return possible object is + * {@link String } + */ + public String getInnerNetwork() { + return innerNetwork; + } + + /** + * Gets the value of the containerNetwork property. + * + * @return possible object is + * {@link String } + */ + public String getContainerNetwork() { + return containerNetwork; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkAssignment that = NetworkAssignment.class.cast(o); + return equal(innerNetwork, that.innerNetwork) && + equal(containerNetwork, that.containerNetwork); + } + + @Override + public int hashCode() { + return Objects.hashCode(innerNetwork, + containerNetwork); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("innerNetwork", innerNetwork) + .add("containerNetwork", containerNetwork).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java new file mode 100644 index 0000000000..5397647130 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java @@ -0,0 +1,245 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Collections; +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents the network config section of a vApp. + *

+ *

+ *

Java class for NetworkConfigSection complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="NetworkConfigSection">
+ *   <complexContent>
+ *     <extension base="{http://schemas.dmtf.org/ovf/envelope/1}Section_Type">
+ *       <sequence>
+ *         <element name="Link" type="{http://www.vmware.com/vcloud/v1.5}LinkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="NetworkConfig" type="{http://www.vmware.com/vcloud/v1.5}VAppNetworkConfigurationType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlRootElement(name = "NetworkConfigSection") +@XmlType(propOrder = { + "links", + "networkConfigs" +}) +public class NetworkConfigSection extends SectionType { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkConfigSection(this); + } + + public static class Builder extends SectionType.Builder { + + private Set links = Sets.newLinkedHashSet(); + private Set> networkConfigs = Sets.newLinkedHashSet(); + private URI href; + private String type; + + /** + * @see NetworkConfigSection#getLinks() + */ + public Builder links(Set links) { + this.links = checkNotNull(links, "links"); + return this; + } + + /** + * @see NetworkConfigSection#getNetworkConfigs() + */ + public Builder networkConfig(Set> networkConfigs) { + this.networkConfigs = checkNotNull(networkConfigs, "networkConfigs"); + return this; + } + + /** + * @see NetworkConfigSection#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see NetworkConfigSection#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + + public NetworkConfigSection build() { + return new NetworkConfigSection(info, required, links, networkConfigs, href, type); + } + + public Builder fromNetworkConfigSection(NetworkConfigSection in) { + return fromSection(in) + .links(in.getLinks()) + .networkConfig(in.getNetworkConfigs()) + .href(in.getHref()) + .type(in.getType()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromSection(SectionType in) { + return Builder.class.cast(super.fromSection(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder info(String info) { + return Builder.class.cast(super.info(info)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder required(Boolean required) { + return Builder.class.cast(super.required(required)); + } + + } + + @XmlElement(name = "Link") + protected Set links; + @XmlElement(name = "NetworkConfig") + protected Set> networkConfigs; + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected URI href; + @XmlAttribute + protected String type; + + public NetworkConfigSection(@Nullable String info, @Nullable Boolean required, Set links, Set> networkConfigs, + URI href, String type) { + super(info, required); + this.links = ImmutableSet.copyOf(links); + this.networkConfigs = ImmutableSet.copyOf(networkConfigs); + this.href = href; + this.type = type; + } + + private NetworkConfigSection() { + // For JAXB + } + + /** + * Gets the value of the link property. + */ + public Set getLinks() { + return Collections.unmodifiableSet(this.links); + } + + /** + * Gets the value of the networkConfig property. + */ + public Set> getNetworkConfigs() { + return Collections.unmodifiableSet(this.networkConfigs); + } + + /** + * Gets the value of the href property. + */ + public URI getHref() { + return href; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkConfigSection that = NetworkConfigSection.class.cast(o); + return super.equals(that) && + equal(links, that.links) && + equal(networkConfigs, that.networkConfigs) && + equal(href, that.href) && + equal(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), + links, + networkConfigs, + href, + type); + } + + @Override + public Objects.ToStringHelper string() { + return super.string() + .add("links", links) + .add("networkConfigs", networkConfigs) + .add("href", href) + .add("type", type); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java index a611eceb47..5b623ccef7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java @@ -19,10 +19,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; +import static com.google.common.base.Preconditions.checkNotNull; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -30,12 +28,11 @@ import com.google.common.base.Objects; /** * Returns a network configuration - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "NetworkConfiguration") -@XmlAccessorType(XmlAccessType.FIELD) -public class NetworkConfiguration{ +@XmlRootElement(name = "NetworkConfiguration") +public class NetworkConfiguration { public static Builder builder() { return new Builder(); @@ -111,14 +108,7 @@ public class NetworkConfiguration{ } public NetworkConfiguration build() { - NetworkConfiguration networkConfiguration = new NetworkConfiguration(fenceMode); - networkConfiguration.setIpScope(ipScope); - networkConfiguration.setParentNetwork(parentNetwork); - networkConfiguration.setRetainNetInfoAcrossDeployments(retainNetInfoAcrossDeployments); - networkConfiguration.setNetworkFeatures(features); - networkConfiguration.setSyslogServerSettings(syslogServerSettings); - networkConfiguration.setRouterInfo(routerInfo); - return networkConfiguration; + return new NetworkConfiguration(ipScope, parentNetwork, fenceMode, retainNetInfoAcrossDeployments, features, syslogServerSettings, routerInfo); } public Builder fromConfiguration(NetworkConfiguration in) { @@ -130,41 +120,44 @@ public class NetworkConfiguration{ } } + public NetworkConfiguration(IpScope ipScope, ReferenceType parentNetwork, String fenceMode, boolean retainNetInfoAcrossDeployments, + NetworkFeatures features, SyslogServerSettings syslogServerSettings, RouterInfo routerInfo) { + this.ipScope = ipScope; + this.parentNetwork = parentNetwork; + this.fenceMode = checkNotNull(fenceMode, "fenceMode"); + this.retainNetInfoAcrossDeployments = retainNetInfoAcrossDeployments; + this.features = features; + this.syslogServerSettings = syslogServerSettings; + this.routerInfo = routerInfo; + } + private NetworkConfiguration() { // For JAXB and builder use } - private NetworkConfiguration(String fenceMode) { - this.fenceMode = fenceMode; - } - - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IpScope") + @XmlElement(name = "IpScope") private IpScope ipScope; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "ParentNetwork") + @XmlElement(name = "ParentNetwork") private ReferenceType parentNetwork; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "FenceMode") + @XmlElement(name = "FenceMode") private String fenceMode; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "RetainNetInfoAcrossDeployments") + @XmlElement(name = "RetainNetInfoAcrossDeployments") private boolean retainNetInfoAcrossDeployments = false; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Features") + @XmlElement(name = "Features") private NetworkFeatures features; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerSettings") + @XmlElement(name = "SyslogServerSettings") private SyslogServerSettings syslogServerSettings; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "RouterInfo") + @XmlElement(name = "RouterInfo") private RouterInfo routerInfo; /** - * @return IP level configuration items such as gateway, dns, subnet, - * IP address pool to be used for allocation. Note that the pool of IP addresses - * needs to fall within the subnet/mask of the IpScope. + * @return IP level configuration items such as gateway, dns, subnet, + * IP address pool to be used for allocation. Note that the pool of IP addresses + * needs to fall within the subnet/mask of the IpScope. */ public IpScope getIpScope() { return ipScope; } - - public void setIpScope(IpScope ipScope) { - this.ipScope = ipScope; - } /** * @return reference to parent network. @@ -172,32 +165,24 @@ public class NetworkConfiguration{ public ReferenceType getParentNetwork() { return parentNetwork; } - - public void setParentNetwork(ReferenceType parentNetwork) { - this.parentNetwork = parentNetwork; - } /** - * @return Isolation type of the network. If ParentNetwork is specified, this property - * controls connectivity to the parent. One of: bridged (connected directly to the ParentNetwork), - * isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a - * NAT service) + * @return Isolation type of the network. If ParentNetwork is specified, this property + * controls connectivity to the parent. One of: bridged (connected directly to the ParentNetwork), + * isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a + * NAT service) */ public String getFenceMode() { return fenceMode; } /** - * @return whether the network resources such as IP/MAC of router will be retained - * across deployments. Default is false. + * @return whether the network resources such as IP/MAC of router will be retained + * across deployments. Default is false. */ public boolean getRetainNetInfoAcrossDeployments() { return retainNetInfoAcrossDeployments; } - - public void setRetainNetInfoAcrossDeployments(boolean retainNetInfoAcrossDeployments) { - this.retainNetInfoAcrossDeployments = retainNetInfoAcrossDeployments; - } /** * @return Network features like DHCP, firewall and NAT rules. @@ -205,10 +190,6 @@ public class NetworkConfiguration{ public NetworkFeatures getNetworkFeatures() { return features; } - - public void setNetworkFeatures(NetworkFeatures features) { - this.features = features; - } /** * @return Syslog server settings for the network. @@ -216,10 +197,6 @@ public class NetworkConfiguration{ public SyslogServerSettings getSyslogServerSettings() { return syslogServerSettings; } - - public void setSyslogServerSettings(SyslogServerSettings syslogServerSettings) { - this.syslogServerSettings = syslogServerSettings; - } /** * @return router information @@ -227,10 +204,6 @@ public class NetworkConfiguration{ public RouterInfo getRouterInfo() { return routerInfo; } - - public void setRouterInfo(RouterInfo routerInfo) { - this.routerInfo = routerInfo; - } @Override public boolean equals(Object o) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java new file mode 100644 index 0000000000..364b79ee34 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnection.java @@ -0,0 +1,320 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * Represents a network connection. + *

+ *

+ *

Java class for NetworkConnection complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="NetworkConnection">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="NetworkConnectionIndex" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="IpAddress" type="{http://www.vmware.com/vcloud/v1.5}IpAddressType" minOccurs="0"/>
+ *         <element name="ExternalIpAddress" type="{http://www.vmware.com/vcloud/v1.5}IpAddressType" minOccurs="0"/>
+ *         <element name="IsConnected" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="MACAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="IpAddressAllocationMode" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *       <attribute name="network" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="needsCustomization" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "NetworkConnection", propOrder = { + "networkConnectionIndex", + "ipAddress", + "externalIpAddress", + "isConnected", + "macAddress", + "ipAddressAllocationMode" +}) +public class NetworkConnection { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkConnection(this); + } + + public static class Builder { + + private int networkConnectionIndex; + private String ipAddress; + private String externalIpAddress; + private boolean isConnected; + private String macAddress; + private String ipAddressAllocationMode; + private String network; + private Boolean needsCustomization; + + /** + * @see NetworkConnection#getNetworkConnectionIndex() + */ + public Builder networkConnectionIndex(int networkConnectionIndex) { + this.networkConnectionIndex = networkConnectionIndex; + return this; + } + + /** + * @see NetworkConnection#getIpAddress() + */ + public Builder ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + /** + * @see NetworkConnection#getExternalIpAddress() + */ + public Builder externalIpAddress(String externalIpAddress) { + this.externalIpAddress = externalIpAddress; + return this; + } + + /** + * @see NetworkConnection#isConnected() + */ + public Builder isConnected(boolean isConnected) { + this.isConnected = isConnected; + return this; + } + + /** + * @see NetworkConnection#getMACAddress() + */ + public Builder macAddress(String macAddress) { + this.macAddress = macAddress; + return this; + } + + /** + * @see NetworkConnection#getIpAddressAllocationMode() + */ + public Builder ipAddressAllocationMode(String ipAddressAllocationMode) { + this.ipAddressAllocationMode = ipAddressAllocationMode; + return this; + } + + /** + * @see NetworkConnection#getNetwork() + */ + public Builder network(String network) { + this.network = network; + return this; + } + + /** + * @see NetworkConnection#needsCustomization() + */ + public Builder needsCustomization(Boolean needsCustomization) { + this.needsCustomization = needsCustomization; + return this; + } + + + public NetworkConnection build() { + return new NetworkConnection(networkConnectionIndex, ipAddress, externalIpAddress, isConnected, + macAddress, ipAddressAllocationMode, network, needsCustomization); + } + + + public Builder fromNetworkConnection(NetworkConnection in) { + return networkConnectionIndex(in.getNetworkConnectionIndex()) + .ipAddress(in.getIpAddress()) + .externalIpAddress(in.getExternalIpAddress()) + .isConnected(in.isConnected()) + .macAddress(in.getMACAddress()) + .ipAddressAllocationMode(in.getIpAddressAllocationMode()) + .network(in.getNetwork()) + .needsCustomization(in.needsCustomization()); + } + } + + public NetworkConnection(int networkConnectionIndex, String ipAddress, String externalIpAddress, boolean connected, + String macAddress, String ipAddressAllocationMode, String network, Boolean needsCustomization) { + this.networkConnectionIndex = networkConnectionIndex; + this.ipAddress = ipAddress; + this.externalIpAddress = externalIpAddress; + isConnected = connected; + this.macAddress = macAddress; + this.ipAddressAllocationMode = ipAddressAllocationMode; + this.network = network; + this.needsCustomization = needsCustomization; + } + + private NetworkConnection() { + // For JAXB and builder use + } + + + @XmlElement(name = "NetworkConnectionIndex") + protected int networkConnectionIndex; + @XmlElement(name = "IpAddress") + protected String ipAddress; + @XmlElement(name = "ExternalIpAddress") + protected String externalIpAddress; + @XmlElement(name = "IsConnected") + protected boolean isConnected; + @XmlElement(name = "MACAddress") + protected String macAddress; + @XmlElement(name = "IpAddressAllocationMode", required = true) + protected String ipAddressAllocationMode; + @XmlAttribute(required = true) + protected String network; + @XmlAttribute + protected Boolean needsCustomization; + + /** + * Gets the value of the networkConnectionIndex property. + */ + public int getNetworkConnectionIndex() { + return networkConnectionIndex; + } + + /** + * Gets the value of the ipAddress property. + * + * @return possible object is + * {@link String } + */ + public String getIpAddress() { + return ipAddress; + } + + /** + * Gets the value of the externalIpAddress property. + * + * @return possible object is + * {@link String } + */ + public String getExternalIpAddress() { + return externalIpAddress; + } + + /** + * Gets the value of the isConnected property. + */ + public boolean isConnected() { + return isConnected; + } + + /** + * Gets the value of the macAddress property. + * + * @return possible object is + * {@link String } + */ + public String getMACAddress() { + return macAddress; + } + + /** + * Gets the value of the ipAddressAllocationMode property. + * + * @return possible object is + * {@link String } + */ + public String getIpAddressAllocationMode() { + return ipAddressAllocationMode; + } + + /** + * Gets the value of the network property. + * + * @return possible object is + * {@link String } + */ + public String getNetwork() { + return network; + } + + /** + * Gets the value of the needsCustomization property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean needsCustomization() { + return needsCustomization; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkConnection that = NetworkConnection.class.cast(o); + return equal(networkConnectionIndex, that.networkConnectionIndex) && + equal(ipAddress, that.ipAddress) && + equal(externalIpAddress, that.externalIpAddress) && + equal(isConnected, that.isConnected) && + equal(macAddress, that.macAddress) && + equal(ipAddressAllocationMode, that.ipAddressAllocationMode) && + equal(network, that.network) && + equal(needsCustomization, that.needsCustomization); + } + + @Override + public int hashCode() { + return Objects.hashCode(networkConnectionIndex, + ipAddress, + externalIpAddress, + isConnected, + macAddress, + ipAddressAllocationMode, + network, + needsCustomization); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("networkConnectionIndex", networkConnectionIndex) + .add("ipAddress", ipAddress) + .add("externalIpAddress", externalIpAddress) + .add("isConnected", isConnected) + .add("macAddress", macAddress) + .add("ipAddressAllocationMode", ipAddressAllocationMode) + .add("network", network) + .add("needsCustomization", needsCustomization).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java new file mode 100644 index 0000000000..ce7d5b535e --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java @@ -0,0 +1,279 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents a list of network cards existing in a VM. + *

+ *

+ *

Java class for NetworkConnectionSection complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="NetworkConnectionSection">
+ *   <complexContent>
+ *     <extension base="{http://schemas.dmtf.org/ovf/envelope/1}Section_Type">
+ *       <sequence>
+ *         <element name="PrimaryNetworkConnectionIndex" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
+ *         <element name="NetworkConnection" type="{http://www.vmware.com/vcloud/v1.5}NetworkConnectionType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="Link" type="{http://www.vmware.com/vcloud/v1.5}LinkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="href" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlRootElement(name = "NetworkConnectionSection") +@XmlType(propOrder = { + "primaryNetworkConnectionIndex", + "networkConnections", + "links" +}) +public class NetworkConnectionSection extends SectionType { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkConnectionSection(this); + } + + public static class Builder extends SectionType.Builder { + + private Integer primaryNetworkConnectionIndex; + private Set networkConnection = Sets.newLinkedHashSet(); + private Set links = Sets.newLinkedHashSet(); + private URI href; + private String type; + + /** + * @see NetworkConnectionSection#getPrimaryNetworkConnectionIndex() + */ + public Builder primaryNetworkConnectionIndex(Integer primaryNetworkConnectionIndex) { + this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex; + return this; + } + + /** + * @see NetworkConnectionSection#getNetworkConnections() + */ + public Builder networkConnection(Set networkConnection) { + this.networkConnection = checkNotNull(networkConnection, "networkConnection"); + return this; + } + + /** + * @see NetworkConnectionSection#getLinks() + */ + public Builder links(Set links) { + this.links = checkNotNull(links, "links"); + return this; + } + + /** + * @see NetworkConnectionSection#getHref() + */ + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see NetworkConnectionSection#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + + public NetworkConnectionSection build() { + return new NetworkConnectionSection(info, required, primaryNetworkConnectionIndex, networkConnection, links, href, type); + + } + + public Builder fromNetworkConnectionSection(NetworkConnectionSection in) { + return fromSection(in) + .primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex()) + .networkConnection(in.getNetworkConnections()) + .links(in.getLinks()) + .href(in.getHref()) + .type(in.getType()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromSection(SectionType in) { + return Builder.class.cast(super.fromSection(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder info(String info) { + return Builder.class.cast(super.info(info)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder required(Boolean required) { + return Builder.class.cast(super.required(required)); + } + + } + + private NetworkConnectionSection(@Nullable String info, @Nullable Boolean required, Integer primaryNetworkConnectionIndex, + Set networkConnections, Set links, URI href, String type) { + super(info, required); + this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex; + this.networkConnections = ImmutableSet.copyOf(networkConnections); + this.links = ImmutableSet.copyOf(links); + this.href = href; + this.type = type; + } + + private NetworkConnectionSection() { + // For JAXB + } + + @XmlElement(name = "PrimaryNetworkConnectionIndex") + protected Integer primaryNetworkConnectionIndex; + @XmlElement(name = "NetworkConnection") + protected Set networkConnections = Sets.newLinkedHashSet(); + @XmlElement(name = "Link") + protected Set links = Sets.newLinkedHashSet(); + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected URI href; + @XmlAttribute + protected String type; + + /** + * Gets the value of the primaryNetworkConnectionIndex property. + * + * @return possible object is + * {@link Integer } + */ + public Integer getPrimaryNetworkConnectionIndex() { + return primaryNetworkConnectionIndex; + } + + /** + * Gets the value of the networkConnection property. + *

+ * Objects of the following type(s) are allowed in the list + * {@link NetworkConnection } + */ + public Set getNetworkConnections() { + return this.networkConnections; + } + + /** + * Gets the value of the link property. + *

+ * Objects of the following type(s) are allowed in the list + * {@link Link } + */ + public Set getLinks() { + return this.links; + } + + /** + * @return the value of the href property. + */ + public URI getHref() { + return href; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkConnectionSection that = NetworkConnectionSection.class.cast(o); + return super.equals(that) && + equal(primaryNetworkConnectionIndex, that.primaryNetworkConnectionIndex) && + equal(networkConnections, that.networkConnections) && + equal(links, that.links) && + equal(href, that.href) && + equal(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hashCode(primaryNetworkConnectionIndex, + networkConnections, + links, + href, + type); + } + + @Override + public Objects.ToStringHelper string() { + return super.string() + .add("primaryNetworkConnectionIndex", primaryNetworkConnectionIndex) + .add("networkConnection", networkConnections) + .add("links", links) + .add("href", href) + .add("type", type); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java index f49ef80f9e..e8b3c3ffed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java @@ -20,10 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -33,10 +31,10 @@ import com.google.common.collect.Sets; /** * Represents features of a network. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Features") +@XmlRootElement(name = "Features") public class NetworkFeatures { public static Builder builder() { @@ -68,9 +66,7 @@ public class NetworkFeatures { } public NetworkFeatures build() { - NetworkFeatures networkFeatures = new NetworkFeatures(); - networkFeatures.setNetworkServices(services); - return networkFeatures; + return new NetworkFeatures(services); } public Builder fromNetworkFeatures(NetworkFeatures in) { @@ -82,20 +78,20 @@ public class NetworkFeatures { // For JAXB and builder use } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "NetworkService") + public NetworkFeatures(Set services) { + this.services = services; + } + + @XmlElement(name = "NetworkService") private Set services = Sets.newLinkedHashSet(); /** - * @return a Network service. May be any of DhcpService, NatService, IpsecVpnService, - * DhcpService, or StaticRoutingService. + * @return a Network service. May be any of DhcpService, NatService, IpsecVpnService, + * DhcpService, or StaticRoutingService. */ public Set getNetworkServices() { return ImmutableSet.copyOf(services); } - - public void setNetworkServices(Set services) { - this.services = Sets.newLinkedHashSet(checkNotNull(services, "services")); - } @Override public boolean equals(Object o) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java index c5321ac165..56111c741d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -28,10 +27,10 @@ import com.google.common.base.Objects; /** * Represents a network service - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "NetworkService") +@XmlRootElement(name = "NetworkService") public class NetworkService { public static Builder builder() { @@ -55,9 +54,7 @@ public class NetworkService { } public NetworkService build() { - NetworkService networkService = new NetworkService(); - networkService.setEnabled(isEnabled); - return networkService; + return new NetworkService(isEnabled); } public Builder fromNetworkService(NetworkService in) { @@ -65,11 +62,15 @@ public class NetworkService { } } + private NetworkService(boolean enabled) { + isEnabled = enabled; + } + private NetworkService() { // For JAXB and builder use } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IsEnabled") + @XmlElement(name = "IsEnabled") private boolean isEnabled; /** @@ -78,10 +79,6 @@ public class NetworkService { public boolean isEnabled() { return isEnabled; } - - public void setEnabled(boolean isEnabled) { - this.isEnabled = isEnabled; - } @Override public boolean equals(Object o) { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java index 528a30f825..54052b9b18 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -32,9 +30,9 @@ import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "NetworkType") +@XmlRootElement(name = "NetworkType") public class NetworkType> extends EntityType { - + public static > Builder builder() { return new Builder(); } @@ -47,7 +45,7 @@ public class NetworkType> extends EntityType { public static class Builder> extends EntityType.Builder { protected NetworkConfiguration networkConfiguration; - + /** * @see NetworkType#getConfiguration() */ @@ -55,17 +53,10 @@ public class NetworkType> extends EntityType { this.networkConfiguration = networkConfiguration; return this; } - + @Override public NetworkType build() { - NetworkType network = new NetworkType(href, name); - network.setConfiguration(networkConfiguration); - network.setDescription(description); - network.setId(id); - network.setType(type); - network.setLinks(links); - network.setTasksInProgress(tasksInProgress); - return network; + return new NetworkType(href, type, links, description, tasksInProgress, id, name, networkConfiguration); } /** @@ -123,7 +114,7 @@ public class NetworkType> extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -132,7 +123,7 @@ public class NetworkType> extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -154,15 +145,17 @@ public class NetworkType> extends EntityType { } } + public NetworkType(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, + String id, String name, NetworkConfiguration networkConfiguration) { + super(href, type, links, description, tasksInProgress, id, name); + this.networkConfiguration = networkConfiguration; + } + protected NetworkType() { // For JAXB and builder use } - - protected NetworkType(URI href, String name) { - super(href, name); - } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Configuration") + @XmlElement(name = "Configuration") private NetworkConfiguration networkConfiguration; /** @@ -171,11 +164,7 @@ public class NetworkType> extends EntityType { public NetworkConfiguration getConfiguration() { return networkConfiguration; } - - public void setConfiguration(NetworkConfiguration networkConfiguration) { - this.networkConfiguration = networkConfiguration; - } - + @Override public boolean equals(Object o) { if (!super.equals(o)) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java index afcd87cb23..6c2713d061 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Org.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -36,18 +34,18 @@ import com.google.common.collect.Sets; /** * iRepresents an organization. - * + *

* Unit of multi-tenancy and a top-level container. Contain vDCs, TasksList, Catalogs and Shared Network entities. - * + *

*

  * <xs:complexType name="OrgType">
  * 
* * @author Adrian Cole */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Org") +@XmlRootElement(name = "Org") public class Org extends EntityType { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.ORG; @SuppressWarnings("unchecked") @@ -99,14 +97,7 @@ public class Org extends EntityType { @Override public Org build() { - Org org = new Org(href, name, fullName); - org.setDescription(description); - org.setId(id); - org.setType(type); - org.setLinks(links); - org.setTasksInProgress(tasksInProgress); - org.setIsEnabled(isEnabled); - return org; + return new Org(href, type, links, description, tasksInProgress, id, name, fullName, isEnabled); } /** @@ -164,7 +155,7 @@ public class Org extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -173,7 +164,7 @@ public class Org extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -195,14 +186,15 @@ public class Org extends EntityType { // For JAXB and builder use } - private Org(URI href, String name, String fullName) { - super(href, name); + public Org(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, String name, String fullName, Boolean enabled) { + super(href, type, links, description, tasksInProgress, id, name); this.fullName = fullName; + isEnabled = enabled; } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "FullName", required = true) + @XmlElement(name = "FullName", required = true) private String fullName; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "IsEnabled") + @XmlElement(name = "IsEnabled") private Boolean isEnabled; /** @@ -219,10 +211,6 @@ public class Org extends EntityType { return isEnabled; } - public void setIsEnabled(Boolean isEnabled) { - this.isEnabled = isEnabled; - } - @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java index 827ffc0529..1c74e8bace 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java @@ -20,10 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -35,12 +33,12 @@ import com.google.common.collect.Sets; /** * A list of organizations. - * + * * @author Adrian Cole */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "OrgList") +@XmlRootElement(name = "OrgList") public class OrgList { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.ORG_LIST; public static Builder builder() { @@ -88,7 +86,7 @@ public class OrgList { this.orgs = ImmutableSet.copyOf(orgs); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Org") + @XmlElement(name = "Org") private Set orgs = Sets.newLinkedHashSet(); public Set getOrgs() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java index 3e56987900..c2d841ffbe 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java @@ -20,11 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -32,9 +30,9 @@ import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "OrgNetwork") +@XmlRootElement(name = "OrgNetwork") public class OrgNetwork extends NetworkType { - + @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); @@ -49,7 +47,7 @@ public class OrgNetwork extends NetworkType { private ReferenceType networkPool; private IpAddresses allowedExternalIpAddresses; - + /** * @see OrgNetwork#getNetworkPool() */ @@ -65,21 +63,13 @@ public class OrgNetwork extends NetworkType { this.allowedExternalIpAddresses = allowedExternalIpAddresses; return this; } - + @Override public OrgNetwork build() { - OrgNetwork network = new OrgNetwork(href, name); - network.setConfiguration(networkConfiguration); - network.setNetworkPool(networkPool); - network.setAllowedExternalIpAddresses(allowedExternalIpAddresses); - network.setDescription(description); - network.setId(id); - network.setType(type); - network.setLinks(links); - network.setTasksInProgress(tasksInProgress); - return network; + return new OrgNetwork(href, type, links, description, tasksInProgress, id, name, networkConfiguration, + networkPool, allowedExternalIpAddresses); } - + /** * @see NetworkType#getConfiguration() */ @@ -143,7 +133,7 @@ public class OrgNetwork extends NetworkType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -152,7 +142,7 @@ public class OrgNetwork extends NetworkType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -173,16 +163,19 @@ public class OrgNetwork extends NetworkType { } private OrgNetwork() { - // For JAXB and builder use - } - - private OrgNetwork(URI href, String name) { - super(href, name); + // For JAXB } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "NetworkPool") + private OrgNetwork(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, + String id, String name, NetworkConfiguration networkConfiguration, ReferenceType networkPool, IpAddresses allowedExternalIpAddresses) { + super(href, type, links, description, tasksInProgress, id, name, networkConfiguration); + this.networkPool = networkPool; + this.allowedExternalIpAddresses = allowedExternalIpAddresses; + } + + @XmlElement(name = "NetworkPool") private ReferenceType networkPool; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "AllowedExternalIpAddresses") + @XmlElement(name = "AllowedExternalIpAddresses") private IpAddresses allowedExternalIpAddresses; /** @@ -191,28 +184,20 @@ public class OrgNetwork extends NetworkType { public ReferenceType getNetworkPool() { return networkPool; } - - public void setNetworkPool(ReferenceType networkPool) { - this.networkPool = networkPool; - } - + /** * @return optional network pool */ public IpAddresses getAllowedExternalIpAddresses() { return allowedExternalIpAddresses; } - - public void setAllowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) { - this.allowedExternalIpAddresses = allowedExternalIpAddresses; - } - + @Override public boolean equals(Object o) { if (!super.equals(o)) return false; OrgNetwork that = OrgNetwork.class.cast(o); - return super.equals(that) && equal(networkPool, that.networkPool) && + return super.equals(that) && equal(networkPool, that.networkPool) && equal(allowedExternalIpAddresses, that.allowedExternalIpAddresses); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java index 88e392cfd3..b20e2fdee4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Owner.java @@ -24,9 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @@ -36,14 +33,13 @@ import com.google.common.collect.Sets; /** - * - * Represents the owner of this entity. - * - * + * Represents the owner of this entity. + *

+ *

*

Java class for Owner complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType name="Owner">
  *   <complexContent>
@@ -56,14 +52,11 @@ import com.google.common.collect.Sets;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ -@XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "Owner") @XmlType(propOrder = {"user"}) public class Owner - extends ResourceType + extends ResourceType { @SuppressWarnings("unchecked") @@ -71,12 +64,13 @@ public class Owner return new Builder(); } + @Override public Builder toBuilder() { return new Builder().fromOwner(this); } public static class Builder extends ResourceType.Builder { - + private Reference user; /** @@ -89,12 +83,9 @@ public class Owner public Owner build() { - Owner owner = new Owner(); - owner.setUser(user); - return owner; + return new Owner(href, type, links, user); } - /** * @see ResourceType#getHref() */ @@ -134,11 +125,12 @@ public class Owner @Override public Builder fromResourceType(ResourceType in) { - return Builder.class.cast(super.fromResourceType(in)); + return Builder.class.cast(super.fromResourceType(in)); } + public Builder fromOwner(Owner in) { return fromResourceType(in) - .user(in.getUser()); + .user(in.getUser()); } } @@ -146,39 +138,28 @@ public class Owner // For JAXB and builder use } + public Owner(URI href, String type, Set links, Reference user) { + super(href, type, links); + this.user = user; + } + @XmlElement(name = "User", required = true) + protected Reference user; - @XmlElement(name = "User", required = true) - protected Reference user; - - /** - * Gets the value of the user property. - * - * @return - * possible object is - * {@link Reference } - * - */ - public Reference getUser() { - return user; - } - - /** - * Sets the value of the user property. - * - * @param value - * allowed object is - * {@link Reference } - * - */ - public void setUser(Reference value) { - this.user = value; - } + /** + * Gets the value of the user property. + * + * @return possible object is + * {@link Reference } + */ + public Reference getUser() { + return user; + } @Override public boolean equals(Object o) { if (this == o) - return true; + return true; if (o == null || getClass() != o.getClass()) return false; Owner that = Owner.class.cast(o); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java new file mode 100644 index 0000000000..98aaea6fed --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java @@ -0,0 +1,167 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * A basic type used to specify parameters for operations. + *

+ *

+ *

Java class for Params complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="Params">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "Params", propOrder = { + "description" +}) +@XmlSeeAlso({ + CaptureVAppParams.class, + CloneVAppTemplateParams.class, + CloneMediaParams.class, + UploadVAppTemplateParams.class +//, ImportVmAsVAppTemplateParams.class, +// ImportMediaParams.class, +// UpdateResourcePoolSetParams.class, +// VAppCreationParams.class +}) +public class ParamsType> { + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromParamsType(this); + } + + public static class Builder> { + + protected String description; + protected String name; + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + + public ParamsType build() { + return new ParamsType(description, name); + } + + public Builder fromParamsType(ParamsType in) { + return description(in.getDescription()) + .name(in.getName()); + } + } + + protected ParamsType(String description, String name) { + this.description = description; + this.name = name; + } + + protected ParamsType() { + // For JAXB and builder use + } + + + @XmlElement(name = "Description") + protected String description; + @XmlAttribute + protected String name; + + /** + * Gets the value of the description property. + * + * @return possible object is + * {@link String } + */ + public String getDescription() { + return description; + } + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ParamsType that = ParamsType.class.cast(o); + return equal(description, that.description) && + equal(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hashCode(description, + name); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("description", description) + .add("name", name).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java new file mode 100644 index 0000000000..d5cd569e17 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java @@ -0,0 +1,181 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Essentially a container with a list of product sections. + *

+ *

Java class for ProductSectionList complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="ProductSectionList">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ResourceType">
+ *       <sequence>
+ *         <element ref="{http://schemas.dmtf.org/ovf/envelope/1}ProductSection" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "ProductSectionList", propOrder = { + "productSection" +}) +public class ProductSectionList + extends ResourceType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromProductSectionList(this); + } + + public static class Builder extends ResourceType.Builder { + + private Set productSections = Sets.newLinkedHashSet(); + + /** + * @see ProductSectionList#getProductSection() + */ + public Builder productSection(Set productSections) { + this.productSections = checkNotNull(productSections, "productSection"); + return this; + } + + + public ProductSectionList build() { + ProductSectionList productSectionList = new ProductSectionList(productSections); + return productSectionList; + } + + + /** + * @see ResourceType#getHref() + */ + @Override + public Builder href(URI href) { + super.href(href); + return this; + } + + /** + * @see ResourceType#getType() + */ + @Override + public Builder type(String type) { + super.type(type); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder links(Set links) { + super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); + return this; + } + + /** + * @see ResourceType#getLinks() + */ + @Override + public Builder link(Link link) { + super.link(link); + return this; + } + + + @Override + public Builder fromResourceType(ResourceType in) { + return Builder.class.cast(super.fromResourceType(in)); + } + + public Builder fromProductSectionList(ProductSectionList in) { + return fromResourceType(in) + .productSection(in.getProductSection()); + } + } + + private ProductSectionList() { + // For JAXB and builder use + } + + private ProductSectionList(Set productSection) { + this.productSection = ImmutableSet.copyOf(productSection); + } + + + @XmlElement(name = "ProductSection", namespace = "http://schemas.dmtf.org/ovf/envelope/1") + protected Set productSection = Sets.newLinkedHashSet(); + + /** + * Gets the value of the productSection property. + */ + public Set getProductSection() { + return this.productSection; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ProductSectionList that = ProductSectionList.class.cast(o); + return equal(productSection, that.productSection); + } + + @Override + public int hashCode() { + return Objects.hashCode(productSection); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("productSection", productSection).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java index a6c01018b9..6d73e4ba74 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Property.java @@ -18,10 +18,6 @@ */ package org.jclouds.vcloud.director.v1_5.domain; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; @@ -30,15 +26,14 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; /** * Contains key/value pair as property. - * + *

*

  * <complexType name="PropertyType" />
  * 
* * @author grkvlt@apache.org */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Property") +@XmlRootElement(name = "Property") public class Property { public static final String MEDIA_TYPE = VCloudDirectorMediaType.PROPERTY; @@ -83,9 +78,7 @@ public class Property { } public Property build() { - Property property = new Property(key); - property.setValue(value); - return property; + return new Property(key, value); } public Builder fromProperty(Property in) { @@ -94,10 +87,11 @@ public class Property { } private Property() { - // For JAXB and builder use + // For JAXB } - private Property(String key) { + private Property(String key, String value) { + this.value = value; this.key = key; } @@ -113,10 +107,6 @@ public class Property { return value; } - public void setValue(String value) { - this.value = value; - } - /** * Gets the value of the key property. */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java index 1e3af67113..e055bb5264 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Reference.java @@ -22,7 +22,7 @@ import java.net.URI; /** * A reference to a resource. - * + * * @author grkvlt@apache.org */ public class Reference extends ReferenceType { @@ -41,11 +41,7 @@ public class Reference extends ReferenceType { @Override public Reference build() { - Reference reference = new Reference(href); - reference.setId(id); - reference.setName(name); - reference.setType(type); - return reference; + return new Reference(href, id, name, type); } /** @@ -94,8 +90,8 @@ public class Reference extends ReferenceType { } } - protected Reference(URI href) { - super(href); + public Reference(URI href, String id, String name, String type) { + super(href, id, name, type); } protected Reference() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java index bbed73839b..f6a340cdc3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ReferenceType.java @@ -22,9 +22,6 @@ import static com.google.common.base.Objects.equal; import java.net.URI; import java.util.Map; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import com.google.common.base.Objects; @@ -32,16 +29,15 @@ import com.google.common.base.Objects.ToStringHelper; /** * A reference to a resource. - * + *

* Contains an href attribute and optional name and type attributes. - * + *

*

  * <xs:complexType name="ReferenceType">
  * 
- * + * * @author grkvlt@apache.org */ -@XmlAccessorType(XmlAccessType.FIELD) public class ReferenceType> implements URISupplier { public static > Builder builder() { @@ -92,11 +88,7 @@ public class ReferenceType> implements URISupplier { } public ReferenceType build() { - ReferenceType reference = new ReferenceType(href); - reference.setId(id); - reference.setName(name); - reference.setType(type); - return reference; + return new ReferenceType(href, id, name, type); } protected Builder fromReferenceType(ReferenceType in) { @@ -117,8 +109,11 @@ public class ReferenceType> implements URISupplier { @XmlAttribute private String type; - protected ReferenceType(URI href) { + protected ReferenceType(URI href, String id, String name, String type) { this.href = href; + this.id = id; + this.name = name; + this.type = type; } protected ReferenceType() { @@ -127,7 +122,7 @@ public class ReferenceType> implements URISupplier { /** * Contains the URI to the entity. - * + *

* An object reference, expressed in URL format. Because this URL includes the object identifier * portion of the id attribute value, it uniquely identifies the object, persists for the life of * the object, and is never reused. The value of the href attribute is a reference to a view of @@ -135,7 +130,7 @@ public class ReferenceType> implements URISupplier { * particular context. Although URLs have a well-known syntax and a well-understood * interpretation, a client should treat each href as an opaque string. The rules that govern how * the server constructs href strings might change in future releases. - * + * * @return an opaque reference and should never be parsed */ public URI getHref() { @@ -144,7 +139,7 @@ public class ReferenceType> implements URISupplier { /** * The resource identifier, expressed in URN format. - * + *

* The value of this attribute uniquely identifies the resource, persists for the life of the * resource, and is never reused. */ @@ -152,42 +147,30 @@ public class ReferenceType> implements URISupplier { return id; } - public void setId(String id) { - this.id = id; - } - /** * Contains the name of the the entity. - * + *

* The object type, specified as a MIME content type, of the object that the link references. * This attribute is present only for links to objects. It is not present for links to actions. - * + * * @return type definition, type, expressed as an HTTP Content-Type */ public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - /** * Contains the type of the the entity. - * + *

* The object type, specified as a MIME content type, of the object that the link references. * This attribute is present only for links to objects. It is not present for links to actions. - * + * * @return type definition, type, expressed as an HTTP Content-Type */ public String getType() { return type; } - public void setType(String type) { - this.type = type; - } - /** * @see URISupplier#getURI() */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java new file mode 100644 index 0000000000..aeb036e2c5 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java @@ -0,0 +1,63 @@ +/** + * 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.domain; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * Parameters to be used for vm relocation. + *

+ *

+ *

Java class for RelocateParams complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="RelocateParams">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Datastore" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "RelocateParams", propOrder = { + "datastore" +}) +public class RelocateParams { + + @XmlElement(name = "Datastore", required = true) + protected ReferenceType datastore; + + /** + * Gets the value of the datastore property. + * + * @return possible object is + * {@link ReferenceType } + */ + public ReferenceType getDatastore() { + return datastore; + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java index b380e200e0..61e0d5ea15 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Resource.java @@ -27,12 +27,11 @@ import com.google.common.collect.Sets; /** * A resource. - * + * * @author grkvlt@apache.org */ public class Resource extends ResourceType { - @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } @@ -46,10 +45,7 @@ public class Resource extends ResourceType { @Override public Resource build() { - Resource reference = new Resource(href); - reference.setType(type); - reference.setLinks(links); - return reference; + return new Resource(href, type, links); } /** @@ -98,11 +94,11 @@ public class Resource extends ResourceType { } } - protected Resource(URI href) { - super(href); + private Resource(URI href, String type, Set links) { + super(href, type, links); } - protected Resource() { + private Resource() { // For JAXB } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java new file mode 100644 index 0000000000..6bcf21db4d --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java @@ -0,0 +1,137 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents a list of references to resource entities. + *

+ *

+ *

Java class for ResourceEntities complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="ResourceEntities">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="ResourceEntity" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "ResourceEntities", propOrder = { + "resourceEntities" +}) +public class ResourceEntities { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromResourceEntities(this); + } + + public static class Builder { + + private Set resourceEntities = Sets.newLinkedHashSet(); + + /** + * @see ResourceEntities#getResourceEntities() + */ + public Builder resourceEntities(Set resourceEntities) { + this.resourceEntities = checkNotNull(resourceEntities, "resourceEntities"); + return this; + } + + /** + * @see ResourceEntities#getResourceEntities() + */ + public Builder resourceEntity(Reference resourceEntity) { + resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity")); + return this; + } + + public ResourceEntities build() { + return new ResourceEntities(this.resourceEntities); + } + + + public Builder fromResourceEntities(ResourceEntities in) { + return resourceEntities(in.getResourceEntities()); + } + } + + private ResourceEntities() { + // For JAXB and builder use + } + + private ResourceEntities(Set resourceEntity) { + this.resourceEntities = ImmutableSet.copyOf(resourceEntity); + } + + + @XmlElement(name = "ResourceEntity") + private Set resourceEntities = Sets.newLinkedHashSet(); + + /** + * Gets the value of the resourceEntity property. + */ + public Set getResourceEntities() { + return this.resourceEntities; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ResourceEntities that = ResourceEntities.class.cast(o); + return equal(resourceEntities, that.resourceEntities); + } + + @Override + public int hashCode() { + return Objects.hashCode(resourceEntities); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("resourceEntity", resourceEntities).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java index d72a21523c..78afcce32f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntityType.java @@ -24,7 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; - import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -34,28 +33,19 @@ import com.google.common.collect.Sets; /** * Base type that represents a resource entity such as a vApp template or virtual media. - * + *

*

  * <complexType name="ResourceEntity" >
  * 
- * + * * @author danikov + * @author Adam Lowe */ -public class ResourceEntityType> extends EntityType { +public abstract class ResourceEntityType> extends EntityType { - public static > Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return new Builder().fromResourceEntityType(this); - } - - public static class Builder> extends EntityType.Builder { - - private FilesList files; - private Integer status; + public static abstract class Builder> extends EntityType.Builder { + protected FilesList files; + protected Integer status; /** * @see ResourceEntityType#getFiles() @@ -73,14 +63,6 @@ public class ResourceEntityType> extends EntityT return this; } - @Override - public ResourceEntityType build() { - ResourceEntityType resourceEntity = new ResourceEntityType(); - resourceEntity.setFiles(files); - resourceEntity.setStatus(status); - return resourceEntity; - } - /** * @see EntityType#getId() */ @@ -118,7 +100,7 @@ public class ResourceEntityType> extends EntityT } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -127,7 +109,7 @@ public class ResourceEntityType> extends EntityT } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -135,6 +117,7 @@ public class ResourceEntityType> extends EntityT return this; } + @SuppressWarnings("unchecked") @Override public Builder fromResourceType(ResourceType in) { return Builder.class.cast(super.fromResourceType(in)); @@ -145,15 +128,22 @@ public class ResourceEntityType> extends EntityT } } - public ResourceEntityType() { - // for JAXB - } - @XmlElement(name = "Files") protected FilesList files; @XmlAttribute protected Integer status; + public ResourceEntityType(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, String name, FilesList files, Integer status) { + super(href, type, links, description, tasksInProgress, id, name); + this.files = files; + this.status = status; + } + + protected ResourceEntityType() { + // for JAXB + } + + /** * Gets the value of the files property. */ @@ -161,10 +151,6 @@ public class ResourceEntityType> extends EntityT return files; } - public void setFiles(FilesList value) { - this.files = value; - } - /** * Gets the value of the status property. */ @@ -172,10 +158,6 @@ public class ResourceEntityType> extends EntityT return status; } - public void setStatus(Integer value) { - this.status = value; - } - @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java index bb61f6ffc3..a4d5745ff2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java @@ -20,13 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -36,27 +32,20 @@ import com.google.common.collect.Sets; /** * The base type for all objects in the vCloud model. - * + *

* Has an optional list of links and href and type attributes. - * + *

*

  * <xs:complexType name="ResourceType">
  * 
- * + * * @author Adrian Cole */ -@XmlAccessorType(XmlAccessType.FIELD) -public class ResourceType> implements URISupplier { +public abstract class ResourceType> implements URISupplier { - public static > Builder builder() { - return new Builder(); - } + public abstract Builder toBuilder(); - public Builder toBuilder() { - return new Builder().fromResourceType(this); - } - - public static class Builder> { + public static abstract class Builder> { protected URI href; protected String type; @@ -94,12 +83,7 @@ public class ResourceType> implements URISupplier { return this; } - public ResourceType build() { - ResourceType reference = new ResourceType(href); - reference.setType(type); - reference.setLinks(links); - return reference; - } + public abstract ResourceType build(); protected Builder fromResourceType(ResourceType in) { return href(in.getHref()).type(in.getType()).links(in.getLinks()); @@ -110,11 +94,13 @@ public class ResourceType> implements URISupplier { private URI href; @XmlAttribute private String type; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Link") + @XmlElement(name = "Link") private Set links = Sets.newLinkedHashSet(); - protected ResourceType(URI href) { + protected ResourceType(URI href, String type, Set links) { this.href = href; + this.type = type; + this.links = links; } protected ResourceType() { @@ -123,7 +109,7 @@ public class ResourceType> implements URISupplier { /** * Contains the URI to the entity. - * + *

* An object reference, expressed in URL format. Because this URL includes the object identifier * portion of the id attribute value, it uniquely identifies the object, persists for the life of * the object, and is never reused. The value of the href attribute is a reference to a view of @@ -131,7 +117,7 @@ public class ResourceType> implements URISupplier { * particular context. Although URLs have a well-known syntax and a well-understood * interpretation, a client should treat each href as an opaque string. The rules that govern how * the server constructs href strings might change in future releases. - * + * * @return an opaque reference and should never be parsed */ public URI getHref() { @@ -148,20 +134,16 @@ public class ResourceType> implements URISupplier { /** * Contains the type of the the entity. - * + *

* The object type, specified as a MIME content type, of the object that the link references. * This attribute is present only for links to objects. It is not present for links to actions. - * + * * @return type definition, type, expressed as an HTTP Content-Type */ public String getType() { return type; } - public void setType(String type) { - this.type = type; - } - /** * Set of optional links to an entity or operation associated with this object. */ @@ -169,14 +151,6 @@ public class ResourceType> implements URISupplier { return links; } - public void setLinks(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - } - - public void addLink(Link link) { - this.links.add(checkNotNull(link, "link")); - } - @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java index 7ae387f1ca..29b32fb9e3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -28,10 +27,10 @@ import com.google.common.base.Objects; /** * Specifies router information. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "RouterInfo") +@XmlRootElement(name = "RouterInfo") public class RouterInfo { public static Builder builder() { return new Builder(); @@ -42,7 +41,7 @@ public class RouterInfo { } public static class Builder { - + private String externalIp; /** @@ -61,7 +60,7 @@ public class RouterInfo { return externalIp(in.getExternalIp()); } } - + private RouterInfo() { // For JAXB and builder use } @@ -69,18 +68,18 @@ public class RouterInfo { private RouterInfo(String externalIp) { this.externalIp = externalIp; } - - - @XmlElement(namespace = VCLOUD_1_5_NS, name = "ExternalIp") + + + @XmlElement(name = "ExternalIp") private String externalIp; - + /** * @return the external IP of the router. Applicable for NAT Routed / Fenced networks only. */ public String getExternalIp() { return externalIp; } - + @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java index 27e3f27dea..e72bd5797e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java @@ -20,13 +20,9 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -41,13 +37,12 @@ import com.google.common.collect.Sets; * Returns a representation of the current session that can serve as a single entry point to the * system, as it provides user, admin, and extension (sysadmin) entry links depending on the * privileges of the current user. - * + * * @author Adrian Cole */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Session") -@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "Session") public class Session { - + public static final String MEDIA_TYPE = VCloudDirectorMediaType.SESSION; public static Builder builder() { @@ -124,7 +119,7 @@ public class Session { this.links = ImmutableSet.copyOf(links); } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Link") + @XmlElement(name = "Link") private Set links = Sets.newLinkedHashSet(); @XmlAttribute private String user; @@ -138,7 +133,6 @@ public class Session { } /** - * * @return the user's login name. */ public String getUser() { @@ -146,7 +140,6 @@ public class Session { } /** - * * @return is the name of an organization of which the user is a member */ public String getOrg() { @@ -154,7 +147,6 @@ public class Session { } /** - * * @return a reference to the current session */ public URI getHref() { @@ -179,6 +171,6 @@ public class Session { @Override public String toString() { return Objects.toStringHelper("").add("user", user).add("org", org).add("href", href).add("links", links) - .toString(); + .toString(); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java index 98bfa1d05b..c3782614f2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SessionWithToken.java @@ -24,7 +24,7 @@ import com.google.common.base.Objects; /** * Session and its corresponding token - * + * * @author Adrian Cole */ public class SessionWithToken { @@ -95,7 +95,7 @@ public class SessionWithToken { * particular context. Although URLs have a well-known syntax and a well-understood * interpretation, a client should treat each token as an opaque string. The rules that govern * how the server constructs token strings might change in future releases. - * + * * @return an opaque reference and should never be parsed */ public String getToken() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java new file mode 100644 index 0000000000..d699a9096f --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java @@ -0,0 +1,257 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.Set; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + + +/** + * Represents a composition item. + *

+ *

+ *

Java class for SourcedCompositionItemParam complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="SourcedCompositionItemParam">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="VAppScopedLocalId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="InstantiationParams" type="{http://www.vmware.com/vcloud/v1.5}InstantiationParamsType" minOccurs="0"/>
+ *         <element name="NetworkAssignment" type="{http://www.vmware.com/vcloud/v1.5}NetworkAssignmentType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="sourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "SourcedCompositionItemParam", propOrder = { + "source", + "vAppScopedLocalId", + "instantiationParams", + "networkAssignment" +}) +public class SourcedCompositionItemParam { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromSourcedCompositionItemParam(this); + } + + public static class Builder { + + private Reference source; + private String vAppScopedLocalId; + private InstantiationParams instantiationParams; + private Set networkAssignments = Sets.newLinkedHashSet(); + private Boolean sourceDelete; + + /** + * @see SourcedCompositionItemParam#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see SourcedCompositionItemParam#getVAppScopedLocalId() + */ + public Builder vAppScopedLocalId(String vAppScopedLocalId) { + this.vAppScopedLocalId = vAppScopedLocalId; + return this; + } + + /** + * @see SourcedCompositionItemParam#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + this.instantiationParams = instantiationParams; + return this; + } + + /** + * @see SourcedCompositionItemParam#getNetworkAssignments() + */ + public Builder networkAssignments(Set networkAssignments) { + this.networkAssignments = networkAssignments; + return this; + } + + /** + * @see SourcedCompositionItemParam#isSourceDelete() + */ + public Builder sourceDelete(Boolean sourceDelete) { + this.sourceDelete = sourceDelete; + return this; + } + + public SourcedCompositionItemParam build() { + return new SourcedCompositionItemParam(source, vAppScopedLocalId, instantiationParams, networkAssignments, sourceDelete); + } + + public Builder fromSourcedCompositionItemParam(SourcedCompositionItemParam in) { + return source(in.getSource()) + .vAppScopedLocalId(in.getVAppScopedLocalId()) + .instantiationParams(in.getInstantiationParams()) + .networkAssignments(in.getNetworkAssignments()) + .sourceDelete(in.isSourceDelete()); + } + } + + public SourcedCompositionItemParam(Reference source, String vAppScopedLocalId, InstantiationParams instantiationParams, + Set networkAssignments, Boolean sourceDelete) { + this.source = source; + this.vAppScopedLocalId = vAppScopedLocalId; + this.instantiationParams = instantiationParams; + this.networkAssignments = ImmutableSet.copyOf(networkAssignments); + this.sourceDelete = sourceDelete; + } + + private SourcedCompositionItemParam() { + // For JAXB and builder use + } + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "VAppScopedLocalId") + protected String vAppScopedLocalId; + @XmlElement(name = "InstantiationParams") + protected InstantiationParams instantiationParams; + @XmlElement(name = "NetworkAssignment") + protected Set networkAssignments = Sets.newLinkedHashSet(); + @XmlAttribute + protected Boolean sourceDelete; + + /** + * Gets the value of the source property. + * + * @return possible object is + * {@link Reference } + */ + public Reference getSource() { + return source; + } + + + /** + * Gets the value of the vAppScopedLocalId property. + * + * @return possible object is + * {@link String } + */ + public String getVAppScopedLocalId() { + return vAppScopedLocalId; + } + + /** + * Gets the value of the instantiationParams property. + * + * @return possible object is + * {@link InstantiationParams } + */ + public InstantiationParams getInstantiationParams() { + return instantiationParams; + } + + /** + * Gets the value of the networkAssignment property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the networkAssignment property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+    *    getNetworkAssignment().add(newItem);
+    * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link NetworkAssignment } + */ + public Set getNetworkAssignments() { + return this.networkAssignments; + } + + /** + * Gets the value of the sourceDelete property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isSourceDelete() { + return sourceDelete; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + SourcedCompositionItemParam that = SourcedCompositionItemParam.class.cast(o); + return equal(source, that.source) && + equal(vAppScopedLocalId, that.vAppScopedLocalId) && + equal(instantiationParams, that.instantiationParams) && + equal(networkAssignments, that.networkAssignments) && + equal(sourceDelete, that.sourceDelete); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + vAppScopedLocalId, + instantiationParams, + networkAssignments, + sourceDelete); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("vAppScopedLocalId", vAppScopedLocalId) + .add("instantiationParams", instantiationParams) + .add("networkAssignments", networkAssignments) + .add("sourceDelete", sourceDelete).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java new file mode 100644 index 0000000000..e74dea141f --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java @@ -0,0 +1,138 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Collections; +import java.util.Set; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.collect.Sets; + + +/** + * Represents a list of supported VM hardware versions. + *

+ *

+ *

Java class for SupportedHardwareVersions complex type. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="SupportedHardwareVersions">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="SupportedHardwareVersion" type="{http://www.vmware.com/vcloud/v1.5}SupportedHardwareVersionType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlType(name = "SupportedHardwareVersions", propOrder = { + "supportedHardwareVersions" +}) +public class SupportedHardwareVersions { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromSupportedHardwareVersions(this); + } + + public static class Builder { + + private Set supportedHardwareVersions = Sets.newLinkedHashSet(); + + /** + * @see SupportedHardwareVersions#getSupportedHardwareVersions() + */ + public Builder supportedHardwareVersions(Set supportedHardwareVersions) { + this.supportedHardwareVersions = Sets.newLinkedHashSet(checkNotNull(supportedHardwareVersions, "supportedHardwareVersions")); + return this; + } + + /** + * @see SupportedHardwareVersions#getSupportedHardwareVersions() + */ + public Builder supportedHardwareVersion(String supportedHardwareVersion) { + supportedHardwareVersions.add(checkNotNull(supportedHardwareVersion, "supportedHardwareVersion")); + return this; + } + + public SupportedHardwareVersions build() { + SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(this.supportedHardwareVersions); + return supportedHardwareVersions; + } + + + public Builder fromSupportedHardwareVersions(SupportedHardwareVersions in) { + return supportedHardwareVersions(in.getSupportedHardwareVersions()); + } + } + + private SupportedHardwareVersions() { + // For JAXB and builder use + } + + private SupportedHardwareVersions(Set supportedHardwareVersions) { + this.supportedHardwareVersions = supportedHardwareVersions; + } + + + @XmlElement(name = "SupportedHardwareVersion") + protected Set supportedHardwareVersions = Sets.newLinkedHashSet(); + + /** + * Gets the value of the supportedHardwareVersion property. + */ + public Set getSupportedHardwareVersions() { + return Collections.unmodifiableSet(supportedHardwareVersions); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + SupportedHardwareVersions that = SupportedHardwareVersions.class.cast(o); + return equal(supportedHardwareVersions, that.supportedHardwareVersions); + } + + @Override + public int hashCode() { + return Objects.hashCode(supportedHardwareVersions); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("supportedHardwareVersion", supportedHardwareVersions).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java index d2a2736ddd..ffbb8c536f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java @@ -19,23 +19,19 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; /** - * Syslog server settings. If logging is configured for firewall rules, the logs + * Syslog server settings. If logging is configured for firewall rules, the logs * will be directed to these syslog servers. - * + * * @author danikov */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerSettings") -@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "SyslogServerSettings") public class SyslogServerSettings { public static Builder builder() { @@ -47,7 +43,7 @@ public class SyslogServerSettings { } public static class Builder { - + private String syslogServerIp1; private String syslogServerIp2; @@ -78,38 +74,30 @@ public class SyslogServerSettings { return syslogServerIp1(in.getSyslogServerIp1()).syslogServerIp2(in.getSyslogServerIp2()); } } - + private SyslogServerSettings() { // For JAXB and builder use } - - @XmlElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerIp1") + + @XmlElement(name = "SyslogServerIp1") private String syslogServerIp1; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "SyslogServerIp2") + @XmlElement(name = "SyslogServerIp2") private String syslogServerIp2; - + /** * @return Primary syslog server. */ public String getSyslogServerIp1() { return syslogServerIp1; } - - public void setSyslogServerIp1(String syslogServerIp1) { - this.syslogServerIp1 = syslogServerIp1; - } - + /** * @return Secondary syslog server. */ public String getSyslogServerIp2() { return syslogServerIp2; } - - public void setSyslogServerIp2(String syslogServerIp2) { - this.syslogServerIp2 = syslogServerIp2; - } - + @Override public boolean equals(Object o) { if (this == o) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java index 25219f95d0..a791f8dcd8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Task.java @@ -20,14 +20,12 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import java.net.URI; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Set; - import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -40,34 +38,33 @@ import com.google.common.collect.Sets; /** * Represents an asynchronous or long-running task in the vCloud environment. - * + *

*

  * <xs:complexType name="TaskType">
  * 
* * @author grkvlt@apache.org */ -@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Task") +@XmlRootElement(name = "Task") public class Task extends EntityType { - - public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK; - - public static class Status { - public static final String QUEUED = "queued"; - public static final String PRE_RUNNING = "preRunning"; - public static final String RUNNING = "running"; - public static final String SUCCESS = "success"; - public static final String ERROR = "error"; - public static final String CANCELED = "canceled"; - public static final String ABORTED = "aborted"; - public static final List ALL = Arrays.asList( - QUEUED, PRE_RUNNING, RUNNING, SUCCESS, - ERROR, CANCELED, ABORTED - ); + public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK; + + public static class Status { + public static final String QUEUED = "queued"; + public static final String PRE_RUNNING = "preRunning"; + public static final String RUNNING = "running"; + public static final String SUCCESS = "success"; + public static final String ERROR = "error"; + public static final String CANCELED = "canceled"; + public static final String ABORTED = "aborted"; + + public static final List ALL = Arrays.asList( + QUEUED, PRE_RUNNING, RUNNING, SUCCESS, + ERROR, CANCELED, ABORTED + ); } - @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); } @@ -190,25 +187,8 @@ public class Task extends EntityType { @Override public Task build() { - Task task = new Task(href, name); - task.setDescription(description); - task.setTasksInProgress(tasksInProgress); - task.setId(id); - task.setType(type); - task.setLinks(links); - task.setError(error); - task.setOrg(org); - task.setOwner(owner); - task.setUser(user); - task.setParams(params); - task.setProgress(progress); - task.setStatus(status); - task.setOperation(operation); - task.setOperationName(operationName); - task.setStartTime(startTime); - task.setEndTime(endTime); - task.setExpiryTime(expiryTime); - return task; + return new Task(href, type, links, description, tasksInProgress, id, name, + error, org, progress, owner, user, params, status, operation, operationName, startTime, endTime, expiryTime); } /** @@ -266,7 +246,7 @@ public class Task extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder links(Set links) { @@ -275,7 +255,7 @@ public class Task extends EntityType { } /** - * @see ReferenceType#getLinks() + * @see EntityType#getLinks() */ @Override public Builder link(Link link) { @@ -290,30 +270,46 @@ public class Task extends EntityType { public Builder fromTask(Task in) { return fromEntityType(in) - .error(in.getError()).org(in.getOrg()).progress(in.getProgress()).status(in.getStatus()) - .operation(in.getOperation()).operationName(in.getOperationName()); + .error(in.getError()).org(in.getOrg()).progress(in.getProgress()).status(in.getStatus()) + .operation(in.getOperation()).operationName(in.getOperationName()); } } + public Task(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, + String id, String name, Error error, Reference org, Integer progress, Reference owner, + Reference user, Object params, String status, String operation, String operationName, + Date startTime, Date endTime, Date expiryTime) { + super(href, type, links, description, tasksInProgress, id, name); + this.error = error; + this.org = org; + this.progress = progress; + this.owner = owner; + this.user = user; + this.params = params; + this.status = status; + this.operation = operation; + this.operationName = operationName; + this.startTime = startTime; + this.endTime = endTime; + this.expiryTime = expiryTime; + } + private Task() { // For JAXB and builder use } - private Task(URI href, String name) { - super(href, name); - } - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Error") + @XmlElement(name = "Error") private Error error; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Organization") + @XmlElement(name = "Organization") private Reference org; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Progress") + @XmlElement(name = "Progress") private Integer progress; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Owner") + @XmlElement(name = "Owner") private Reference owner; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "User") + @XmlElement(name = "User") private Reference user; - @XmlElement(namespace = VCLOUD_1_5_NS, name = "Params") + @XmlElement(name = "Params") private Object params; @XmlAttribute private String status; @@ -327,7 +323,7 @@ public class Task extends EntityType { private Date endTime; @XmlAttribute private Date expiryTime; - + /** * Represents an error information if the task failed. */ @@ -335,10 +331,6 @@ public class Task extends EntityType { return error; } - public void setError(Error error) { - this.error = error; - } - /** * The organization that started the task. */ @@ -346,10 +338,6 @@ public class Task extends EntityType { return org; } - public void setOrg(Reference org) { - this.org = org; - } - /** * Reference to the owner of the task. */ @@ -357,10 +345,6 @@ public class Task extends EntityType { return owner; } - public void setOwner(Reference owner) { - this.owner = owner; - } - /** * The user who started the task. */ @@ -368,10 +352,6 @@ public class Task extends EntityType { return user; } - public void setUser(Reference user) { - this.user = user; - } - /** * The parameters with which this task has been run. */ @@ -379,13 +359,9 @@ public class Task extends EntityType { return params; } - public void setParams(Object params) { - this.params = params; - } - /** * The progress of a long running asynchronous task. - * + *

* The value is between 0 - 100. Not all tasks have progress, the value is not * present for task which progress is not available. */ @@ -393,13 +369,9 @@ public class Task extends EntityType { return progress; } - public void setProgress(Integer progress) { - this.progress = progress; - } - /** * The execution status of the task. - * + *

* One of: *