From 1b91cca8c17048de9525cff175b538aa2c7eb35a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 6 Feb 2011 17:29:52 -0800 Subject: [PATCH] Issue 464: started read-only features --- sandbox-apis/cloudstack/pom.xml | 135 +++++ .../cloudstack/CloudStackAsyncClient.java | 61 ++ .../jclouds/cloudstack/CloudStackClient.java | 65 ++ .../cloudstack/CloudStackContextBuilder.java | 45 ++ .../CloudStackPropertiesBuilder.java | 45 ++ .../config/CloudStackRestClientModule.java | 80 +++ .../cloudstack/domain/DiskOffering.java | 217 +++++++ .../cloudstack/domain/GuestIPType.java | 58 ++ .../jclouds/cloudstack/domain/Network.java | 564 ++++++++++++++++++ .../cloudstack/domain/NetworkOffering.java | 239 ++++++++ .../cloudstack/domain/NetworkService.java | 150 +++++ .../cloudstack/domain/NetworkType.java | 52 ++ .../cloudstack/domain/ServiceOffering.java | 261 ++++++++ .../cloudstack/domain/StorageType.java | 52 ++ .../jclouds/cloudstack/domain/Template.java | 538 +++++++++++++++++ .../cloudstack/domain/TemplateFilter.java | 57 ++ .../cloudstack/domain/TrafficType.java | 67 +++ .../org/jclouds/cloudstack/domain/Zone.java | 306 ++++++++++ .../features/NetworkAsyncClient.java | 73 +++ .../cloudstack/features/NetworkClient.java | 57 ++ .../features/OfferingAsyncClient.java | 117 ++++ .../cloudstack/features/OfferingClient.java | 96 +++ .../features/TemplateAsyncClient.java | 83 +++ .../cloudstack/features/TemplateClient.java | 65 ++ .../cloudstack/features/ZoneAsyncClient.java | 73 +++ .../cloudstack/features/ZoneClient.java | 56 ++ .../cloudstack/filters/QuerySigner.java | 144 +++++ .../handlers/CloudStackErrorHandler.java | 98 +++ .../options/ListDiskOfferingsOptions.java | 90 +++ .../options/ListNetworkOfferingsOptions.java | 175 ++++++ .../options/ListNetworksOptions.java | 197 ++++++ .../options/ListServiceOfferingsOptions.java | 109 ++++ .../options/ListTemplatesOptions.java | 168 ++++++ .../cloudstack/options/ListZonesOptions.java | 92 +++ .../cloudstack/CloudStackAsyncClientTest.java | 77 +++ .../cloudstack/CloudStackClientLiveTest.java | 147 +++++ .../BaseCloudStackAsyncClientTest.java | 68 +++ .../BaseCloudStackClientLiveTest.java | 97 +++ .../features/NetworkAsyncClientTest.java | 102 ++++ .../features/NetworkClientLiveTest.java | 93 +++ .../features/OfferingAsyncClientTest.java | 209 +++++++ .../features/OfferingClientLiveTest.java | 106 ++++ .../features/TemplateAsyncClientTest.java | 103 ++++ .../features/TemplateClientLiveTest.java | 69 +++ .../features/ZoneAsyncClientTest.java | 112 ++++ .../features/ZoneClientLiveTest.java | 75 +++ .../cloudstack/filters/QuerySignerTest.java | 98 +++ .../handlers/CloudStackErrorHandlerTest.java | 123 ++++ .../options/ListDiskOfferingsOptionsTest.java | 69 +++ .../ListNetworkOfferingsOptionsTest.java | 125 ++++ .../options/ListNetworksOptionsTest.java | 146 +++++ .../ListServiceOfferingsOptionsTest.java | 79 +++ .../options/ListTemplatesOptionsTest.java | 119 ++++ .../options/ListZonesOptionsTest.java | 68 +++ .../cloudstack/src/test/resources/log4j.xml | 170 ++++++ 55 files changed, 6940 insertions(+) create mode 100644 sandbox-apis/cloudstack/pom.xml create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackAsyncClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/GuestIPType.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkType.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StorageType.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TrafficType.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Zone.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ZoneAsyncClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/ZoneClient.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListDiskOfferingsOptions.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListNetworkOfferingsOptions.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListNetworksOptions.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListServiceOfferingsOptions.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListTemplatesOptions.java create mode 100644 sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListZonesOptions.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneClientLiveTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandlerTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListDiskOfferingsOptionsTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListNetworkOfferingsOptionsTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListNetworksOptionsTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListServiceOfferingsOptionsTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListTemplatesOptionsTest.java create mode 100644 sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/options/ListZonesOptionsTest.java create mode 100644 sandbox-apis/cloudstack/src/test/resources/log4j.xml diff --git a/sandbox-apis/cloudstack/pom.xml b/sandbox-apis/cloudstack/pom.xml new file mode 100644 index 0000000000..c7508e35c9 --- /dev/null +++ b/sandbox-apis/cloudstack/pom.xml @@ -0,0 +1,135 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.api + cloudstack + jclouds cloudstack core + jclouds components to access cloudstack + + + + + jclouds-rimu-snapshots-nexus + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + + http://localhost:8080/client/api + 2.2 + FIXME_apiKey + FIXME_secretKey + + + + org.jclouds + jclouds-core + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-jsch + ${project.version} + test + + + com.jcraft + jsch + 0.1.42 + test + + + log4j + log4j + 1.2.14 + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.cloudstack.endpoint + ${test.cloudstack.endpoint} + + + test.cloudstack.apiversion + ${test.cloudstack.apiversion} + + + test.cloudstack.identity + ${test.cloudstack.identity} + + + test.cloudstack.credential + ${test.cloudstack.credential} + + + + + + + + + + + diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackAsyncClient.java new file mode 100644 index 0000000000..5197225349 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackAsyncClient.java @@ -0,0 +1,61 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack; + +import org.jclouds.cloudstack.features.NetworkAsyncClient; +import org.jclouds.cloudstack.features.OfferingAsyncClient; +import org.jclouds.cloudstack.features.TemplateAsyncClient; +import org.jclouds.cloudstack.features.ZoneAsyncClient; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides asynchronous access to CloudStack via their REST API. + *

+ * + * @see CloudStackClient + * @see + * @author Adrian Cole + */ +public interface CloudStackAsyncClient { + + /** + * Provides asynchronous access to Zone features. + */ + @Delegate + ZoneAsyncClient getZoneClient(); + + /** + * Provides asynchronous access to Template features. + */ + @Delegate + TemplateAsyncClient getTemplateClient(); + + /** + * Provides asynchronous access to Service, Disk, and Network Offering features. + */ + @Delegate + OfferingAsyncClient getOfferingClient(); + + /** + * Provides asynchronous access to Network features. + */ + @Delegate + NetworkAsyncClient getNetworkClient(); +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackClient.java new file mode 100644 index 0000000000..84613de911 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackClient.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.cloudstack.features.NetworkClient; +import org.jclouds.cloudstack.features.OfferingClient; +import org.jclouds.cloudstack.features.TemplateClient; +import org.jclouds.cloudstack.features.ZoneClient; +import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides synchronous access to CloudStack. + *

+ * + * @see CloudStackAsyncClient + * @see + * @author Adrian Cole + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface CloudStackClient { + /** + * Provides synchronous access to Zone features. + */ + @Delegate + ZoneClient getZoneClient(); + + /** + * Provides synchronous access to Template features. + */ + @Delegate + TemplateClient getTemplateClient(); + + /** + * Provides synchronous access to Service, Disk, and Network Offering features. + */ + @Delegate + OfferingClient getOfferingClient(); + + /** + * Provides synchronous access to Network features. + */ + @Delegate + NetworkClient getNetworkClient(); + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java new file mode 100644 index 0000000000..396b368eba --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.cloudstack.config.CloudStackRestClientModule; +import org.jclouds.rest.RestContextBuilder; + +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +public class CloudStackContextBuilder extends + RestContextBuilder { + + public CloudStackContextBuilder(Properties props) { + super(CloudStackClient.class, CloudStackAsyncClient.class, props); + } + + protected void addClientModule(List modules) { + modules.add(new CloudStackRestClientModule()); + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java new file mode 100644 index 0000000000..f9cc073cde --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; + +import java.util.Properties; + +import org.jclouds.PropertiesBuilder; + +/** + * Builds properties used in cloudstack Clients + * + * @author Adrian Cole + */ +public class CloudStackPropertiesBuilder extends PropertiesBuilder { + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_API_VERSION, "2.2"); + return properties; + } + + public CloudStackPropertiesBuilder(Properties properties) { + super(properties); + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java new file mode 100644 index 0000000000..6a058f964b --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java @@ -0,0 +1,80 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.config; + +import java.util.Map; + +import org.jclouds.cloudstack.CloudStackAsyncClient; +import org.jclouds.cloudstack.CloudStackClient; +import org.jclouds.cloudstack.features.NetworkAsyncClient; +import org.jclouds.cloudstack.features.NetworkClient; +import org.jclouds.cloudstack.features.OfferingAsyncClient; +import org.jclouds.cloudstack.features.OfferingClient; +import org.jclouds.cloudstack.features.TemplateAsyncClient; +import org.jclouds.cloudstack.features.TemplateClient; +import org.jclouds.cloudstack.features.ZoneAsyncClient; +import org.jclouds.cloudstack.features.ZoneClient; +import org.jclouds.cloudstack.handlers.CloudStackErrorHandler; +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.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.config.RestClientModule; + +import com.google.common.collect.ImmutableMap; + +/** + * Configures the cloudstack connection. + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class CloudStackRestClientModule extends RestClientModule { + + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// + .put(ZoneClient.class, ZoneAsyncClient.class)// + .put(TemplateClient.class, TemplateAsyncClient.class)// + .put(OfferingClient.class, OfferingAsyncClient.class)// + .put(NetworkClient.class, NetworkAsyncClient.class)// + .build(); + + public CloudStackRestClientModule() { + super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP); + } + + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + super.configure(); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CloudStackErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CloudStackErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CloudStackErrorHandler.class); + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java new file mode 100644 index 0000000000..02ae5b99a3 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java @@ -0,0 +1,217 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import java.util.Date; +import java.util.Set; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class DiskOffering { + private String id; + private String name; + @SerializedName("displaytext") + private String displayText; + private Date created; + private String domain; + @SerializedName("domainid") + private String domainId; + @SerializedName("disksize") + private int diskSize; + @SerializedName("iscustomized") + private boolean customized; + private String tags; + + public DiskOffering(String id, String name, String displayText, Date created, String domain, String domainId, + int diskSize, boolean customized, Set tags) { + this.id = id; + this.name = name; + this.displayText = displayText; + this.created = created; + this.domain = domain; + this.domainId = domainId; + this.diskSize = diskSize; + this.customized = customized; + this.tags = Joiner.on(',').join(tags); + } + + /** + * present only for serializer + * + */ + DiskOffering() { + + } + + /** + * + * @return the id of the disk offering + */ + public String getId() { + return id; + } + + /** + * + * @return the name of the disk offering + */ + + public String getName() { + return name; + } + + /** + * + * @return an alternate display text of the disk offering. + */ + public String getDisplayText() { + return displayText; + } + + /** + * + * @return the date this disk offering was created + */ + public Date getCreated() { + return created; + } + + /** + * + * @return Domain name for the offering + */ + public String getDomain() { + return domain; + } + + /** + * + * @return the domain id of the disk offering + */ + public String getDomainId() { + return domainId; + } + + /** + * + * @return the size of the disk offering in GB + */ + public int getDiskSize() { + return diskSize; + } + + /** + * + * @return the ha support in the disk offering + */ + public boolean isCustomized() { + return customized; + } + + /** + * + * @return the tags for the disk offering + */ + public Set getTags() { + return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet. of(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + (customized ? 1231 : 1237); + result = prime * result + diskSize; + result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); + result = prime * result + ((domain == null) ? 0 : domain.hashCode()); + result = prime * result + ((domainId == null) ? 0 : domainId.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.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; + DiskOffering other = (DiskOffering) obj; + if (created == null) { + if (other.created != null) + return false; + } else if (!created.equals(other.created)) + return false; + if (customized != other.customized) + return false; + if (diskSize != other.diskSize) + return false; + if (displayText == null) { + if (other.displayText != null) + return false; + } else if (!displayText.equals(other.displayText)) + return false; + if (domain == null) { + if (other.domain != null) + return false; + } else if (!domain.equals(other.domain)) + return false; + if (domainId == null) { + if (other.domainId != null) + return false; + } else if (!domainId.equals(other.domainId)) + 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 (tags == null) { + if (other.tags != null) + return false; + } else if (!tags.equals(other.tags)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", created=" + created + ", diskSize=" + + diskSize + ", iscustomized=" + customized + ", domain=" + domain + ", domainId=" + domainId + + ", tags=" + tags + "]"; + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/GuestIPType.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/GuestIPType.java new file mode 100644 index 0000000000..da12fc5461 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/GuestIPType.java @@ -0,0 +1,58 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.CaseFormat; + +/** + * + * @author Adrian Cole + * @see NetworkOfferingClient#listNetworkOfferings + */ +public enum GuestIPType { + + /** + * guest IP address will be issued by Dhcp server in the guest virtual network. Dhcp role is + * played by domain router. + */ + VIRTUAL, + /** + * traffic directly to the network and VMs created here are assigned an IP directly from the + * network as configured + */ + DIRECT, + + UNRECOGNIZED; + + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + public static GuestIPType fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java new file mode 100644 index 0000000000..cdda7e7701 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java @@ -0,0 +1,564 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList.Builder; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class Network { + private String id; + private String account; + @SerializedName("broadcastdomaintype") + private String broadcastDomainType; + @SerializedName("broadcasturi") + private URI broadcastURI; + @SerializedName("displaytext") + private String displayText; + @SerializedName("dns1") + private String DNS1; + @SerializedName("dns2") + private String DNS2; + private String domain; + @Nullable + @SerializedName("domainid") + private String domainId; + @SerializedName("endip") + private String endIP; + private String gateway; + @SerializedName("isdefault") + private boolean isDefault; + @SerializedName("isshared") + private boolean isShared; + @SerializedName("issystem") + private boolean isSystem; + private String netmask; + @SerializedName("networkdomain") + private String networkDomain; + @SerializedName("networkofferingavailability") + private String networkOfferingAvailability; + @SerializedName("networkofferingid") + private String networkOfferingDisplayText; + @SerializedName("networkofferingid") + private String networkOfferingId; + @SerializedName("networkofferingname") + private String networkOfferingName; + private String related; + @SerializedName("startip") + private String startIP; + private String name; + private String state; + @SerializedName("type") + private GuestIPType guestIPType; + @SerializedName("vlan") + private String VLAN; + @SerializedName("traffictype") + private TrafficType trafficType; + @SerializedName("zoneid") + private String zoneId; + @SerializedName("service") + private Set services = ImmutableSet. of(); + + /** + * present only for serializer + * + */ + Network() { + + } + + public Network(String id, String account, String broadcastDomainType, URI broadcastURI, String displayText, + List DNS, String domain, String domainId, String endIP, String gateway, boolean isDefault, + boolean isShared, boolean isSystem, String netmask, String networkDomain, + String networkOfferingAvailability, String networkOfferingDisplayText, String networkOfferingId, + String networkOfferingName, String related, String startIP, String name, String state, GuestIPType type, + String vLAN, TrafficType trafficType, String zoneId, Set services) { + this.id = id; + this.account = account; + this.broadcastDomainType = broadcastDomainType; + this.broadcastURI = broadcastURI; + this.displayText = displayText; + this.DNS1 = checkNotNull(DNS, "DNS").size() > 0 ? DNS.get(0) : null; + this.DNS2 = DNS.size() > 1 ? DNS.get(1) : null; + this.domain = domain; + this.domainId = domainId; + this.endIP = endIP; + this.gateway = gateway; + this.isDefault = isDefault; + this.isShared = isShared; + this.isSystem = isSystem; + this.netmask = netmask; + this.networkDomain = networkDomain; + this.networkOfferingAvailability = networkOfferingAvailability; + this.networkOfferingDisplayText = networkOfferingDisplayText; + this.networkOfferingId = networkOfferingId; + this.networkOfferingName = networkOfferingName; + this.related = related; + this.startIP = startIP; + this.name = name; + this.state = state; + this.guestIPType = type; + this.VLAN = vLAN; + this.trafficType = trafficType; + this.zoneId = zoneId; + this.services = ImmutableSet.copyOf(checkNotNull(services, "services")); + } + + /** + * + * @return network id + */ + public String getId() { + return id; + } + + /** + * + * @return the name of the account to which the template beLongs + */ + public String getAccount() { + return account; + } + + /** + * + * @return Broadcast domain type of the network + */ + public String getBroadcastDomainType() { + return broadcastDomainType; + } + + /** + * + * @return broadcast uri of the network + */ + public URI getBroadcastURI() { + return broadcastURI; + } + + /** + * + * @return the display text of the zone + */ + public String getDisplayText() { + return displayText; + } + + /** + * + * @return the external DNS for the network + */ + public List getDNS() { + Builder builder = ImmutableList.builder(); + if (DNS1 != null && !"".equals(DNS1)) + builder.add(DNS1); + if (DNS2 != null && !"".equals(DNS2)) + builder.add(DNS2); + return builder.build(); + } + + /** + * + * @return Domain name for the Vms in the zone + */ + public String getDomain() { + return domain; + } + + /** + * + * @return the ID of the containing domain, null for public zones + */ + @Nullable + public String getDomainId() { + return domainId; + } + + /** + * + * @return the end ip of the network + */ + public String getEndIP() { + return endIP; + } + + /** + * + * @return the network's gateway + */ + public String getGateway() { + return gateway; + } + + /** + * + * @return true if network offering is default, false otherwise + */ + public boolean isDefault() { + return isDefault; + } + + /** + * + * @return true if network offering is shared, false otherwise + */ + public boolean isShared() { + return isShared; + } + + /** + * + * @return true if network offering is system, false otherwise + */ + public boolean isSystem() { + return isSystem; + } + + /** + * + * @return network name + */ + public String getName() { + return name; + } + + /** + * + * @return the GuestIPType of the network + */ + public GuestIPType getGuestIPType() { + return guestIPType; + } + + /** + * + * @return state of the network + */ + public String getState() { + return state; + } + + /** + * + * @return the vlan range of the zone + */ + public String getVLAN() { + return VLAN; + } + + /** + * + * @return the traffic type for this network offering + */ + public TrafficType getTrafficType() { + return trafficType; + } + + /** + * + * @return the network's netmask + */ + public String getNetmask() { + return netmask; + } + + /** + * + * @return the network domain + */ + public String getNetworkDomain() { + return networkDomain; + } + + /** + * + * @return availability of the network offering the network is created from + */ + public String getNetworkOfferingAvailability() { + return networkOfferingAvailability; + } + + /** + * + * @return display text of the network offering the network is created from + */ + public String getNetworkOfferingDisplayText() { + return networkOfferingDisplayText; + } + + /** + * + * @return network offering id the network is created from + */ + public String getNetworkOfferingId() { + return networkOfferingId; + } + + /** + * + * @return name of the network offering the network is created from + */ + public String getNetworkOfferingName() { + return networkOfferingName; + } + + /** + * + * @return related to what other network configuration + */ + public String getRelated() { + return related; + } + + /** + * + * @return the start ip of the network + */ + public String getStartIP() { + return startIP; + } + + /** + * + * @return zone id of the network + */ + public String getZoneId() { + return zoneId; + } + + /** + * + * @return the list of services + */ + public Set getServices() { + return services; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((DNS1 == null) ? 0 : DNS1.hashCode()); + result = prime * result + ((DNS2 == null) ? 0 : DNS2.hashCode()); + result = prime * result + ((VLAN == null) ? 0 : VLAN.hashCode()); + result = prime * result + ((account == null) ? 0 : account.hashCode()); + result = prime * result + ((broadcastDomainType == null) ? 0 : broadcastDomainType.hashCode()); + result = prime * result + ((broadcastURI == null) ? 0 : broadcastURI.hashCode()); + result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); + result = prime * result + ((domain == null) ? 0 : domain.hashCode()); + result = prime * result + ((domainId == null) ? 0 : domainId.hashCode()); + result = prime * result + ((endIP == null) ? 0 : endIP.hashCode()); + result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + (isDefault ? 1231 : 1237); + result = prime * result + (isShared ? 1231 : 1237); + result = prime * result + (isSystem ? 1231 : 1237); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); + result = prime * result + ((networkDomain == null) ? 0 : networkDomain.hashCode()); + result = prime * result + ((networkOfferingAvailability == null) ? 0 : networkOfferingAvailability.hashCode()); + result = prime * result + ((networkOfferingDisplayText == null) ? 0 : networkOfferingDisplayText.hashCode()); + result = prime * result + ((networkOfferingId == null) ? 0 : networkOfferingId.hashCode()); + result = prime * result + ((networkOfferingName == null) ? 0 : networkOfferingName.hashCode()); + result = prime * result + ((related == null) ? 0 : related.hashCode()); + result = prime * result + ((services == null) ? 0 : services.hashCode()); + result = prime * result + ((startIP == null) ? 0 : startIP.hashCode()); + result = prime * result + ((state == null) ? 0 : state.hashCode()); + result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); + result = prime * result + ((guestIPType == null) ? 0 : guestIPType.hashCode()); + result = prime * result + ((zoneId == null) ? 0 : zoneId.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; + Network other = (Network) obj; + if (DNS1 == null) { + if (other.DNS1 != null) + return false; + } else if (!DNS1.equals(other.DNS1)) + return false; + if (DNS2 == null) { + if (other.DNS2 != null) + return false; + } else if (!DNS2.equals(other.DNS2)) + return false; + if (VLAN == null) { + if (other.VLAN != null) + return false; + } else if (!VLAN.equals(other.VLAN)) + return false; + if (account == null) { + if (other.account != null) + return false; + } else if (!account.equals(other.account)) + return false; + if (broadcastDomainType == null) { + if (other.broadcastDomainType != null) + return false; + } else if (!broadcastDomainType.equals(other.broadcastDomainType)) + return false; + if (broadcastURI == null) { + if (other.broadcastURI != null) + return false; + } else if (!broadcastURI.equals(other.broadcastURI)) + return false; + if (displayText == null) { + if (other.displayText != null) + return false; + } else if (!displayText.equals(other.displayText)) + return false; + if (domain == null) { + if (other.domain != null) + return false; + } else if (!domain.equals(other.domain)) + return false; + if (domainId == null) { + if (other.domainId != null) + return false; + } else if (!domainId.equals(other.domainId)) + return false; + if (endIP == null) { + if (other.endIP != null) + return false; + } else if (!endIP.equals(other.endIP)) + return false; + if (gateway == null) { + if (other.gateway != null) + return false; + } else if (!gateway.equals(other.gateway)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (isDefault != other.isDefault) + return false; + if (isShared != other.isShared) + return false; + if (isSystem != other.isSystem) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (netmask == null) { + if (other.netmask != null) + return false; + } else if (!netmask.equals(other.netmask)) + return false; + if (networkDomain == null) { + if (other.networkDomain != null) + return false; + } else if (!networkDomain.equals(other.networkDomain)) + return false; + if (networkOfferingAvailability == null) { + if (other.networkOfferingAvailability != null) + return false; + } else if (!networkOfferingAvailability.equals(other.networkOfferingAvailability)) + return false; + if (networkOfferingDisplayText == null) { + if (other.networkOfferingDisplayText != null) + return false; + } else if (!networkOfferingDisplayText.equals(other.networkOfferingDisplayText)) + return false; + if (networkOfferingId == null) { + if (other.networkOfferingId != null) + return false; + } else if (!networkOfferingId.equals(other.networkOfferingId)) + return false; + if (networkOfferingName == null) { + if (other.networkOfferingName != null) + return false; + } else if (!networkOfferingName.equals(other.networkOfferingName)) + return false; + if (related == null) { + if (other.related != null) + return false; + } else if (!related.equals(other.related)) + return false; + if (services == null) { + if (other.services != null) + return false; + } else if (!services.equals(other.services)) + return false; + if (startIP == null) { + if (other.startIP != null) + return false; + } else if (!startIP.equals(other.startIP)) + return false; + if (state == null) { + if (other.state != null) + return false; + } else if (!state.equals(other.state)) + return false; + if (trafficType == null) { + if (other.trafficType != null) + return false; + } else if (!trafficType.equals(other.trafficType)) + return false; + if (guestIPType == null) { + if (other.guestIPType != null) + return false; + } else if (!guestIPType.equals(other.guestIPType)) + return false; + if (zoneId == null) { + if (other.zoneId != null) + return false; + } else if (!zoneId.equals(other.zoneId)) + return false; + return true; + } + + @Override + public String toString() { + return "Network [id=" + id + ", state=" + state + ", name=" + name + ", displayText=" + displayText + ", guestIPType=" + + guestIPType + ", trafficType=" + trafficType + ", DNS=" + getDNS() + ", VLAN=" + VLAN + ", account=" + + account + ", startIP=" + startIP + ", endIP=" + endIP + ", netmask=" + netmask + ", gateway=" + + gateway + ", broadcastDomainType=" + broadcastDomainType + ", broadcastURI=" + broadcastURI + + ", services=" + services + ", domain=" + domain + ", domainId=" + domainId + ", isDefault=" + + isDefault + ", isShared=" + isShared + ", isSystem=" + isSystem + ", related=" + related + ", zoneId=" + + zoneId + ", networkDomain=" + networkDomain + ", networkOfferingAvailability=" + + networkOfferingAvailability + ", networkOfferingDisplayText=" + networkOfferingDisplayText + + ", networkOfferingId=" + networkOfferingId + ", networkOfferingName=" + networkOfferingName + "]"; + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java new file mode 100644 index 0000000000..82f38d7ed0 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java @@ -0,0 +1,239 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import java.util.Date; +import java.util.Set; + +import javax.annotation.Nullable; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class NetworkOffering { + private String id; + private String name; + @SerializedName("displaytext") + private String displayText; + private Date created; + private String availability; + @SerializedName("maxconnections") + private Integer maxConnections; + @SerializedName("isdefault") + private boolean isDefault; + @SerializedName("specifyvlan") + private boolean supportsVLAN; + @SerializedName("traffictype") + private TrafficType trafficType; + private String tags; + + public NetworkOffering(String id, String name, String displayText, @Nullable Date created, String availability, + boolean supportsVLAN, @Nullable Integer maxConnections, boolean isDefault, TrafficType trafficType, + Set tags) { + this.id = id; + this.name = name; + this.displayText = displayText; + this.created = created; + this.availability = availability; + this.supportsVLAN = supportsVLAN; + this.maxConnections = maxConnections; + this.isDefault = isDefault; + this.trafficType = trafficType; + this.tags = Joiner.on(',').join(tags); + } + + /** + * present only for serializer + * + */ + NetworkOffering() { + + } + + /** + * + * @return the id of the network offering + */ + public String getId() { + return id; + } + + /** + * + * @return the name of the network offering + */ + + public String getName() { + return name; + } + + /** + * + * @return an alternate display text of the network offering. + */ + public String getDisplayText() { + return displayText; + } + + /** + * + * @return the date this network offering was created + */ + @Nullable + public Date getCreated() { + return created; + } + + /** + * + * @return Availability name for the offering + */ + public String getAvailability() { + return availability; + } + + /** + * + * @return true if network offering supports vlans, false otherwise + */ + public boolean supportsVLAN() { + return supportsVLAN; + } + + /** + * + * @return the max number of concurrent connection the network offering supports + */ + @Nullable + public Integer getMaxConnections() { + return maxConnections; + } + + /** + * + * @return true if network offering is default, false otherwise + */ + public boolean isDefault() { + return isDefault; + } + + /** + * + * @return the traffic type for this network offering + */ + public TrafficType getTrafficType() { + return trafficType; + } + + /** + * + * @return the tags for the network offering + */ + public Set getTags() { + return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet. of(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((availability == null) ? 0 : availability.hashCode()); + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + (isDefault ? 1231 : 1237); + result = prime * result + ((maxConnections == null) ? 0 : maxConnections.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + (supportsVLAN ? 1231 : 1237); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); + result = prime * result + ((trafficType == null) ? 0 : trafficType.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; + NetworkOffering other = (NetworkOffering) obj; + if (availability == null) { + if (other.availability != null) + return false; + } else if (!availability.equals(other.availability)) + return false; + if (created == null) { + if (other.created != null) + return false; + } else if (!created.equals(other.created)) + return false; + if (displayText == null) { + if (other.displayText != null) + return false; + } else if (!displayText.equals(other.displayText)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (isDefault != other.isDefault) + return false; + if (maxConnections == null) { + if (other.maxConnections != null) + return false; + } else if (!maxConnections.equals(other.maxConnections)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (supportsVLAN != other.supportsVLAN) + return false; + if (tags == null) { + if (other.tags != null) + return false; + } else if (!tags.equals(other.tags)) + return false; + if (trafficType == null) { + if (other.trafficType != null) + return false; + } else if (!trafficType.equals(other.trafficType)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", created=" + created + + ", maxConnections=" + maxConnections + ", trafficType=" + trafficType + ", isDefault=" + isDefault + + ", availability=" + availability + ", supportsVLAN=" + supportsVLAN + ", tags=" + tags + "]"; + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java new file mode 100644 index 0000000000..a1c4e6079e --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java @@ -0,0 +1,150 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; + +import com.google.common.collect.ImmutableSet; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class NetworkService { + public static class Capability { + + private String name; + private String value; + + Capability() { + + } + + public Capability(String name, String value) { + this.name = checkNotNull(name, "name"); + this.value = checkNotNull(value, "value"); + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((value == null) ? 0 : value.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; + NetworkService.Capability other = (NetworkService.Capability) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + + @Override + public String toString() { + return "[name=" + name + ", value=" + value + "]"; + } + + } + + private String name; + @SerializedName("capability") + private Set capabilities = ImmutableSet.of(); + + NetworkService() { + + } + + public NetworkService(String name, Set capabilities) { + this.name = checkNotNull(name, "name"); + this.capabilities = ImmutableSet.copyOf(checkNotNull(capabilities, "capabilities")); + } + + public String getName() { + return name; + } + + public Set getCapabilities() { + return capabilities; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); + result = prime * result + ((name == null) ? 0 : name.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; + NetworkService other = (NetworkService) obj; + if (capabilities == null) { + if (other.capabilities != null) + return false; + } else if (!capabilities.equals(other.capabilities)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + return "[name=" + name + ", capabilities=" + capabilities + "]"; + } +} \ No newline at end of file diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkType.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkType.java new file mode 100644 index 0000000000..2be5914dd8 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkType.java @@ -0,0 +1,52 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.cloudstack.features.TemplateClient; + +import com.google.common.base.CaseFormat; + +/** + * + * @author Adrian Cole + * @see TemplateClient#listZones + */ +public enum NetworkType { + BASIC, + + ADVANCED, + + UNRECOGNIZED; + + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + public static NetworkType fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java new file mode 100644 index 0000000000..d059c47ed3 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java @@ -0,0 +1,261 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import java.util.Date; +import java.util.Set; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class ServiceOffering { + private String id; + private String name; + @SerializedName("displaytext") + private String displayText; + private Date created; + private String domain; + @SerializedName("domainid") + private String domainId; + @SerializedName("cpunumber") + private int cpuNumber; + @SerializedName("cpuspeed") + private int cpuSpeed; + private int memory; + @SerializedName("offerha") + private boolean haSupport; + @SerializedName("storagetype") + private StorageType storageType; + private String tags; + + public ServiceOffering(String id, String name, String displayText, Date created, String domain, String domainId, + int cpuNumber, int cpuSpeed, int memory, boolean haSupport, StorageType storageType, Set tags) { + this.id = id; + this.name = name; + this.displayText = displayText; + this.created = created; + this.domain = domain; + this.domainId = domainId; + this.cpuNumber = cpuNumber; + this.cpuSpeed = cpuSpeed; + this.memory = memory; + this.haSupport = haSupport; + this.storageType = storageType; + this.tags = Joiner.on(',').join(tags); + } + + /** + * present only for serializer + * + */ + ServiceOffering() { + + } + + /** + * + * @return the id of the service offering + */ + public String getId() { + return id; + } + + /** + * + * @return the name of the service offering + */ + + public String getName() { + return name; + } + + /** + * + * @return an alternate display text of the service offering. + */ + public String getDisplayText() { + return displayText; + } + + /** + * + * @return the date this service offering was created + */ + public Date getCreated() { + return created; + } + + /** + * + * @return Domain name for the offering + */ + public String getDomain() { + return domain; + } + + /** + * + * @return the domain id of the service offering + */ + public String getDomainId() { + return domainId; + } + + /** + * + * @return the number of CPU + */ + public int getCpuNumber() { + return cpuNumber; + } + + /** + * + * @return the clock rate CPU speed in Mhz + */ + public int getCpuSpeed() { + return cpuSpeed; + } + + /** + * + * @return the memory in MB + */ + public int getMemory() { + return memory; + } + + /** + * + * @return the ha support in the service offering + */ + public boolean supportsHA() { + return haSupport; + } + + /** + * + * @return the storage type for this service offering + */ + public StorageType getStorageType() { + return storageType; + } + + /** + * + * @return the tags for the service offering + */ + public Set getTags() { + return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet. of(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + cpuNumber; + result = prime * result + cpuSpeed; + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); + result = prime * result + ((domain == null) ? 0 : domain.hashCode()); + result = prime * result + ((domainId == null) ? 0 : domainId.hashCode()); + result = prime * result + (haSupport ? 1231 : 1237); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + memory; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.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; + ServiceOffering other = (ServiceOffering) obj; + if (cpuNumber != other.cpuNumber) + return false; + if (cpuSpeed != other.cpuSpeed) + return false; + if (created == null) { + if (other.created != null) + return false; + } else if (!created.equals(other.created)) + return false; + if (displayText == null) { + if (other.displayText != null) + return false; + } else if (!displayText.equals(other.displayText)) + return false; + if (domain == null) { + if (other.domain != null) + return false; + } else if (!domain.equals(other.domain)) + return false; + if (domainId == null) { + if (other.domainId != null) + return false; + } else if (!domainId.equals(other.domainId)) + return false; + if (haSupport != other.haSupport) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (memory != other.memory) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (storageType == null) { + if (other.storageType != null) + return false; + } else if (!storageType.equals(other.storageType)) + return false; + if (tags == null) { + if (other.tags != null) + return false; + } else if (!tags.equals(other.tags)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", created=" + created + ", cpuNumber=" + + cpuNumber + ", cpuSpeed=" + cpuSpeed + ", memory=" + memory + ", storageType=" + storageType + + ", haSupport=" + haSupport + ", domain=" + domain + ", domainId=" + domainId + ", tags=" + tags + "]"; + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StorageType.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StorageType.java new file mode 100644 index 0000000000..65897eaee9 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StorageType.java @@ -0,0 +1,52 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.cloudstack.features.OfferingClient; + +import com.google.common.base.CaseFormat; + +/** + * + * @author Adrian Cole + * @see OfferingClient#listServiceOfferings + */ +public enum StorageType { + LOCAL, + + SHARED, + + UNRECOGNIZED; + + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); + } + + public static StorageType fromValue(String type) { + try { + return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java new file mode 100644 index 0000000000..d84b80aa0d --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java @@ -0,0 +1,538 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import java.util.Date; +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class Template { + + public enum Type { + + USER, BUILTIN, UNRECOGNIZED; + + public static Type fromValue(String type) { + try { + return valueOf(checkNotNull(type, "type")); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public enum Format { + + VHD, QCOW2, OVA, UNRECOGNIZED; + + public static Format fromValue(String format) { + try { + return valueOf(checkNotNull(format, "format")); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + private String id; + @SerializedName("displaytext") + private String displayText; + private String domain; + @SerializedName("domainid") + private String domainId; + private String account; + @SerializedName("accountid") + private String accountId; + @SerializedName("zonename") + private String zone; + @SerializedName("zoneid") + private String zoneId; + @SerializedName("ostypename") + private String OSType; + @SerializedName("ostypeid") + private String OSTypeId; + private String name; + @SerializedName("templatetype") + private Type type; + private String status; + private Format format; + private String hypervisor; + private Long size; + private Date created; + private Date removed; + @SerializedName("crossZones") + private boolean crossZones; + @SerializedName("bootable") + private boolean bootable; + @SerializedName("isextractable") + private boolean extractable; + @SerializedName("isfeatured") + private boolean featured; + @SerializedName("ispublic") + private boolean ispublic; + @SerializedName("isready") + private boolean ready; + @SerializedName("passwordenabled") + private boolean passwordEnabled; + @Nullable + @SerializedName("jobid") + private String jobId; + @SerializedName("jobstatus") + private String jobStatus; + + public Template(String id, String displayText, String domain, String domainId, String account, String accountId, + String zone, String zoneId, String oSType, String oSTypeId, String name, Type type, String status, + Format format, String hypervisor, Long size, Date created, Date removed, boolean crossZones, + boolean bootable, boolean extractable, boolean featured, boolean ispublic, boolean ready, + boolean passwordEnabled, String jobId, String jobStatus) { + this.id = id; + this.displayText = displayText; + this.domain = domain; + this.domainId = domainId; + this.account = account; + this.accountId = accountId; + this.zone = zone; + this.zoneId = zoneId; + this.OSType = oSType; + this.OSTypeId = oSTypeId; + this.name = name; + this.type = type; + this.status = status; + this.format = format; + this.hypervisor = hypervisor; + this.size = size; + this.created = created; + this.removed = removed; + this.crossZones = crossZones; + this.bootable = bootable; + this.extractable = extractable; + this.featured = featured; + this.ispublic = ispublic; + this.ready = ready; + this.passwordEnabled = passwordEnabled; + this.jobId = jobId; + this.jobStatus = jobStatus; + } + + /** + * present only for serializer + * + */ + Template() { + + } + + /** + * + * @return Template id + */ + public String getId() { + return id; + } + + /** + * + * @return the display text of the template + */ + public String getDisplayText() { + return displayText; + } + + /** + * + * @return the name of the domain to which the template beLongs + */ + public String getDomain() { + return domain; + } + + /** + * + * @return the ID of the domain to which the template beLongs + */ + public String getDomainId() { + return domainId; + } + + /** + * + * @return the name of the account to which the template beLongs + */ + public String getAccount() { + return account; + } + + /** + * + * @return the ID of the account to which the template beLongs + */ + public String getAccountId() { + return accountId; + } + + /** + * + * @return the name of the zone to which the template beLongs + */ + public String getZone() { + return zone; + } + + /** + * + * @return the ID of the zone to which the template beLongs + */ + public String getZoneId() { + return zoneId; + } + + /** + * + * @return the name of the OS type to which the template beLongs + */ + public String getOSType() { + return OSType; + } + + /** + * + * @return the ID of the OS type to which the template beLongs + */ + public String getOSTypeId() { + return OSTypeId; + } + + /** + * + * @return Template name + */ + public String getName() { + return name; + } + + /** + * + * @return + */ + public String getStatus() { + return status; + } + + /** + * + * @return the format of the template. + */ + public Format getFormat() { + return format; + } + + /** + * + * @return the hypervisor on which the template runs + */ + public String getHypervisor() { + return hypervisor; + } + + /** + * + * @return the size of the template in kilobytes + */ + public Long getSize() { + return size; + } + + /** + * + * @return the type of the template + */ + public Type getType() { + return type; + } + + /** + * + * @return the date this template was created + */ + public Date getCreated() { + return created; + } + + /** + * + * @return the date this template was removed + */ + public Date getRemoved() { + return removed; + } + + /** + * + * @return true if the template is managed across all Zones, false otherwise + */ + public boolean isCrossZones() { + return crossZones; + } + + /** + * + * @return true if the ISO is bootable, false otherwise + */ + public boolean isBootable() { + return bootable; + } + + /** + * + * @return true if the template is extractable, false otherwise + */ + public boolean isExtractable() { + return extractable; + } + + /** + * + * @return true if this template is a featured template, false otherwise + */ + public boolean isFeatured() { + return featured; + } + + /** + * + * @return true if this template is a public template, false otherwise + */ + public boolean isPublic() { + return ispublic; + } + + /** + * + * @return true if the template is ready to be deployed from, false otherwise + */ + public boolean isReady() { + return ready; + } + + /** + * + * @return true if the reset password feature is enabled, false otherwise + */ + public boolean isPasswordEnabled() { + return passwordEnabled; + } + + /** + * + * @return shows the current pending asynchronous job ID, or null if current pending jobs are + * acting on the template + */ + @Nullable + public String getJobId() { + return jobId; + } + + /** + * + * @return shows the current pending asynchronous job status + */ + public String getJobStatus() { + return jobStatus; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((OSType == null) ? 0 : OSType.hashCode()); + result = prime * result + ((OSTypeId == null) ? 0 : OSTypeId.hashCode()); + result = prime * result + ((account == null) ? 0 : account.hashCode()); + result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); + result = prime * result + (bootable ? 1231 : 1237); + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + (crossZones ? 1231 : 1237); + result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); + result = prime * result + ((domain == null) ? 0 : domain.hashCode()); + result = prime * result + ((domainId == null) ? 0 : domainId.hashCode()); + result = prime * result + (extractable ? 1231 : 1237); + result = prime * result + (featured ? 1231 : 1237); + result = prime * result + ((format == null) ? 0 : format.hashCode()); + result = prime * result + ((hypervisor == null) ? 0 : hypervisor.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + (ispublic ? 1231 : 1237); + result = prime * result + ((jobId == null) ? 0 : jobId.hashCode()); + result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + (passwordEnabled ? 1231 : 1237); + result = prime * result + (ready ? 1231 : 1237); + result = prime * result + ((removed == null) ? 0 : removed.hashCode()); + result = prime * result + ((size == null) ? 0 : size.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((zone == null) ? 0 : zone.hashCode()); + result = prime * result + ((zoneId == null) ? 0 : zoneId.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; + Template other = (Template) obj; + if (OSType == null) { + if (other.OSType != null) + return false; + } else if (!OSType.equals(other.OSType)) + return false; + if (OSTypeId == null) { + if (other.OSTypeId != null) + return false; + } else if (!OSTypeId.equals(other.OSTypeId)) + return false; + if (account == null) { + if (other.account != null) + return false; + } else if (!account.equals(other.account)) + return false; + if (accountId == null) { + if (other.accountId != null) + return false; + } else if (!accountId.equals(other.accountId)) + return false; + if (bootable != other.bootable) + return false; + if (created == null) { + if (other.created != null) + return false; + } else if (!created.equals(other.created)) + return false; + if (crossZones != other.crossZones) + return false; + if (displayText == null) { + if (other.displayText != null) + return false; + } else if (!displayText.equals(other.displayText)) + return false; + if (domain == null) { + if (other.domain != null) + return false; + } else if (!domain.equals(other.domain)) + return false; + if (domainId == null) { + if (other.domainId != null) + return false; + } else if (!domainId.equals(other.domainId)) + return false; + if (extractable != other.extractable) + return false; + if (featured != other.featured) + return false; + if (format == null) { + if (other.format != null) + return false; + } else if (!format.equals(other.format)) + return false; + if (hypervisor == null) { + if (other.hypervisor != null) + return false; + } else if (!hypervisor.equals(other.hypervisor)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (ispublic != other.ispublic) + return false; + if (jobId == null) { + if (other.jobId != null) + return false; + } else if (!jobId.equals(other.jobId)) + return false; + if (jobStatus == null) { + if (other.jobStatus != null) + return false; + } else if (!jobStatus.equals(other.jobStatus)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (passwordEnabled != other.passwordEnabled) + return false; + if (ready != other.ready) + return false; + if (removed == null) { + if (other.removed != null) + return false; + } else if (!removed.equals(other.removed)) + return false; + if (size == null) { + if (other.size != null) + return false; + } else if (!size.equals(other.size)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + if (zone == null) { + if (other.zone != null) + return false; + } else if (!zone.equals(other.zone)) + return false; + if (zoneId == null) { + if (other.zoneId != null) + return false; + } else if (!zoneId.equals(other.zoneId)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", format=" + format + ", type=" + type + + ", hypervisor=" + hypervisor + ", size=" + size + ", status=" + status + ", created=" + created + + ", removed=" + removed + ", OSType=" + OSType + ", OSTypeId=" + OSTypeId + ", account=" + account + + ", accountId=" + accountId + ", domain=" + domain + ", domainId=" + domainId + ", zone=" + zone + + ", zoneId=" + zoneId + ", ready=" + ready + ", bootable=" + bootable + ", crossZones=" + crossZones + + ", extractable=" + extractable + ", featured=" + featured + ", ispublic=" + ispublic + + ", passwordEnabled=" + passwordEnabled + ", jobId=" + jobId + ", jobStatus=" + jobStatus + "]"; + } + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java new file mode 100644 index 0000000000..8d03221228 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import org.jclouds.cloudstack.features.TemplateClient; + +import com.google.common.base.CaseFormat; + +/** + * + * @author Adrian Cole + * @see TemplateClient#listTemplates + */ +public enum TemplateFilter { + /** + * templates that are featured and are public + */ + FEATURED, + /** + * templates that have been registered/created by the owner + */ + SELF, + /** + * templates that have been registered/created by the owner that can be used to deploy a new VM + */ + SELF_EXECUTABLE, + /** + * all templates that can be used to deploy a new VM + */ + EXECUTABLE, + /** + * templates that are public + */ + COMMUNITY; + + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TrafficType.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TrafficType.java new file mode 100644 index 0000000000..f19d5f3266 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TrafficType.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.CaseFormat; + +/** + * + * @author Adrian Cole + * @see NetworkOfferingClient#listNetworkOfferings + */ +public enum TrafficType { + + /** + * traffic to the public internet + */ + PUBLIC, + /** + * VM-to-VM traffic and VMs are assigned a virtual IP created by CloudStack + */ + GUEST, + /** + * System network that only Admin can view, and only when isSystem is specified. + */ + STORAGE, + /** + * System network that only Admin can view, and only when isSystem is specified. + */ + MANAGEMENT, + /** + * System network that only Admin can view, and only when isSystem is specified. + */ + CONTROL, + + UNRECOGNIZED; + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + public static TrafficType fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Zone.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Zone.java new file mode 100644 index 0000000000..752a0f63a3 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Zone.java @@ -0,0 +1,306 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; + +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.gson.annotations.SerializedName; + +/** + * + * @author Adrian Cole + */ +public class Zone { + private String id; + private String description; + @SerializedName("displaytext") + private String displayText; + @SerializedName("dns1") + private String DNS1; + @SerializedName("dns2") + private String DNS2; + private String domain; + @Nullable + @SerializedName("domainid") + private String domainId; + @SerializedName("guestcidraddress") + private String guestCIDRAddress; + @SerializedName("internaldns1") + private String internalDNS1; + @SerializedName("internaldns2") + private String internalDNS2; + private String name; + @SerializedName("networktype") + private NetworkType networkType; + private String status; + @SerializedName("vlan") + private String VLAN; + + /** + * present only for serializer + * + */ + Zone() { + + } + + public Zone(String id, String description, String displayText, List DNS, String domain, String domainId, + String guestCIDRAddress, List internalDNS, String name, NetworkType networkType, String status, + String vLAN) { + this.id = id; + this.description = description; + this.displayText = displayText; + this.DNS1 = checkNotNull(DNS, "DNS").size() > 0 ? DNS.get(0) : null; + this.DNS2 = DNS.size() > 1 ? DNS.get(1) : null; + this.domain = domain; + this.domainId = domainId; + this.guestCIDRAddress = guestCIDRAddress; + this.internalDNS1 = checkNotNull(internalDNS, "internalDNS").size() > 0 ? internalDNS.get(0) : null; + this.internalDNS2 = internalDNS.size() > 1 ? internalDNS.get(1) : null; + this.name = name; + this.networkType = networkType; + this.status = status; + this.VLAN = vLAN; + } + + /** + * + * @return Zone id + */ + public String getId() { + return id; + } + + /** + * + * @return Zone description + */ + public String getDescription() { + return description; + } + + /** + * + * @return the display text of the zone + */ + public String getDisplayText() { + return displayText; + } + + /** + * + * @return the external DNS for the Zone + */ + public List getDNS() { + Builder builder = ImmutableList.builder(); + if (DNS1 != null && !"".equals(DNS1)) + builder.add(DNS1); + if (DNS2 != null && !"".equals(DNS2)) + builder.add(DNS2); + return builder.build(); + } + + /** + * + * @return Domain name for the Vms in the zone + */ + public String getDomain() { + return domain; + } + + /** + * + * @return the ID of the containing domain, null for public zones + */ + @Nullable + public String getDomainId() { + return domainId; + } + + /** + * + * @return the guest CIDR address for the Zone + */ + public String getGuestCIDRAddress() { + return guestCIDRAddress; + } + + /** + * + * @return the internal DNS for the Zone + */ + public List getInternalDNS() { + Builder builder = ImmutableList.builder(); + if (internalDNS1 != null && !"".equals(internalDNS1)) + builder.add(internalDNS1); + if (internalDNS2 != null && !"".equals(internalDNS2)) + builder.add(internalDNS2); + return builder.build(); + } + + /** + * + * @return Zone name + */ + public String getName() { + return name; + } + + /** + * + * @return the network type of the zone; can be Basic or Advanced + */ + public NetworkType getNetworkType() { + return networkType; + } + + /** + * + * @return + */ + public String getStatus() { + return status; + } + + /** + * + * @return the vlan range of the zone + */ + public String getVLAN() { + return VLAN; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((DNS1 == null) ? 0 : DNS1.hashCode()); + result = prime * result + ((DNS2 == null) ? 0 : DNS2.hashCode()); + result = prime * result + ((VLAN == null) ? 0 : VLAN.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); + result = prime * result + ((domain == null) ? 0 : domain.hashCode()); + result = prime * result + ((domainId == null) ? 0 : domainId.hashCode()); + result = prime * result + ((guestCIDRAddress == null) ? 0 : guestCIDRAddress.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((internalDNS1 == null) ? 0 : internalDNS1.hashCode()); + result = prime * result + ((internalDNS2 == null) ? 0 : internalDNS2.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((networkType == null) ? 0 : networkType.hashCode()); + result = prime * result + ((status == null) ? 0 : status.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; + Zone other = (Zone) obj; + if (DNS1 == null) { + if (other.DNS1 != null) + return false; + } else if (!DNS1.equals(other.DNS1)) + return false; + if (DNS2 == null) { + if (other.DNS2 != null) + return false; + } else if (!DNS2.equals(other.DNS2)) + return false; + if (VLAN == null) { + if (other.VLAN != null) + return false; + } else if (!VLAN.equals(other.VLAN)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (displayText == null) { + if (other.displayText != null) + return false; + } else if (!displayText.equals(other.displayText)) + return false; + if (domain == null) { + if (other.domain != null) + return false; + } else if (!domain.equals(other.domain)) + return false; + if (domainId == null) { + if (other.domainId != null) + return false; + } else if (!domainId.equals(other.domainId)) + return false; + if (guestCIDRAddress == null) { + if (other.guestCIDRAddress != null) + return false; + } else if (!guestCIDRAddress.equals(other.guestCIDRAddress)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (internalDNS1 == null) { + if (other.internalDNS1 != null) + return false; + } else if (!internalDNS1.equals(other.internalDNS1)) + return false; + if (internalDNS2 == null) { + if (other.internalDNS2 != null) + return false; + } else if (!internalDNS2.equals(other.internalDNS2)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (networkType == null) { + if (other.networkType != null) + return false; + } else if (!networkType.equals(other.networkType)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", status=" + status + ", name=" + name + ", description=" + description + ", displayText=" + + displayText + ", domain=" + domain + ", domainId=" + domainId + ", networkType=" + networkType + + ", guestCIDRAddress=" + guestCIDRAddress + ", VLAN=" + VLAN + ", DNS=" + getDNS() + ", internalDNS=" + + getInternalDNS() + "]"; + } +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java new file mode 100644 index 0000000000..ab934de3bf --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkAsyncClient.java @@ -0,0 +1,73 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.cloudstack.domain.Network; +import org.jclouds.cloudstack.filters.QuerySigner; +import org.jclouds.cloudstack.options.ListNetworksOptions; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to cloudstack via their REST API. + *

+ * + * @see NetworkClient + * @see + * @author Adrian Cole + */ +@RequestFilters(QuerySigner.class) +@QueryParams(keys = "response", values = "json") +public interface NetworkAsyncClient { + + /** + * @see NetworkClient#listNetworks + */ + @GET + @QueryParams(keys = "command", values = "listNetworks") + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listNetworks(ListNetworksOptions... options); + + /** + * @see NetworkClient#getNetwork + */ + @GET + @QueryParams(keys = "command", values = "listNetworks") + @Unwrap(depth = 3, edgeCollection = Set.class) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetwork(@QueryParam("id") String id); + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkClient.java new file mode 100644 index 0000000000..5874c99870 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/NetworkClient.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.cloudstack.domain.Network; +import org.jclouds.cloudstack.options.ListNetworksOptions; +import org.jclouds.concurrent.Timeout; + +/** + * Provides synchronous access to CloudStack network features. + *

+ * + * @see NetworkAsyncClient + * @see + * @author Adrian Cole + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface NetworkClient { + /** + * Lists networks + * + * @param options + * if present, how to constrain the list. + * @return networks matching query, or empty set, if no networks are found + */ + Set listNetworks(ListNetworksOptions... options); + + /** + * get a specific network by id + * + * @param id + * network to get + * @return network or null if not found + */ + Network getNetwork(String id); + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java new file mode 100644 index 0000000000..46961a8477 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingAsyncClient.java @@ -0,0 +1,117 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.cloudstack.domain.DiskOffering; +import org.jclouds.cloudstack.domain.NetworkOffering; +import org.jclouds.cloudstack.domain.ServiceOffering; +import org.jclouds.cloudstack.filters.QuerySigner; +import org.jclouds.cloudstack.options.ListDiskOfferingsOptions; +import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; +import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to cloudstack via their REST API. + *

+ * + * @see OfferingClient + * @see + * @author Adrian Cole + */ +@RequestFilters(QuerySigner.class) +@QueryParams(keys = "response", values = "json") +public interface OfferingAsyncClient { + + /** + * @see OfferingClient#listServiceOfferings + */ + @GET + @QueryParams(keys = "command", values = "listServiceOfferings") + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listServiceOfferings(ListServiceOfferingsOptions... options); + + /** + * @see OfferingClient#getServiceOffering + */ + @GET + @QueryParams(keys = "command", values = "listServiceOfferings") + @Unwrap(depth = 3, edgeCollection = Set.class) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getServiceOffering(@QueryParam("id") String id); + + /** + * @see OfferingClient#listDiskOfferings + */ + @GET + @QueryParams(keys = "command", values = "listDiskOfferings") + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listDiskOfferings(ListDiskOfferingsOptions... options); + + /** + * @see OfferingClient#getDiskOffering + */ + @GET + @QueryParams(keys = "command", values = "listDiskOfferings") + @Unwrap(depth = 3, edgeCollection = Set.class) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getDiskOffering(@QueryParam("id") String id); + + /** + * @see NetworkOfferingClient#listNetworkOfferings + */ + @GET + @QueryParams(keys = "command", values = "listNetworkOfferings") + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listNetworkOfferings(ListNetworkOfferingsOptions... options); + + /** + * @see NetworkOfferingClient#getNetworkOffering + */ + @GET + @QueryParams(keys = "command", values = "listNetworkOfferings") + @Unwrap(depth = 3, edgeCollection = Set.class) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkOffering(@QueryParam("id") String id); + +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingClient.java new file mode 100644 index 0000000000..b8453e81f8 --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/OfferingClient.java @@ -0,0 +1,96 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.cloudstack.domain.DiskOffering; +import org.jclouds.cloudstack.domain.NetworkOffering; +import org.jclouds.cloudstack.domain.ServiceOffering; +import org.jclouds.cloudstack.options.ListDiskOfferingsOptions; +import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; +import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; +import org.jclouds.concurrent.Timeout; + +/** + * Provides synchronous access to CloudStack zone features. + *

+ * + * @see OfferingAsyncClient + * @see + * @author Adrian Cole + */ +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface OfferingClient { + /** + * Lists service offerings + * + * @param options + * if present, how to constrain the list. + * @return service offerings matching query, or empty set, if no service offerings are found + */ + Set listServiceOfferings(ListServiceOfferingsOptions... options); + + /** + * get a specific service offering by id + * + * @param id + * offering to get + * @return service offering or null if not found + */ + ServiceOffering getServiceOffering(String id); + + /** + * Lists disk offerings + * + * @param options + * if present, how to constrain the list. + * @return disk offerings matching query, or empty set, if no disk offerings are found + */ + Set listDiskOfferings(ListDiskOfferingsOptions... options); + + /** + * get a specific disk offering by id + * + * @param id + * offering to get + * @return disk offering or null if not found + */ + DiskOffering getDiskOffering(String id); + + /** + * Lists service offerings + * + * @param options + * if present, how to constrain the list. + * @return service offerings matching query, or empty set, if no service offerings are found + */ + Set listNetworkOfferings(ListNetworkOfferingsOptions... options); + + /** + * get a specific service offering by id + * + * @param id + * offering to get + * @return service offering or null if not found + */ + NetworkOffering getNetworkOffering(String id); +} diff --git a/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java new file mode 100644 index 0000000000..a9fc34f53c --- /dev/null +++ b/sandbox-apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/TemplateAsyncClient.java @@ -0,0 +1,83 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.cloudstack.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.cloudstack.domain.Template; +import org.jclouds.cloudstack.filters.QuerySigner; +import org.jclouds.cloudstack.options.ListTemplatesOptions; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to cloudstack via their REST API. + *

+ * + * @see TemplateClient + * @see + * @author Adrian Cole + */ +@RequestFilters(QuerySigner.class) +@QueryParams(keys = "response", values = "json") +public interface TemplateAsyncClient { + + /** + * @see TemplateClient#listTemplates + */ + @GET + @QueryParams(keys = { "command", "templatefilter" }, values = { "listTemplates", "executable" }) + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listTemplates(); + + /** + * @see TemplateClient#listTemplates(ListTemplatesOptions) + */ + @GET + @QueryParams(keys = "command", values = "listTemplates") + @Unwrap(depth = 2) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listTemplates(ListTemplatesOptions options); + + /** + * @see TemplateClient#getTemplate + */ + @GET + @QueryParams(keys = { "command", "templatefilter" }, values = { "listTemplates", "executable" }) + @Unwrap(depth = 3, edgeCollection = Set.class) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture