You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/24 18:08:35 UTC

[01/21] git commit: Fix osgi export.

Repository: jclouds-labs
Updated Branches:
  refs/heads/1.8.x 98c19ee5f -> d1a637f19


Fix osgi export.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/576c7bcc
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/576c7bcc
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/576c7bcc

Branch: refs/heads/1.8.x
Commit: 576c7bcc1db8a464f25644e3fa03f641c9a1677f
Parents: 98c19ee
Author: Adrian Cole <ad...@gmail.com>
Authored: Thu Oct 16 09:01:10 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:34:22 2014 -0700

----------------------------------------------------------------------
 azurecompute/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/576c7bcc/azurecompute/pom.xml
----------------------------------------------------------------------
diff --git a/azurecompute/pom.xml b/azurecompute/pom.xml
index 162a77c..a6f75f7 100644
--- a/azurecompute/pom.xml
+++ b/azurecompute/pom.xml
@@ -42,7 +42,7 @@
     <test.azurecompute.build-version />
     <test.azurecompute.identity>/path/to/cert.p12</test.azurecompute.identity>
     <test.azurecompute.credential>password to cert</test.azurecompute.credential>
-    <jclouds.osgi.export>org.jclouds.azure.management*;version="${project.version}"</jclouds.osgi.export>
+    <jclouds.osgi.export>org.jclouds.azurecompute*;version="${project.version}"</jclouds.osgi.export>
     <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
   </properties>
 


[07/21] git commit: Cleanup output-only Image object.

Posted by ad...@apache.org.
Cleanup output-only Image object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/34b4fc2d
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/34b4fc2d
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/34b4fc2d

Branch: refs/heads/1.8.x
Commit: 34b4fc2d000e1790a20272065f9b984461b480c6
Parents: 497c90b
Author: Adrian Cole <ac...@twitter.com>
Authored: Thu Oct 16 19:49:17 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:40:22 2014 -0700

----------------------------------------------------------------------
 .../org/jclouds/azurecompute/domain/Image.java  | 311 ++++++-------------
 .../org/jclouds/azurecompute/domain/OSType.java |  10 +-
 .../jclouds/azurecompute/xml/ImageHandler.java  | 104 ++++---
 .../azurecompute/xml/ListImagesHandler.java     |  38 +--
 .../azurecompute/features/DiskApiLiveTest.java  |   2 +-
 .../azurecompute/features/ImageApiLiveTest.java |  88 ++----
 .../azurecompute/features/ImageApiMockTest.java |  24 +-
 .../azurecompute/parse/ListImagesTest.java      | 117 -------
 .../azurecompute/xml/ListImagesHandlerTest.java | 156 ++++++++++
 9 files changed, 378 insertions(+), 472 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
index f9f64eb..8a1e373 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
@@ -16,197 +16,54 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.net.URI;
 import java.util.List;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
 
 /**
- * OS images from the image repository
+ * OS image from the image repository
  *
  * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
  */
-public class Image {
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public Builder toBuilder() {
-      return new Builder().fromOSImage(this);
-   }
-
-   public static class Builder {
-      private OSType os;
-      private String name;
-      private Optional<Integer> logicalSizeInGB = Optional.absent();
-      private Optional<String> description = Optional.absent();
-      private Optional<String> category = Optional.absent();
-      private Optional<String> location = Optional.absent();
-      private Optional<String> affinityGroup = Optional.absent();
-      private Optional<URI> mediaLink = Optional.absent();
-      private ImmutableList.Builder<String> eula = ImmutableList.builder();
-      private String label;
-
-      /**
-       * @see Image#getOS()
-       */
-      public Builder os(OSType os) {
-         this.os = os;
-         return this;
-      }
-
-      /**
-       * @see Image#getName()
-       */
-      public Builder name(String name) {
-         this.name = name;
-         return this;
-      }
-
-      /**
-       * @see Image#getDescription()
-       */
-      public Builder description(String description) {
-         this.description = Optional.fromNullable(description);
-         return this;
-      }
-
-      /**
-       * @see Image#getLogicalSizeInGB()
-       */
-      public Builder logicalSizeInGB(Integer logicalSizeInGB) {
-         this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB);
-         return this;
-      }
-
-      /**
-       * @see Image#getCategory()
-       */
-      public Builder category(String category) {
-         this.category = Optional.fromNullable(category);
-         return this;
-      }
-
-      /**
-       * @see Image#getLocation()
-       */
-      public Builder location(String location) {
-         this.location = Optional.fromNullable(location);
-         return this;
-      }
+public final class Image {
 
-      /**
-       * @see Image#getAffinityGroup()
-       */
-      public Builder affinityGroup(String affinityGroup) {
-         this.affinityGroup = Optional.fromNullable(affinityGroup);
-         return this;
-      }
-
-      /**
-       * @see Image#getMediaLink()
-       */
-      public Builder mediaLink(URI mediaLink) {
-         this.mediaLink = Optional.fromNullable(mediaLink);
-         return this;
-      }
-
-      /**
-       * @see Image#getEula()
-       */
-      public Builder eula(Iterable<String> eula) {
-         this.eula.addAll(eula);
-         return this;
-      }
-
-      /**
-       * @see Image#getEula()
-       */
-      public Builder eula(String eula) {
-         this.eula.add(eula);
-         return this;
-      }
-
-      /**
-       * @see Image#getLabel()
-       */
-      public Builder label(String label) {
-         this.label = label;
-         return this;
-      }
-
-      public Image build() {
-         return new Image(os, name, logicalSizeInGB, description, category, location, affinityGroup, mediaLink,
-               eula.build(), label);
-      }
-
-      public Builder fromOSImage(Image in) {
-         return this.os(in.getOS()).name(in.getName()).logicalSizeInGB(in.getLogicalSizeInGB().orNull())
-                  .description(in.getDescription().orNull()).category(in.getCategory().orNull())
-                  .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull())
-                  .mediaLink(in.getMediaLink().orNull()).eula(in.getEula()).label(in.getLabel());
-      }
-   }
-
-   private final OSType os;
-   private final String name;
-   private final Optional<Integer> logicalSizeInGB;
-   private final Optional<String> description;
-   private final Optional<String> category;
-   private final Optional<String> location;
-   private final Optional<String> affinityGroup;
-   private final Optional<URI> mediaLink;
-   private final List<String> eula;
-   private final String label;
-
-   private Image(OSType os, String name, Optional<Integer> logicalSizeInGB, Optional<String> description,
-         Optional<String> category, Optional<String> location, Optional<String> affinityGroup, Optional<URI> mediaLink,
-         List<String> eula, String label) {
-      this.name = checkNotNull(name, "name");
-      this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name);
-      this.description = checkNotNull(description, "description for %s", name);
-      this.os = checkNotNull(os, "os for %s", name);
-      this.category = checkNotNull(category, "category for %s", name);
-      this.location = checkNotNull(location, "location for %s", name);
-      this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name);
-      this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name);
-      this.eula = checkNotNull(eula, "eula for %s", name);
-      this.label = checkNotNull(label, "label for %s", name);
+   public String name() {
+      return name;
    }
 
    /**
-    * The operating system type of the OS image.
+    * The geo-location of the image in Windows Azure, if the image is not
+    * associated with an affinity group. If a location has been specified, the AffinityGroup element
+    * is not returned.
     */
-   public OSType getOS() {
-      return os;
+   @Nullable public String location() {
+      return location;
    }
 
    /**
-    * The name of the hosted service. This name is the DNS prefix name and can be used to access the
-    * hosted service.
-    *
-    * For example, if the service name is MyService you could access the access the service by
-    * calling: http://MyService.cloudapp.net
+    * The affinity group with which this image is associated, if any. If the service is
+    * associated with an affinity group, the Location element is not returned.
     */
-   public String getName() {
-      return name;
+   @Nullable public String affinityGroup() {
+      return affinityGroup;
    }
 
    /**
-    * The size, in GB, of the image.
+    * The name can be up to 100 characters in length. The name can be used identify the storage account for your
+    * tracking purposes.
     */
-   public Optional<Integer> getLogicalSizeInGB() {
-      return logicalSizeInGB;
+   public String label() {
+      return label;
    }
 
-   /**
-    * The description for the image.
-    */
-   public Optional<String> getDescription() {
+   @Nullable public String description() {
       return description;
    }
 
@@ -214,26 +71,13 @@ public class Image {
     * The repository classification of image. All user images have the category "User", but
     * categories for other images could be, for example "Canonical"
     */
-   public Optional<String> getCategory() {
+   @Nullable public String category() {
       return category;
    }
 
-   /**
-    * The geo-location in which this media is located. The Location value is derived from storage
-    * account that contains the blob in which the media is located. If the storage account belongs
-    * to an affinity group the value is absent.
-    */
-   public Optional<String> getLocation() {
-      return location;
-   }
-
-   /**
-    * The affinity in which the media is located. The AffinityGroup value is derived from storage
-    * account that contains the blob in which the media is located. If the storage account does not
-    * belong to an affinity group the value is absent.
-    */
-   public Optional<String> getAffinityGroup() {
-      return affinityGroup;
+   /** The operating system type of the OS image. */
+   public OSType os() {
+      return os;
    }
 
    /**
@@ -245,53 +89,92 @@ public class Image {
     *
     * http://example.blob.core.windows.net/disks/myimage.vhd
     */
-   public Optional<URI> getMediaLink() {
+   @Nullable public URI mediaLink() {
       return mediaLink;
    }
 
-   /**
-    * The eulas for the image, if available.
-    */
+   public int logicalSizeInGB() {
+      return logicalSizeInGB;
+   }
+
+   /** The eulas for the image, if available. */
    // Not URI as some providers put non-uri data in, such as riverbed.
-   public List<String> getEula() {
+   public List<String> eula() {
       return eula;
    }
 
-   /**
-    * The description of the image.
-    */
-   public String getLabel() {
-      return label;
+   public static Image create(String name, String location, String affinityGroup, String label, String description,
+         String category, OSType os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
+      return new Image(name, location, affinityGroup, label, description, category, os, mediaLink, logicalSizeInGB,
+            eula);
    }
 
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(name);
+   // TODO: Remove from here down with @AutoValue.
+   private Image(String name, String location, String affinityGroup, String label, String description, String category,
+         OSType os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
+      this.name = checkNotNull(name, "name");
+      this.location = location;
+      this.affinityGroup = affinityGroup;
+      this.label = checkNotNull(label, "label");
+      this.description = description;
+      this.category = category;
+      this.os = checkNotNull(os, "os");
+      this.mediaLink = mediaLink;
+      this.logicalSizeInGB = logicalSizeInGB;
+      this.eula = checkNotNull(eula, "eula");
    }
 
+   private final String name;
+   private final String location;
+   private final String affinityGroup;
+   private final String label;
+   private final String category;
+   private final String description;
+   private final OSType os;
+   private final URI mediaLink;
+   private final int logicalSizeInGB;
+   private final List<String> eula;
+
    @Override
-   public boolean equals(Object obj) {
-      if (this == obj)
+   public boolean equals(Object object) {
+      if (this == object) {
          return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
+      }
+      if (object instanceof Image) {
+         Image that = Image.class.cast(object);
+         return equal(name, that.name)
+               && equal(location, that.location)
+               && equal(affinityGroup, that.affinityGroup)
+               && equal(label, that.label)
+               && equal(description, that.description)
+               && equal(category, that.category)
+               && equal(os, that.os)
+               && equal(mediaLink, that.mediaLink)
+               && equal(logicalSizeInGB, that.logicalSizeInGB)
+               && equal(eula, that.eula);
+      } else {
          return false;
-      Image other = (Image) obj;
-      return Objects.equal(this.name, other.name);
+      }
    }
 
    @Override
-   public String toString() {
-      return string().toString();
+   public int hashCode() {
+      return Objects.hashCode(name, location, affinityGroup, label, description, category, os, mediaLink,
+            logicalSizeInGB, eula);
    }
 
-   private ToStringHelper string() {
-      return Objects.toStringHelper(this).omitNullValues().add("os", os).add("name", name)
-               .add("logicalSizeInGB", logicalSizeInGB.orNull()).add("description", description)
-               .add("category", category.orNull()).add("location", location.orNull())
-               .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull())
-               .add("eula", eula).add("label", label);
+   @Override
+   public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("location", location)
+            .add("affinityGroup", affinityGroup)
+            .add("label", label)
+            .add("description", description)
+            .add("category", category)
+            .add("os", os)
+            .add("mediaLink", mediaLink)
+            .add("logicalSizeInGB", logicalSizeInGB)
+            .add("eula", eula).toString();
    }
-
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
index fd85bde..c81b590 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
@@ -16,20 +16,18 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.CaseFormat;
-
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 public enum OSType {
 
    LINUX,
-
    WINDOWS,
-
    UNRECOGNIZED;
 
    public String value() {
-      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
+      return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
    }
 
    @Override
@@ -39,7 +37,7 @@ public enum OSType {
 
    public static OSType fromValue(String type) {
       try {
-         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
+         return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, checkNotNull(type, "type")));
       } catch (IllegalArgumentException e) {
          return UNRECOGNIZED;
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
index 1182c64..c53888d 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
@@ -16,73 +16,91 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
+import static com.google.common.base.Strings.emptyToNull;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
 import java.net.URI;
+import java.util.List;
+
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.SAXException;
 
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 
 /**
  * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
  */
-public class ImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Image> {
+final class ImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Image> {
+   private String name;
+   private String location;
+   private String affinityGroup;
+   private String label;
+   private String category;
+   private String description;
+   private OSType os;
+   private URI mediaLink;
+   private Integer logicalSizeInGB;
+   private final List<String> eula = Lists.newArrayList();
 
-   private StringBuilder currentText = new StringBuilder();
-   private Image.Builder builder = Image.builder();
+   private final StringBuilder currentText = new StringBuilder();
 
-   @Override
-   public Image getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = Image.builder();
-      }
+   @Override public Image getResult() {
+      Image result = Image.create(name, location, affinityGroup, label, description, category, os, mediaLink,
+            logicalSizeInGB, ImmutableList.copyOf(eula));
+      resetState(); // handler is called in a loop.
+      return result;
+   }
+
+   private void resetState() {
+      name = location = affinityGroup = label = description = category = null;
+      os = null;
+      mediaLink = null;
+      logicalSizeInGB = null;
+      eula.clear();
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
-      if (equalsOrSuffix(qName, "OS")) {
-         builder.os(OSType.fromValue(currentOrNull(currentText)));
-      } else if (equalsOrSuffix(qName, "Name")) {
-         builder.name(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "LogicalSizeInGB")) {
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("OS")) {
+         os = OSType.fromValue(currentOrNull(currentText));
+      } else if (qName.equals("Name")) {
+         name = currentOrNull(currentText);
+      } else if (qName.equals("LogicalSizeInGB")) {
          String gb = currentOrNull(currentText);
-         if (gb != null)
-            builder.logicalSizeInGB(Integer.parseInt(gb));
-      } else if (equalsOrSuffix(qName, "Description")) {
-         builder.description(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "Category")) {
-         builder.category(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "Location")) {
-         builder.location(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "AffinityGroup")) {
-         builder.affinityGroup(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "MediaLink")) {
+         if (gb != null) {
+            logicalSizeInGB = Integer.parseInt(gb);
+         }
+      } else if (qName.equals("Description")) {
+         description = currentOrNull(currentText);
+      } else if (qName.equals("Category")) {
+         category = currentOrNull(currentText);
+      } else if (qName.equals("Location")) {
+         location = currentOrNull(currentText);
+      } else if (qName.equals("AffinityGroup")) {
+         affinityGroup = currentOrNull(currentText);
+      } else if (qName.equals("MediaLink")) {
          String link = currentOrNull(currentText);
-         if (link != null)
-            builder.mediaLink(URI.create(link));
-      } else if (equalsOrSuffix(qName, "Eula")) {
+         if (link != null) {
+            mediaLink = URI.create(link);
+         }
+      } else if (qName.equals("Eula")) {
          String eulaField = currentOrNull(currentText);
          if (eulaField != null) {
             for (String eula : Splitter.on(';').split(eulaField)) {
-               if ((eula = Strings.emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eula field.
-                  builder.eula(eula);
+               if ((eula = emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eula field.
+                  this.eula.add(eula);
                }
             }
          }
-      } else if (equalsOrSuffix(qName, "Label")) {
-         builder.label(currentOrNull(currentText));
+      } else if (qName.equals("Label")) {
+         label = currentOrNull(currentText);
       }
-      currentText = new StringBuilder();
+      currentText.setLength(0);
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       currentText.append(ch, start, length);
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
index beae350..f220f8c 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
@@ -16,58 +16,46 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.inject.Inject;
 import java.util.List;
+
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
 
-public class ListImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Image>> {
-
-   private final ImageHandler locationHandler;
-
-   private Builder<Image> locations = ImmutableList.<Image> builder();
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
 
+public final class ListImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Image>> {
    private boolean inOSImage;
-
-   @Inject
-   public ListImagesHandler(ImageHandler locationHandler) {
-      this.locationHandler = locationHandler;
-   }
+   private final ImageHandler imageHandler = new ImageHandler();
+   private final Builder<Image> images = ImmutableList.builder();
 
    @Override
    public List<Image> getResult() {
-      return locations.build();
+      return images.build();
    }
 
    @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
-      if (SaxUtils.equalsOrSuffix(qName, "OSImage")) {
+   public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("OSImage")) {
          inOSImage = true;
       }
-      if (inOSImage) {
-         locationHandler.startElement(url, name, qName, attributes);
-      }
    }
 
    @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   public void endElement(String uri, String name, String qName) {
       if (qName.equals("OSImage")) {
          inOSImage = false;
-         locations.add(locationHandler.getResult());
+         images.add(imageHandler.getResult());
       } else if (inOSImage) {
-         locationHandler.endElement(uri, name, qName);
+         imageHandler.endElement(uri, name, qName);
       }
    }
 
    @Override
    public void characters(char ch[], int start, int length) {
       if (inOSImage) {
-         locationHandler.characters(ch, start, length);
+         imageHandler.characters(ch, start, length);
       }
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index eb16847..478b1b3 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -52,7 +52,7 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
       images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function<Image, String>() {
          @Override
          public String apply(Image in) {
-            return in.getName();
+            return in.name();
          }
       }));
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
index 3507147..2b1aaf0 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
@@ -16,9 +16,12 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.Location;
 import org.jclouds.azurecompute.domain.OSType;
@@ -26,11 +29,8 @@ import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.transform;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
 
 @Test(groups = "live", testName = "ImageApiLiveTest")
 public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
@@ -41,65 +41,41 @@ public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
    public void setup() {
       super.setup();
 
-      locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(),
-               new Function<Location, String>() {
-                  @Override
-                  public String apply(Location in) {
-                     return in.getName();
-                  }
-               }));
+      locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
+         public String apply(Location in) {
+            return in.getName();
+         }
+      }));
    }
 
-   @Test
-   protected void testList() {
-      List<Image> response = api().list();
-
-      for (Image image : response) {
+   public void testList() {
+      for (Image image : api().list()) {
          checkOSImage(image);
       }
    }
 
    private void checkOSImage(Image image) {
-      checkNotNull(image.getLabel(), "Label cannot be null for OSImage %s", image);
-      checkNotNull(image.getName(), "Name cannot be null for OSImage %s", image.getLabel());
-      checkNotNull(image.getOS(), "OS cannot be null for OSImage: %s", image);
-      assertNotEquals(image.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for OSImage: " + image);
-
-      checkNotNull(image.getCategory(), "While Category can be null for OSImage, its Optional wrapper cannot: %s",
-               image);
-      if (image.getCategory().isPresent())
-         assertNotEquals("", image.getCategory().get().trim(), "Invalid Category: " + image.toString());
-
-      checkNotNull(image.getLogicalSizeInGB(),
-               "While LogicalSizeInGB can be null for OSImage, its Optional wrapper cannot: %s", image);
-
-      if (image.getLogicalSizeInGB().isPresent())
-         assertTrue(image.getLogicalSizeInGB().get() > 0,
-                  "LogicalSizeInGB should be positive, if set" + image.toString());
-
-      checkNotNull(image.getMediaLink(), "While MediaLink can be null for OSImage, its Optional wrapper cannot: %s",
-               image);
-
-      if (image.getMediaLink().isPresent())
-         assertTrue(ImmutableSet.of("http", "https").contains(image.getMediaLink().get().getScheme()),
-                  "MediaLink should be an http(s) url" + image.toString());
-
-      checkNotNull(image.getDescription(),
-               "While Description can be null for OSImage, its Optional wrapper cannot: %s", image);
+      assertNotNull(image.label(), "Label cannot be null for " + image);
+      assertNotNull(image.name(), "Name cannot be null for " + image);
+      assertNotNull(image.os(), "OS cannot be null for " + image);
+      assertNotEquals(image.os(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for " + image);
+      assertTrue(image.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + image);
+
+      if (image.category() != null) {
+         assertNotEquals("", image.category().trim(), "Invalid Category for " + image);
+      }
 
-      checkNotNull(image.getLocation(), "While Location can be null for OSImage, its Optional wrapper cannot: %s",
-               image);
-      if (image.getLocation().isPresent()) {
-         assertTrue(locations.contains(image.getLocation().get()),
-                  "Location not in " + locations + " :" + image.toString());
+      if (image.mediaLink() != null) {
+         assertTrue(ImmutableSet.of("http", "https").contains(image.mediaLink().getScheme()),
+               "MediaLink should be an http(s) url" + image);
+      }
+      if (image.location() != null) {
+         assertTrue(locations.contains(image.location()), "Location not in " + locations + " :" + image);
       }
 
       // Ex. Dirty data in RightScale eula field comes out as an empty string.
-      assertThat(image.getEula()).isNotNull().doesNotContain("");
-
-      checkNotNull(image.getAffinityGroup(),
-               "While AffinityGroup can be null for OSImage, its Optional wrapper cannot: %s", image);
-      if (image.getAffinityGroup().isPresent()) {
+      assertFalse(image.eula().contains(""));
+      if (image.affinityGroup() != null) {
          // TODO: list getAffinityGroups and check if there
       }
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
index 6c7b5c4..be3d9d7 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
@@ -16,16 +16,20 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
 import java.net.URI;
+
 import org.jclouds.azurecompute.domain.ImageParams;
 import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.parse.ListImagesTest;
+import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "ImageApiMockTest")
 public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
@@ -37,7 +41,7 @@ public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          ImageApi api = api(server.getUrl("/")).getImageApi();
 
-         assertThat(api.list()).containsExactlyElementsOf(ListImagesTest.expected());
+         assertEquals(api.list(), ListImagesHandlerTest.expected());
 
          assertSent(server, "GET", "/services/images");
       } finally {
@@ -52,7 +56,7 @@ public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          ImageApi api = api(server.getUrl("/")).getImageApi();
 
-         assertThat(api.list()).isEmpty();
+         assertTrue(api.list().isEmpty());
 
          assertSent(server, "GET", "/services/images");
       } finally {
@@ -70,7 +74,7 @@ public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
          ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
                .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
 
-         assertThat(api.add(params)).isEqualTo("request-1");
+         assertEquals(api.add(params), "request-1");
 
          assertSent(server, "POST", "/services/images", "/imageparams.xml");
       } finally {
@@ -88,7 +92,7 @@ public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
          ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
                .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
 
-         assertThat(api.update(params)).isEqualTo("request-1");
+         assertEquals(api.update(params), "request-1");
 
          assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
       } finally {
@@ -103,7 +107,7 @@ public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          ImageApi api = api(server.getUrl("/")).getImageApi();
 
-         assertThat(api.delete("myimage")).isEqualTo("request-1");
+         assertEquals(api.delete("myimage"), "request-1");
 
          assertSent(server, "DELETE", "/services/images/myimage");
       } finally {
@@ -118,7 +122,7 @@ public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          ImageApi api = api(server.getUrl("/")).getImageApi();
 
-         assertThat(api.delete("myimage")).isNull();
+         assertNull(api.delete("myimage"));
 
          assertSent(server, "DELETE", "/services/images/myimage");
       } finally {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java
deleted file mode 100644
index d9e19b3..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import com.google.common.collect.ImmutableList;
-import java.io.InputStream;
-import java.util.List;
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.OSType;
-import org.jclouds.azurecompute.xml.ListImagesHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Test(groups = "unit", testName = "ListOSImagesTest")
-public class ListImagesTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/images.xml");
-
-      ListImagesHandler handler = injector.getInstance(ListImagesHandler.class);
-      List<Image> result = factory.create(handler).parse(is);
-
-      assertThat(result).usingFieldByFieldElementComparator().containsExactlyElementsOf(expected());
-   }
-
-   public static List<Image> expected() {
-      return ImmutableList.<Image>builder()
-         .add(Image.builder()
-                   .category("Canonical")
-                   .label("Ubuntu Server 12.04 LTS")
-                   .logicalSizeInGB(30)
-                   .name("CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd")
-                   .os(OSType.LINUX)
-                   .eula("http://www.ubuntu.com/project/about-ubuntu/licensing")
-                   .description("Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image").build())
-         .add(Image.builder()
-                   .category("Microsoft")
-                   .label("Windows Server 2008 R2 SP1, June 2012")
-                   .logicalSizeInGB(30)
-                   .name("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd")
-                   .os(OSType.WINDOWS)
-                   .description("Windows Server 2008 R2 is a multi-purpose server.").build())
-         .add(Image.builder()
-                   .category("Microsoft")
-                   .label("Microsoft SQL Server 2012 Evaluation Edition")
-                   .logicalSizeInGB(30)
-                   .name("MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd")
-                   .os(OSType.WINDOWS)
-                   .eula("http://go.microsoft.com/fwlink/?LinkID=251820") // NOTE multiple eula.
-                   .eula("http://go.microsoft.com/fwlink/?LinkID=131004")
-                   .description("SQL Server 2012 Evaluation Edition (64-bit).").build())
-         .add(Image.builder()
-                   .category("Microsoft")
-                   .label("Windows Server 2012 Release Candidate, July 2012")
-                   .logicalSizeInGB(30)
-                   .name("MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd")
-                   .os(OSType.WINDOWS)
-                   .description("Windows Server 2012 incorporates Microsoft's experience building.").build())
-         .add(Image.builder()
-                   .category("Microsoft")
-                   .label("Windows Server 2008 R2 SP1, July 2012")
-                   .logicalSizeInGB(30)
-                   .name("MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd")
-                   .os(OSType.WINDOWS)
-                   .description("Windows Server 2008 R2 is a multi-purpose server.")
-                   .build())
-         .add(Image.builder()
-                   .category("OpenLogic")
-                   .label("OpenLogic CentOS 6.2")
-                   .logicalSizeInGB(30)
-                   .name("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd")
-                   .os(OSType.LINUX)
-                   .eula("http://www.openlogic.com/azure/service-agreement/")
-                   .description("This distribution of Linux is based on CentOS.").build())
-         .add(Image.builder()
-                   .category("SUSE")
-                   .label("openSUSE 12.1")
-                   .logicalSizeInGB(30)
-                   .name("SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd")
-                   .os(OSType.LINUX)
-                   .eula("http://opensuse.org/")
-                   .description("openSUSE is a free and Linux-based operating system!")
-                   .build())
-         .add(Image.builder()
-                   .category("SUSE")
-                   .label("SUSE Linux Enterprise Server")
-                   .logicalSizeInGB(30)
-                   .name("SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd")
-                   .os(OSType.LINUX)
-                   .eula("http://www.novell.com/licensing/eula/")
-                   .description("SUSE Linux Enterprise Server is a highly reliable value.").build())
-         .add(Image.builder()
-                   .category("RightScale with Linux")
-                   .label("RightImage-CentOS-6.4-x64-v13.4")
-                   .logicalSizeInGB(10)
-                   .name("0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4")
-                   .os(OSType.LINUX) // No EULA, as RightScale stuffed ';' into the field.
-                   .build()).build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/34b4fc2d/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
new file mode 100644
index 0000000..823a6e2
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListImagesHandlerTest")
+public class ListImagesHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/images.xml");
+      List<Image> result = factory.create(new ListImagesHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<Image> expected() {
+      return ImmutableList.of( //
+            Image.create( //
+                  "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "Ubuntu Server 12.04 LTS", // label
+                  "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
+                  "Canonical", // category
+                  OSType.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
+            ),
+            Image.create( //
+                  "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "Windows Server 2008 R2 SP1, June 2012", // label
+                  "Windows Server 2008 R2 is a multi-purpose server.", //description
+                  "Microsoft", // category
+                  OSType.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            Image.create( //
+                  "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "Microsoft SQL Server 2012 Evaluation Edition", // label
+                  "SQL Server 2012 Evaluation Edition (64-bit).", //description
+                  "Microsoft", // category
+                  OSType.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
+                                "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
+            ),
+            Image.create( //
+                  "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "Windows Server 2012 Release Candidate, July 2012", // label
+                  "Windows Server 2012 incorporates Microsoft's experience building.", //description
+                  "Microsoft", // category
+                  OSType.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            Image.create( //
+                  "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "Windows Server 2008 R2 SP1, July 2012", // label
+                  "Windows Server 2008 R2 is a multi-purpose server.", //description
+                  "Microsoft", // category
+                  OSType.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            Image.create( //
+                  "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "OpenLogic CentOS 6.2", // label
+                  "This distribution of Linux is based on CentOS.", //description
+                  "OpenLogic", // category
+                  OSType.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
+            ),
+            Image.create( //
+                  "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "openSUSE 12.1", // label
+                  "openSUSE is a free and Linux-based operating system!", //description
+                  "SUSE", // category
+                  OSType.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://opensuse.org/") // eula
+            ),
+            Image.create( //
+                  "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
+                  null, // location
+                  null, // affinityGroup
+                  "SUSE Linux Enterprise Server", // label
+                  "SUSE Linux Enterprise Server is a highly reliable value.", //description
+                  "SUSE", // category
+                  OSType.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.novell.com/licensing/eula/") // eula
+            ),
+            Image.create( //
+                  "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
+                  null, // location
+                  null, // affinityGroup
+                  "RightImage-CentOS-6.4-x64-v13.4", // label
+                  null, //description
+                  "RightScale with Linux", // category
+                  OSType.LINUX, // os
+                  null, // mediaLink
+                  10, // logicalSizeInGB
+                  Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
+            )
+      );
+   }
+}


[11/21] git commit: Cleanup output-only Operation object.

Posted by ad...@apache.org.
Cleanup output-only Operation object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/02b139e6
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/02b139e6
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/02b139e6

Branch: refs/heads/1.8.x
Commit: 02b139e6f651f1d077c3c5096d366287eb7d430d
Parents: 9da9795
Author: Adrian Cole <ac...@twitter.com>
Authored: Mon Oct 20 09:59:13 2014 -0400
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:56:24 2014 -0700

----------------------------------------------------------------------
 .../jclouds/azurecompute/domain/Operation.java  | 179 +++++--------------
 .../azurecompute/xml/OperationHandler.java      |  83 ++++-----
 .../features/HostedServiceApiLiveTest.java      |   2 +-
 .../features/OperationApiMockTest.java          |  14 +-
 .../azurecompute/parse/GetOperationTest.java    |  53 ------
 .../azurecompute/xml/OperationHandlerTest.java  |  41 +++++
 6 files changed, 125 insertions(+), 247 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/02b139e6/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
index 8728ad3..0c0b02a 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java
@@ -16,167 +16,62 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-
+import static com.google.common.base.Objects.equal;
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
 /**
  *
- * Determines whether the operation has succeeded, failed, or is still in progress.
+ * Determines whether the asynchronous operation has succeeded, failed, or is still in progress.
  *
  * @see <a href="http://msdn.microsoft.com/en-us/library/ee460783" >api</a>
  */
-public class Operation {
-
-   public static enum Status {
-
-      IN_PROGRESS,
-
-      SUCCEEDED,
-
-      FAILED,
-
+public final class Operation {
+   public enum Status {
+      IN_PROGRESS, SUCCEEDED, FAILED,
       UNRECOGNIZED;
-
-      public String value() {
-         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-      }
-
-      @Override
-      public String toString() {
-         return value();
-      }
-
-      public static Status fromValue(String status) {
-         try {
-            return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
-         } catch (IllegalArgumentException e) {
-            return UNRECOGNIZED;
-         }
-      }
-   }
-
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public Builder toBuilder() {
-      return builder().fromOperation(this);
    }
 
-   public static class Builder {
-
-      private String id;
-      private String rawStatus;
-      private Status status;
-      // When the operation is in progress, no status code is returned
-      private Optional<Integer> httpStatusCode = Optional.absent();
-      private Optional<Error> error = Optional.absent();
-
-      /**
-       * @see Operation#getId()
-       */
-      public Builder id(String id) {
-         this.id = id;
-         return this;
-      }
-
-      /**
-       * @see Operation#getRawStatus()
-       */
-      public Builder rawStatus(String rawStatus) {
-         this.rawStatus = rawStatus;
-         return this;
-      }
-
-      /**
-       * @see Operation#getStatus()
-       */
-      public Builder status(Status status) {
-         this.status = status;
-         return this;
-      }
-
-      /**
-       * @see Operation#getHttpStatusCode()
-       */
-      public Builder httpStatusCode(Integer httpStatusCode) {
-         this.httpStatusCode = Optional.fromNullable(httpStatusCode);
-         return this;
-      }
-
-      /**
-       * @see Operation#getError()
-       */
-      public Builder error(Error error) {
-         this.error = Optional.fromNullable(error);
-         return this;
-      }
-
-      public Operation build() {
-         return new Operation(id, rawStatus, status, httpStatusCode, error);
-      }
-
-      public Builder fromOperation(Operation in) {
-         return this.id(in.id).rawStatus(in.rawStatus).status(in.status).httpStatusCode(in.httpStatusCode.orNull())
-                  .error(in.error.orNull());
-      }
+   public String id() {
+      return id;
    }
 
-   private final String id;
-   private final String rawStatus;
-   private final Status status;
-   private final Optional<Integer> httpStatusCode;
-   private final Optional<Error> error;
-
-   protected Operation(String id, String rawStatus, Status status, Optional<Integer> httpStatusCode, Optional<Error> error) {
-      this.id = checkNotNull(id, "id");
-      this.rawStatus = checkNotNull(rawStatus, "rawStatus for %s", id);
-      this.status = checkNotNull(status, "status for %s", id);
-      this.httpStatusCode = checkNotNull(httpStatusCode, "httpStatusCode for %s", id);
-      this.error = checkNotNull(error, "error for %s", id);
+   public Status status() {
+      return status;
    }
 
-   /**
-    * The request ID of the asynchronous request.
-    */
-   public String getId() {
-      return id;
+   @Nullable public Integer httpStatusCode() {
+      return httpStatusCode;
    }
 
-   /**
-    * The status of the asynchronous request.
-    */
-   public Status getStatus() {
-      return status;
+   /** Present when the operation {@link Status#FAILED failed}. */
+   @Nullable public Error error() {
+      return error;
    }
 
-   /**
-    * The status of the asynchronous request, unparsed
-    */
-   public String getRawStatus() {
-      return rawStatus;
+   public static Operation create(String id, Status status, Integer httpStatusCode, Error error) {
+      return new Operation(id, status, httpStatusCode, error);
    }
 
-   /**
-    * The HTTP status code for the asynchronous request.
-    */
-   public Optional<Integer> getHttpStatusCode() {
-      return httpStatusCode;
+   // TODO: Remove from here down with @AutoValue.
+   private Operation(String id, Status status, Integer httpStatusCode, Error error) {
+      this.id = checkNotNull(id, "id");
+      this.status = checkNotNull(status, "status");
+      this.httpStatusCode = httpStatusCode;
+      this.error = error;
    }
 
-   /**
-    * The management service error returned if the asynchronous request failed.
-    */
-   public Optional<Error> getError() {
-      return error;
-   }
+   private final String id;
+   private final Status status;
+   private final Integer httpStatusCode;
+   private final Error error;
 
    @Override
    public int hashCode() {
-      return Objects.hashCode(id);
+      return Objects.hashCode(id, status, httpStatusCode, error);
    }
 
    @Override
@@ -188,12 +83,18 @@ public class Operation {
       if (getClass() != obj.getClass())
          return false;
       Operation other = (Operation) obj;
-      return Objects.equal(this.id, other.id);
+      return equal(this.id, other.id) &&
+            equal(this.status, other.status) &&
+            equal(this.httpStatusCode, other.httpStatusCode) &&
+            equal(this.error, other.error);
    }
 
    @Override
    public String toString() {
-      return Objects.toStringHelper(this).omitNullValues().add("id", id).add("status", rawStatus)
-               .add("httpStatusCode", httpStatusCode).add("error", error.orNull()).toString();
+      return Objects.toStringHelper(this)
+            .add("id", id)
+            .add("status", status)
+            .add("httpStatusCode", httpStatusCode)
+            .add("error", error).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/02b139e6/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java
index 05858f6..e417be1 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java
@@ -16,82 +16,69 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import javax.inject.Inject;
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import org.jclouds.azurecompute.domain.Error;
 import org.jclouds.azurecompute.domain.Operation;
-import org.jclouds.azurecompute.domain.Operation.Builder;
 import org.jclouds.azurecompute.domain.Operation.Status;
 import org.jclouds.http.functions.ParseSax;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
 
 /**
  * @see <a href="http://msdn.microsoft.com/en-us/library/ee460783" >api</a>
  */
-public class OperationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Operation> {
-
-   private final ErrorHandler errorHandler;
-
-   @Inject
-   private OperationHandler(ErrorHandler errorHandler) {
-      this.errorHandler = errorHandler;
-   }
-
-   private StringBuilder currentText = new StringBuilder();
-   private Operation.Builder builder = builder();
-
-   private Builder builder() {
-      return Operation.builder();
-   }
+public final class OperationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Operation> {
+   private String id;
+   private Status status;
+   private Integer httpStatusCode;
+   private Error error;
 
    private boolean inError;
+   private final ErrorHandler errorHandler = new ErrorHandler();
+   private final StringBuilder currentText = new StringBuilder();
 
-   @Override
-   public Operation getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = builder();
-      }
+   @Override public Operation getResult() {
+      return Operation.create(id, status, httpStatusCode, error);
    }
 
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
-      if (equalsOrSuffix(qName, "Error")) {
+   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("Error")) {
          inError = true;
       }
-      if (inError) {
-         errorHandler.startElement(url, name, qName, attributes);
-      }
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
-      if (equalsOrSuffix(qName, "Error")) {
-         builder.error(errorHandler.getResult());
+   @Override public void endElement(String uri, String name, String qName) {
+      if (qName.equals("Error")) {
+         error = errorHandler.getResult();
          inError = false;
       } else if (inError) {
          errorHandler.endElement(uri, name, qName);
-      } else if (equalsOrSuffix(qName, "ID")) {
-         builder.id(currentOrNull(currentText));
+      } else if (qName.equals("ID")) {
+         id = currentOrNull(currentText);
       } else if (qName.equals("Status")) {
-         String rawStatus = currentOrNull(currentText);
-         builder.rawStatus(rawStatus);
-         builder.status(Status.fromValue(rawStatus));
-      } else if (equalsOrSuffix(qName, "HttpStatusCode")) {
-         builder.httpStatusCode(Integer.parseInt(currentOrNull(currentText)));
+         String statusText = currentOrNull(currentText);
+         status = parseStatus(statusText);
+      } else if (qName.equals("HttpStatusCode")) {
+         httpStatusCode = Integer.parseInt(currentOrNull(currentText));
       }
-      currentText = new StringBuilder();
+      currentText.setLength(0);
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       if (inError) {
          errorHandler.characters(ch, start, length);
       } else {
          currentText.append(ch, start, length);
       }
    }
+
+   private static Status parseStatus(String status) {
+      try {
+         return Status.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, status));
+      } catch (IllegalArgumentException e) {
+         return Status.UNRECOGNIZED;
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/02b139e6/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
index eb0eec8..894c0de 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
@@ -57,7 +57,7 @@ public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
       location = Iterables.get(api.getLocationApi().list(), 0).name();
       operationSucceeded = retry(new Predicate<String>() {
          public boolean apply(String input) {
-            return api.getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED;
+            return api.getOperationApi().get(input).status() == Operation.Status.SUCCEEDED;
          }
       }, 600, 5, 5, SECONDS);
       hostedServiceCreated = retry(new Predicate<HostedService>() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/02b139e6/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java
index 2298bc0..dae2053 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java
@@ -16,13 +16,15 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.parse.GetOperationTest;
+import org.jclouds.azurecompute.xml.OperationHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "OperationApiMockTest")
 public class OperationApiMockTest extends BaseAzureComputeApiMockTest {
@@ -34,7 +36,7 @@ public class OperationApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          OperationApi api = api(server.getUrl("/")).getOperationApi();
 
-         assertThat(api.get("request-id")).isEqualTo(GetOperationTest.expected());
+         assertEquals(api.get("request-id"), OperationHandlerTest.expected());
 
          assertSent(server, "GET", "/operations/request-id");
       } finally {
@@ -49,7 +51,7 @@ public class OperationApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          OperationApi api = api(server.getUrl("/")).getOperationApi();
 
-         assertThat(api.get("request-id")).isNull();
+         assertNull(api.get("request-id"));
 
          assertSent(server, "GET", "/operations/request-id");
       } finally {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/02b139e6/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
deleted file mode 100644
index 8e41f81..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-
-import org.jclouds.azurecompute.domain.Operation;
-import org.jclouds.azurecompute.domain.Operation.Status;
-import org.jclouds.azurecompute.xml.ErrorHandlerTest;
-import org.jclouds.azurecompute.xml.OperationHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "GetOperationTest")
-public class GetOperationTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/operation.xml");
-
-      Operation expected = expected();
-
-      OperationHandler handler = injector.getInstance(OperationHandler.class);
-      Operation result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-   }
-
-   public static Operation expected() {
-      return Operation.builder()
-                      .id("request-id")
-                      .rawStatus("Failed")
-                      .status(Status.FAILED)
-                      .httpStatusCode(400)
-                      .error(ErrorHandlerTest.expected())
-                      .build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/02b139e6/azurecompute/src/test/java/org/jclouds/azurecompute/xml/OperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/OperationHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/OperationHandlerTest.java
new file mode 100644
index 0000000..635c5df
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/OperationHandlerTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.azurecompute.domain.Operation;
+import org.jclouds.azurecompute.domain.Operation.Status;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "OperationHandlerTest")
+public class OperationHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/operation.xml");
+      Operation result = factory.create(new OperationHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static Operation expected() {
+      return Operation.create("request-id", Status.FAILED, 400, ErrorHandlerTest.expected());
+   }
+}


[18/21] git commit: Rename Azure HostedService -> CloudService to match documentation.

Posted by ad...@apache.org.
Rename Azure HostedService -> CloudService to match documentation.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/99633575
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/99633575
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/99633575

Branch: refs/heads/1.8.x
Commit: 996335751010f31945527ee5e933d123c5a22f4f
Parents: d1f10e3
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Oct 21 21:55:20 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:06:05 2014 -0700

----------------------------------------------------------------------
 .../jclouds/azurecompute/AzureComputeApi.java   |   9 +-
 .../azurecompute/domain/CloudService.java       | 178 +++++++++++++++++++
 .../jclouds/azurecompute/domain/Deployment.java |   2 +-
 .../org/jclouds/azurecompute/domain/Disk.java   |   2 +-
 .../azurecompute/domain/HostedService.java      | 178 -------------------
 .../azurecompute/features/CloudServiceApi.java  | 130 ++++++++++++++
 .../azurecompute/features/HostedServiceApi.java | 130 --------------
 .../jclouds/azurecompute/features/ImageApi.java |   4 +-
 .../azurecompute/features/LocationApi.java      |   2 +-
 .../azurecompute/xml/CloudServiceHandler.java   | 127 +++++++++++++
 .../azurecompute/xml/HostedServiceHandler.java  | 127 -------------
 .../xml/ListCloudServicesHandler.java           |  69 +++++++
 .../xml/ListHostedServicesHandler.java          |  69 -------
 .../features/CloudServiceApiLiveTest.java       | 143 +++++++++++++++
 .../features/CloudServiceApiMockTest.java       | 138 ++++++++++++++
 .../features/HostedServiceApiLiveTest.java      | 145 ---------------
 .../features/HostedServiceApiMockTest.java      | 138 --------------
 .../xml/CloudServiceHandlerTest.java            |  55 ++++++
 .../xml/HostedServiceHandlerTest.java           |  55 ------
 .../xml/ListCloudServicesHandlerTest.java       |  71 ++++++++
 .../xml/ListHostedServicesHandlerTest.java      |  71 --------
 .../src/test/resources/hostedservice.xml        |   2 +-
 .../src/test/resources/hostedservices.xml       |   2 +-
 23 files changed, 923 insertions(+), 924 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
index 7dc946b..ec037a3 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
@@ -18,9 +18,10 @@ package org.jclouds.azurecompute;
 
 import java.io.Closeable;
 import javax.ws.rs.PathParam;
+
+import org.jclouds.azurecompute.features.CloudServiceApi;
 import org.jclouds.azurecompute.features.DeploymentApi;
 import org.jclouds.azurecompute.features.DiskApi;
-import org.jclouds.azurecompute.features.HostedServiceApi;
 import org.jclouds.azurecompute.features.ImageApi;
 import org.jclouds.azurecompute.features.LocationApi;
 import org.jclouds.azurecompute.features.OperationApi;
@@ -37,7 +38,7 @@ import org.jclouds.rest.annotations.Delegate;
 public interface AzureComputeApi extends Closeable {
    /**
     * The Service Management API includes operations for listing the available data center locations
-    * for a hosted service in your subscription.
+    * for a cloud service in your subscription.
     *
     * @see <a href="http://msdn.microsoft.com/en-us/library/gg441299">docs</a>
     */
@@ -45,13 +46,13 @@ public interface AzureComputeApi extends Closeable {
    LocationApi getLocationApi();
 
    /**
-    * The Service Management API includes operations for managing the hosted services beneath your
+    * The Service Management API includes operations for managing the cloud services beneath your
     * subscription.
     *
     * @see <a href="http://msdn.microsoft.com/en-us/library/ee460812">docs</a>
     */
    @Delegate
-   HostedServiceApi getHostedServiceApi();
+   CloudServiceApi getCloudServiceApi();
 
    /**
     * The Service Management API includes operations for managing the virtual machines in your

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
new file mode 100644
index 0000000..bc29be7
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CloudService.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * System properties for the specified cloud service. These properties include the service name and
+ * service type; the name of the affinity group to which the service belongs, or its location if it
+ * is not part of an affinity group.
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
+ */
+public final class CloudService {
+   public enum Status {
+      CREATING, CREATED, DELETING, DELETED, CHANGING, RESOLVING_DNS,
+      UNRECOGNIZED;
+   }
+
+   /**
+    * The name of the cloud service. This name is the DNS prefix name and can be used to access the
+    * cloud service.
+    *
+    * <p/>For example, if the service name is MyService you could access the access the service by
+    * calling: http://MyService.cloudapp.net
+    */
+   public String name() {
+      return name;
+   }
+
+   /**
+    * The geo-location of the cloud service in Windows Azure, if the cloud service is not
+    * associated with an affinity group. If a location has been specified, the AffinityGroup element
+    * is not returned.
+    */
+   @Nullable public String location() {
+      return location;
+   }
+
+   /**
+    * The affinity group with which this cloud service is associated, if any. If the service is
+    * associated with an affinity group, the Location element is not returned.
+    */
+   @Nullable public String affinityGroup() {
+      return affinityGroup;
+   }
+
+   /**
+    * The name can be up to 100 characters in length. The name can be used identify the storage account for your
+    * tracking purposes.
+    */
+   public String label() {
+      return label;
+   }
+
+   @Nullable public String description() {
+      return description;
+   }
+
+   public Status status() {
+      return status;
+   }
+
+   public Date created() {
+      return created;
+   }
+
+   public Date lastModified() {
+      return lastModified;
+   }
+
+   /**
+    * Represents the name of an extended cloud service property. Each extended property must have
+    * both a defined name and value. You can have a maximum of 50 extended property name/value
+    * pairs.
+    *
+    * <p/>The maximum length of the Name element is 64 characters, only alphanumeric characters and
+    * underscores are valid in the Name, and the name must start with a letter. Each extended
+    * property value has a maximum length of 255 characters.
+    */
+   public Map<String, String> extendedProperties() {
+      return extendedProperties;
+   }
+
+   public static CloudService create(String name, String location, String affinityGroup, String label,
+         String description, Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
+      return new CloudService(name, location, affinityGroup, label, description, status, created, lastModified,
+            extendedProperties);
+   }
+
+   // TODO: Remove from here down with @AutoValue.
+   private CloudService(String name, String location, String affinityGroup, String label, String description,
+         Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
+      this.name = checkNotNull(name, "name");
+      this.location = location;
+      this.affinityGroup = affinityGroup;
+      this.label = checkNotNull(label, "label");
+      this.description = description;
+      this.status = checkNotNull(status, "status");
+      this.created = checkNotNull(created, "created");
+      this.lastModified = checkNotNull(lastModified, "lastModified");
+      this.extendedProperties = checkNotNull(extendedProperties, "extendedProperties");
+   }
+
+   private final String name;
+   private final String location;
+   private final String affinityGroup;
+   private final String label;
+   private final String description;
+   private final Status status;
+   private final Date created;
+   private final Date lastModified;
+   private final Map<String, String> extendedProperties;
+
+   @Override
+   public boolean equals(Object object) {
+      if (this == object) {
+         return true;
+      }
+      if (object instanceof CloudService) {
+         CloudService that = CloudService.class.cast(object);
+         return equal(name, that.name)
+               && equal(location, that.location)
+               && equal(affinityGroup, that.affinityGroup)
+               && equal(label, that.label)
+               && equal(description, that.description)
+               && equal(status, that.status)
+               && equal(created, that.created)
+               && equal(lastModified, that.lastModified)
+               && equal(extendedProperties, that.extendedProperties);
+      } else {
+         return false;
+      }
+   }
+
+   @Override
+   public int hashCode() {
+      return Objects.hashCode(name, location, affinityGroup, label, description, status, created, lastModified,
+            extendedProperties);
+   }
+
+   @Override
+   public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("location", location)
+            .add("affinityGroup", affinityGroup)
+            .add("label", label)
+            .add("description", description)
+            .add("status", status)
+            .add("created", created)
+            .add("lastModified", lastModified)
+            .add("extendedProperties", extendedProperties).toString();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
index 7a6986f..580c59d 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
@@ -51,7 +51,7 @@ public final class Deployment {
       return name;
    }
 
-   /** The environment to which the hosted service is deployed. */
+   /** The environment to which the cloud service is deployed. */
    public Slot slot() {
       return slot;
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
index 26a16b6..07ebf56 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
@@ -39,7 +39,7 @@ public final class Disk {
          return deployment;
       }
 
-      /** The hosted service in which the disk is being used. */
+      /** The cloud service in which the disk is being used. */
       public String hostedService() {
          return hostedService;
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
deleted file mode 100644
index 6ef400b..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Date;
-import java.util.Map;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-
-/**
- * System properties for the specified hosted service. These properties include the service name and
- * service type; the name of the affinity group to which the service belongs, or its location if it
- * is not part of an affinity group.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public final class HostedService {
-   public enum Status {
-      CREATING, CREATED, DELETING, DELETED, CHANGING, RESOLVING_DNS,
-      UNRECOGNIZED;
-   }
-
-   /**
-    * The name of the hosted service. This name is the DNS prefix name and can be used to access the
-    * hosted service.
-    *
-    * <p/>For example, if the service name is MyService you could access the access the service by
-    * calling: http://MyService.cloudapp.net
-    */
-   public String name() {
-      return name;
-   }
-
-   /**
-    * The geo-location of the hosted service in Windows Azure, if the hosted service is not
-    * associated with an affinity group. If a location has been specified, the AffinityGroup element
-    * is not returned.
-    */
-   @Nullable public String location() {
-      return location;
-   }
-
-   /**
-    * The affinity group with which this hosted service is associated, if any. If the service is
-    * associated with an affinity group, the Location element is not returned.
-    */
-   @Nullable public String affinityGroup() {
-      return affinityGroup;
-   }
-
-   /**
-    * The name can be up to 100 characters in length. The name can be used identify the storage account for your
-    * tracking purposes.
-    */
-   public String label() {
-      return label;
-   }
-
-   @Nullable public String description() {
-      return description;
-   }
-
-   public Status status() {
-      return status;
-   }
-
-   public Date created() {
-      return created;
-   }
-
-   public Date lastModified() {
-      return lastModified;
-   }
-
-   /**
-    * Represents the name of an extended hosted service property. Each extended property must have
-    * both a defined name and value. You can have a maximum of 50 extended property name/value
-    * pairs.
-    *
-    * <p/>The maximum length of the Name element is 64 characters, only alphanumeric characters and
-    * underscores are valid in the Name, and the name must start with a letter. Each extended
-    * property value has a maximum length of 255 characters.
-    */
-   public Map<String, String> extendedProperties() {
-      return extendedProperties;
-   }
-
-   public static HostedService create(String name, String location, String affinityGroup, String label,
-         String description, Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
-      return new HostedService(name, location, affinityGroup, label, description, status, created, lastModified,
-            extendedProperties);
-   }
-
-   // TODO: Remove from here down with @AutoValue.
-   private HostedService(String name, String location, String affinityGroup, String label, String description,
-         Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
-      this.name = checkNotNull(name, "name");
-      this.location = location;
-      this.affinityGroup = affinityGroup;
-      this.label = checkNotNull(label, "label");
-      this.description = description;
-      this.status = checkNotNull(status, "status");
-      this.created = checkNotNull(created, "created");
-      this.lastModified = checkNotNull(lastModified, "lastModified");
-      this.extendedProperties = checkNotNull(extendedProperties, "extendedProperties");
-   }
-
-   private final String name;
-   private final String location;
-   private final String affinityGroup;
-   private final String label;
-   private final String description;
-   private final Status status;
-   private final Date created;
-   private final Date lastModified;
-   private final Map<String, String> extendedProperties;
-
-   @Override
-   public boolean equals(Object object) {
-      if (this == object) {
-         return true;
-      }
-      if (object instanceof HostedService) {
-         HostedService that = HostedService.class.cast(object);
-         return equal(name, that.name)
-               && equal(location, that.location)
-               && equal(affinityGroup, that.affinityGroup)
-               && equal(label, that.label)
-               && equal(description, that.description)
-               && equal(status, that.status)
-               && equal(created, that.created)
-               && equal(lastModified, that.lastModified)
-               && equal(extendedProperties, that.extendedProperties);
-      } else {
-         return false;
-      }
-   }
-
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(name, location, affinityGroup, label, description, status, created, lastModified,
-            extendedProperties);
-   }
-
-   @Override
-   public String toString() {
-      return toStringHelper(this)
-            .add("name", name)
-            .add("location", location)
-            .add("affinityGroup", affinityGroup)
-            .add("label", label)
-            .add("description", description)
-            .add("status", status)
-            .add("created", created)
-            .add("lastModified", lastModified)
-            .add("extendedProperties", extendedProperties).toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/features/CloudServiceApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/CloudServiceApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/CloudServiceApi.java
new file mode 100644
index 0000000..9cc8b5e
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/CloudServiceApi.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.features;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
+import java.util.List;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.jclouds.azurecompute.domain.CloudService;
+import org.jclouds.azurecompute.functions.Base64EncodeLabel;
+import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
+import org.jclouds.azurecompute.xml.CloudServiceHandler;
+import org.jclouds.azurecompute.xml.ListCloudServicesHandler;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Headers;
+import org.jclouds.rest.annotations.ParamParser;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * The Service Management API includes operations for managing the cloud services beneath your
+ * subscription.
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/ee460812">docs</a>
+ */
+@Path("/services/hostedservices")
+@Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
+@Consumes(APPLICATION_XML)
+public interface CloudServiceApi {
+
+   /**
+    * The List Cloud Services operation lists the cloud services available under the current
+    * subscription.
+    *
+    * @return the response object
+    */
+   @Named("ListCloudServices")
+   @GET
+   @QueryParams(keys = "embed-detail", values = "true")
+   @XMLResponseParser(ListCloudServicesHandler.class)
+   @Fallback(EmptyListOnNotFoundOr404.class)
+   List<CloudService> list();
+
+   /**
+    * The Create Cloud Service operation creates a new cloud service in Windows Azure.
+    *
+    * @param name
+    *           A name for the cloud service that is unique within Windows Azure. This name is the
+    *           DNS prefix name and can be used to access the cloud service.
+    *
+    *           For example: http://name.cloudapp.net//
+    * @param label
+    *           The name can be used identify the storage account for your tracking purposes. The
+    *           name can be up to 100 characters in length.
+    * @param location
+    *           The location where the cloud service will be created.
+    * @return the requestId to track this async request progress
+    *
+    * @see <a href="http://msdn.microsoft.com/en-us/library/ee460812">docs</a>
+    */
+   @Named("CreateCloudService")
+   @POST
+   @Produces(APPLICATION_XML)
+   @ResponseParser(ParseRequestIdHeader.class)
+   @Payload("<CreateHostedService xmlns=\"http://schemas.microsoft.com/windowsazure\"><ServiceName>{name}</ServiceName><Label>{label}</Label><Location>{location}</Location></CreateHostedService>")
+   String createWithLabelInLocation(@PayloadParam("name") String name,
+         @PayloadParam("label") @ParamParser(Base64EncodeLabel.class) String label,
+         @PayloadParam("location") String location);
+
+   /**
+    * The Get Cloud Service Properties operation retrieves system properties for the specified
+    * cloud service. These properties include the service name and service type; the name of the
+    * affinity group to which the service belongs, or its location if it is not part of an affinity
+    * group.
+    *
+    * @param name
+    *           the unique DNS Prefix value in the Windows Azure Management Portal
+    */
+   @Named("GetCloudServiceProperties")
+   @GET
+   @Path("/{name}")
+   @QueryParams(keys = "embed-detail", values = "true")
+   @XMLResponseParser(CloudServiceHandler.class)
+   @Fallback(NullOnNotFoundOr404.class)
+   @Nullable CloudService get(@PathParam("name") String name);
+
+   /**
+    * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure.
+    *
+    * @param name
+    *           the unique DNS Prefix value in the Windows Azure Management Portal
+    *
+    * @return request id or null, if not found
+    */
+   @Named("DeleteCloudService")
+   @DELETE
+   @Path("/{name}")
+   @Fallback(NullOnNotFoundOr404.class)
+   @ResponseParser(ParseRequestIdHeader.class)
+   String delete(@PathParam("name") String name);
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
deleted file mode 100644
index f8d1502..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.features;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_XML;
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
-import java.util.List;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.functions.Base64EncodeLabel;
-import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
-import org.jclouds.azurecompute.xml.HostedServiceHandler;
-import org.jclouds.azurecompute.xml.ListHostedServicesHandler;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.ParamParser;
-import org.jclouds.rest.annotations.Payload;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.rest.annotations.XMLResponseParser;
-
-/**
- * The Service Management API includes operations for managing the hosted services beneath your
- * subscription.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460812">docs</a>
- */
-@Path("/services/hostedservices")
-@Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
-@Consumes(APPLICATION_XML)
-public interface HostedServiceApi {
-
-   /**
-    * The List Hosted Services operation lists the hosted services available under the current
-    * subscription.
-    *
-    * @return the response object
-    */
-   @Named("ListHostedServices")
-   @GET
-   @QueryParams(keys = "embed-detail", values = "true")
-   @XMLResponseParser(ListHostedServicesHandler.class)
-   @Fallback(EmptyListOnNotFoundOr404.class)
-   List<HostedService> list();
-
-   /**
-    * The Create Hosted Service operation creates a new hosted service in Windows Azure.
-    *
-    * @param name
-    *           A name for the hosted service that is unique within Windows Azure. This name is the
-    *           DNS prefix name and can be used to access the hosted service.
-    *
-    *           For example: http://name.cloudapp.net//
-    * @param label
-    *           The name can be used identify the storage account for your tracking purposes. The
-    *           name can be up to 100 characters in length.
-    * @param location
-    *           The location where the hosted service will be created.
-    * @return the requestId to track this async request progress
-    *
-    * @see <a href="http://msdn.microsoft.com/en-us/library/ee460812">docs</a>
-    */
-   @Named("CreateHostedService")
-   @POST
-   @Produces(APPLICATION_XML)
-   @ResponseParser(ParseRequestIdHeader.class)
-   @Payload("<CreateHostedService xmlns=\"http://schemas.microsoft.com/windowsazure\"><ServiceName>{name}</ServiceName><Label>{label}</Label><Location>{location}</Location></CreateHostedService>")
-   String createWithLabelInLocation(@PayloadParam("name") String name,
-         @PayloadParam("label") @ParamParser(Base64EncodeLabel.class) String label,
-         @PayloadParam("location") String location);
-
-   /**
-    * The Get Hosted Service Properties operation retrieves system properties for the specified
-    * hosted service. These properties include the service name and service type; the name of the
-    * affinity group to which the service belongs, or its location if it is not part of an affinity
-    * group.
-    *
-    * @param name
-    *           the unique DNS Prefix value in the Windows Azure Management Portal
-    */
-   @Named("GetHostedServiceProperties")
-   @GET
-   @Path("/{name}")
-   @QueryParams(keys = "embed-detail", values = "true")
-   @XMLResponseParser(HostedServiceHandler.class)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Nullable HostedService get(@PathParam("name") String name);
-
-   /**
-    * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure.
-    *
-    * @param name
-    *           the unique DNS Prefix value in the Windows Azure Management Portal
-    *
-    * @return request id or null, if not found
-    */
-   @Named("DeleteHostedService")
-   @DELETE
-   @Path("/{name}")
-   @Fallback(NullOnNotFoundOr404.class)
-   @ResponseParser(ParseRequestIdHeader.class)
-   String delete(@PathParam("name") String name);
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
index 7ccad03..3ca54c3 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
@@ -56,7 +56,7 @@ import org.jclouds.rest.annotations.XMLResponseParser;
 public interface ImageApi {
 
    /**
-    * The List Hosted Services operation lists the hosted services available under the current
+    * The List Cloud Services operation lists the cloud services available under the current
     * subscription.
     */
    @Named("ListImages")
@@ -87,7 +87,7 @@ public interface ImageApi {
                @BinderParam(ImageParamsToXML.class) ImageParams params);
 
    /**
-    * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure.
+    * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure.
     *
     * @param imageName
     *           the unique DNS Prefix value in the Windows Azure Management Portal

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
index 1621139..2a77e68 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
@@ -32,7 +32,7 @@ import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
 
 /**
  * The Service Management API includes operations for listing the available data center locations
- * for a hosted service in your subscription.
+ * for a cloud service in your subscription.
  * <p/>
  *
  * @see <a href="http://msdn.microsoft.com/en-us/library/gg441299" />

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/xml/CloudServiceHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/CloudServiceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/CloudServiceHandler.java
new file mode 100644
index 0000000..267c955
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/CloudServiceHandler.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.util.Date;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.azurecompute.domain.CloudService;
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >Response body description</a>
+ */
+public final class CloudServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<CloudService> {
+   private String name;
+   private String location;
+   private String affinityGroup;
+   private String label;
+   private String description;
+   private CloudService.Status status;
+   private Date created;
+   private Date lastModified;
+   private Map<String, String> extendedProperties = Maps.newLinkedHashMap();
+
+   private boolean inHostedServiceProperties;
+   private String propertyName;
+   private StringBuilder currentText = new StringBuilder();
+   private final DateService dateService;
+
+   @Inject CloudServiceHandler(DateService dateService) {
+      this.dateService = dateService;
+   }
+
+   @Override public CloudService getResult() {
+      CloudService result = CloudService.create(name, location, affinityGroup, label, description, status, created, //
+            lastModified, ImmutableMap.copyOf(extendedProperties));
+      resetState(); // handler is called in a loop.
+      return result;
+   }
+
+   private void resetState() {
+      name = description = location = affinityGroup = label = null;
+      status = null;
+      created = lastModified = null;
+      extendedProperties.clear();
+      inHostedServiceProperties = false;
+      propertyName = null;
+   }
+
+   @Override public void startElement(String ignoredUri, String ignoredLocalName, String qName, Attributes ignoredAttributes) {
+      if (qName.equals("HostedServiceProperties")) {
+         inHostedServiceProperties = true;
+      }
+   }
+
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("HostedServiceProperties")) {
+         inHostedServiceProperties = false;
+      } else if (inHostedServiceProperties) {
+         if (qName.equals("DateCreated")) {
+            created = dateService.iso8601SecondsDateParse(currentOrNull(currentText));
+         } else if (qName.equals("DateLastModified")) {
+            lastModified = dateService.iso8601SecondsDateParse(currentOrNull(currentText));
+         } else if (qName.equals("Status")) {
+            String statusText = currentOrNull(currentText);
+            if (statusText != null) {
+               status = status(statusText);
+            }
+         } else if (qName.equals("Name")) {
+            propertyName = currentOrNull(currentText);
+         } else if (qName.equals("Value")) {
+            extendedProperties.put(propertyName, currentOrNull(currentText));
+            propertyName = null;
+         } else if (qName.equals("Description")) {
+            description = currentOrNull(currentText);
+         } else if (qName.equals("Location")) {
+            location = currentOrNull(currentText);
+         } else if (qName.equals("AffinityGroup")) {
+            affinityGroup = currentOrNull(currentText);
+         } else if (qName.equals("Label")) {
+            label = new String(base64().decode(currentOrNull(currentText)), UTF_8);
+         }
+      } else if (qName.equals("ServiceName")) {
+         name = currentOrNull(currentText);
+      }
+      currentText = new StringBuilder();
+   }
+
+   @Override public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+
+   private static CloudService.Status status(String status) {
+      try {
+         return CloudService.Status.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, status));
+      } catch (IllegalArgumentException e) {
+         return CloudService.Status.UNRECOGNIZED;
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
deleted file mode 100644
index 5e3c3e9..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import static com.google.common.base.CaseFormat.UPPER_CAMEL;
-import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-
-import java.util.Date;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.date.DateService;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >Response body description</a>
- */
-public final class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<HostedService> {
-   private String name;
-   private String location;
-   private String affinityGroup;
-   private String label;
-   private String description;
-   private HostedService.Status status;
-   private Date created;
-   private Date lastModified;
-   private Map<String, String> extendedProperties = Maps.newLinkedHashMap();
-
-   private boolean inHostedServiceProperties;
-   private String propertyName;
-   private StringBuilder currentText = new StringBuilder();
-   private final DateService dateService;
-
-   @Inject HostedServiceHandler(DateService dateService) {
-      this.dateService = dateService;
-   }
-
-   @Override public HostedService getResult() {
-      HostedService result = HostedService.create(name, location, affinityGroup, label, description, status, created, //
-            lastModified, ImmutableMap.copyOf(extendedProperties));
-      resetState(); // handler is called in a loop.
-      return result;
-   }
-
-   private void resetState() {
-      name = description = location = affinityGroup = label = null;
-      status = null;
-      created = lastModified = null;
-      extendedProperties.clear();
-      inHostedServiceProperties = false;
-      propertyName = null;
-   }
-
-   @Override public void startElement(String ignoredUri, String ignoredLocalName, String qName, Attributes ignoredAttributes) {
-      if (qName.equals("HostedServiceProperties")) {
-         inHostedServiceProperties = true;
-      }
-   }
-
-   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
-      if (qName.equals("HostedServiceProperties")) {
-         inHostedServiceProperties = false;
-      } else if (inHostedServiceProperties) {
-         if (qName.equals("DateCreated")) {
-            created = dateService.iso8601SecondsDateParse(currentOrNull(currentText));
-         } else if (qName.equals("DateLastModified")) {
-            lastModified = dateService.iso8601SecondsDateParse(currentOrNull(currentText));
-         } else if (qName.equals("Status")) {
-            String statusText = currentOrNull(currentText);
-            if (statusText != null) {
-               status = status(statusText);
-            }
-         } else if (qName.equals("Name")) {
-            propertyName = currentOrNull(currentText);
-         } else if (qName.equals("Value")) {
-            extendedProperties.put(propertyName, currentOrNull(currentText));
-            propertyName = null;
-         } else if (qName.equals("Description")) {
-            description = currentOrNull(currentText);
-         } else if (qName.equals("Location")) {
-            location = currentOrNull(currentText);
-         } else if (qName.equals("AffinityGroup")) {
-            affinityGroup = currentOrNull(currentText);
-         } else if (qName.equals("Label")) {
-            label = new String(base64().decode(currentOrNull(currentText)), UTF_8);
-         }
-      } else if (qName.equals("ServiceName")) {
-         name = currentOrNull(currentText);
-      }
-      currentText = new StringBuilder();
-   }
-
-   @Override public void characters(char ch[], int start, int length) {
-      currentText.append(ch, start, length);
-   }
-
-   private static HostedService.Status status(String status) {
-      try {
-         return HostedService.Status.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, status));
-      } catch (IllegalArgumentException e) {
-         return HostedService.Status.UNRECOGNIZED;
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListCloudServicesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListCloudServicesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListCloudServicesHandler.java
new file mode 100644
index 0000000..48152d7
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListCloudServicesHandler.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.jclouds.azurecompute.domain.CloudService;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/ee460781">Response body description</a>
+ */
+public final class ListCloudServicesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<CloudService>> {
+   private boolean inHostedService;
+   private final CloudServiceHandler cloudServiceHandler;
+   private final Builder<CloudService> hostedServices = ImmutableList.builder();
+
+   @Inject ListCloudServicesHandler(CloudServiceHandler cloudServiceHandler) {
+      this.cloudServiceHandler = cloudServiceHandler;
+   }
+
+   @Override public List<CloudService> getResult() {
+      return hostedServices.build();
+   }
+
+   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("HostedService")) {
+         inHostedService = true;
+      }
+      if (inHostedService) {
+         cloudServiceHandler.startElement(url, name, qName, attributes);
+      }
+   }
+
+   @Override public void endElement(String uri, String name, String qName) {
+      if (qName.equals("HostedService")) {
+         inHostedService = false;
+         hostedServices.add(cloudServiceHandler.getResult());
+      } else if (inHostedService) {
+         cloudServiceHandler.endElement(uri, name, qName);
+      }
+   }
+
+   @Override public void characters(char ch[], int start, int length) {
+      if (inHostedService) {
+         cloudServiceHandler.characters(ch, start, length);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
deleted file mode 100644
index 15bb5b2..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460781">Response body description</a>
- */
-public final class ListHostedServicesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<HostedService>> {
-   private boolean inHostedService;
-   private final HostedServiceHandler hostedServiceHandler;
-   private final Builder<HostedService> hostedServices = ImmutableList.builder();
-
-   @Inject ListHostedServicesHandler(HostedServiceHandler hostedServiceHandler) {
-      this.hostedServiceHandler = hostedServiceHandler;
-   }
-
-   @Override public List<HostedService> getResult() {
-      return hostedServices.build();
-   }
-
-   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
-      if (qName.equals("HostedService")) {
-         inHostedService = true;
-      }
-      if (inHostedService) {
-         hostedServiceHandler.startElement(url, name, qName, attributes);
-      }
-   }
-
-   @Override public void endElement(String uri, String name, String qName) {
-      if (qName.equals("HostedService")) {
-         inHostedService = false;
-         hostedServices.add(hostedServiceHandler.getResult());
-      } else if (inHostedService) {
-         hostedServiceHandler.endElement(uri, name, qName);
-      }
-   }
-
-   @Override public void characters(char ch[], int start, int length) {
-      if (inHostedService) {
-         hostedServiceHandler.characters(ch, start, length);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiLiveTest.java
new file mode 100644
index 0000000..fb0e915
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiLiveTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.features;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.azurecompute.domain.CloudService.Status.UNRECOGNIZED;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.jclouds.azurecompute.domain.CloudService;
+import org.jclouds.azurecompute.domain.CloudService.Status;
+import org.jclouds.azurecompute.domain.Operation;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+@Test(groups = "live", testName = "CloudServiceApiLiveTest")
+public class CloudServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+   public static final String CLOUD_SERVICE = (System.getProperty("user.name") + "-jclouds-cloudService").toLowerCase();
+
+   private Predicate<String> operationSucceeded;
+   private Predicate<CloudService> cloudServiceCreated;
+   private Predicate<CloudService> cloudServiceGone;
+
+   private String location;
+
+   @BeforeClass(groups = { "integration", "live" })
+   public void setup() {
+      super.setup();
+      // TODO: filter locations on those who have compute
+      location = Iterables.get(api.getLocationApi().list(), 0).name();
+      operationSucceeded = retry(new Predicate<String>() {
+         public boolean apply(String input) {
+            return api.getOperationApi().get(input).status() == Operation.Status.SUCCEEDED;
+         }
+      }, 600, 5, 5, SECONDS);
+      cloudServiceCreated = retry(new Predicate<CloudService>() {
+         public boolean apply(CloudService input) {
+            return api().get(input.name()).status() == Status.CREATED;
+         }
+      }, 600, 5, 5, SECONDS);
+      cloudServiceGone = retry(new Predicate<CloudService>() {
+         public boolean apply(CloudService input) {
+            return api().get(input.name()) == null;
+         }
+      }, 600, 5, 5, SECONDS);
+   }
+
+   private CloudService cloudService;
+
+   public void testCreate() {
+
+      String requestId = api().createWithLabelInLocation(CLOUD_SERVICE, CLOUD_SERVICE, location);
+      assertTrue(operationSucceeded.apply(requestId), requestId);
+      Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
+
+      cloudService = api().get(CLOUD_SERVICE);
+      Logger.getAnonymousLogger().info("created cloudService: " + cloudService);
+
+      assertEquals(cloudService.name(), CLOUD_SERVICE);
+
+      checkHostedService(cloudService);
+
+      assertTrue(cloudServiceCreated.apply(cloudService), cloudService.toString());
+      cloudService = api().get(cloudService.name());
+      Logger.getAnonymousLogger().info("cloudService available: " + cloudService);
+
+   }
+
+   @Test(dependsOnMethods = "testCreate")
+   public void testDelete() {
+      String requestId = api().delete(cloudService.name());
+      assertTrue(operationSucceeded.apply(requestId), requestId);
+      Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
+
+      assertTrue(cloudServiceGone.apply(cloudService), cloudService.toString());
+      Logger.getAnonymousLogger().info("cloudService deleted: " + cloudService);
+   }
+
+   @Override @AfterClass(groups = "live")
+   protected void tearDown() {
+      String requestId = api().delete(CLOUD_SERVICE);
+      if (requestId != null) {
+         operationSucceeded.apply(requestId);
+      }
+
+      super.tearDown();
+   }
+
+   public void testList() {
+      List<CloudService> response = api().list();
+
+      for (CloudService cloudService : response) {
+         checkHostedService(cloudService);
+      }
+
+      if (!response.isEmpty()) {
+         CloudService cloudService = response.iterator().next();
+         assertEquals(api().get(cloudService.name()), cloudService);
+      }
+   }
+
+   private void checkHostedService(CloudService cloudService) {
+      assertNotNull(cloudService.name(), "ServiceName cannot be null for " + cloudService);
+      assertTrue(cloudService.location() != null || cloudService.affinityGroup() != null,
+            "Location or AffinityGroup must be present for " + cloudService);
+      assertNotNull(cloudService.label(), "Label cannot be null for " + cloudService);
+      assertNotNull(cloudService.status(), "Status cannot be null for " + cloudService);
+      assertNotEquals(cloudService.status(), UNRECOGNIZED, "Status cannot be UNRECOGNIZED for " + cloudService);
+      assertNotNull(cloudService.created(), "Created cannot be null for " + cloudService);
+      assertNotNull(cloudService.lastModified(), "LastModified cannot be null for " + cloudService);
+      assertNotNull(cloudService.extendedProperties(), "ExtendedProperties cannot be null for " + cloudService);
+   }
+
+   private CloudServiceApi api() {
+      return api.getCloudServiceApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiMockTest.java
new file mode 100644
index 0000000..a929fff
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/CloudServiceApiMockTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
+import org.jclouds.azurecompute.xml.CloudServiceHandlerTest;
+import org.jclouds.azurecompute.xml.ListCloudServicesHandlerTest;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+@Test(groups = "unit", testName = "CloudServiceApiMockTest")
+public class CloudServiceApiMockTest extends BaseAzureComputeApiMockTest {
+
+   public void listWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(xmlResponse("/hostedservices.xml"));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertEquals(api.list(), ListCloudServicesHandlerTest.expected());
+
+         assertSent(server, "GET", "/services/hostedservices?embed-detail=true");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void listWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertTrue(api.list().isEmpty());
+
+         assertSent(server, "GET", "/services/hostedservices?embed-detail=true");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void getWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(xmlResponse("/hostedservice.xml"));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertEquals(api.get("myservice"), CloudServiceHandlerTest.expected());
+
+         assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void getWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertNull(api.get("myservice"));
+
+         assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void createWithLabelInLocation() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertEquals(api.createWithLabelInLocation("myservice", "service mine", "West US"), "request-1");
+
+         assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location.xml");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void deleteWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertEquals(api.delete("myservice"), "request-1");
+
+         assertSent(server, "DELETE", "/services/hostedservices/myservice");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void deleteWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         CloudServiceApi api = api(server.getUrl("/")).getCloudServiceApi();
+
+         assertNull(api.delete("myservice"));
+
+         assertSent(server, "DELETE", "/services/hostedservices/myservice");
+      } finally {
+         server.shutdown();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
deleted file mode 100644
index 08f53b4..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.features;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.azurecompute.domain.HostedService.Status.UNRECOGNIZED;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.azurecompute.domain.Operation;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-@Test(groups = "live", testName = "HostedServiceApiLiveTest")
-public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
-
-   public static final String HOSTED_SERVICE = (System.getProperty("user.name") + "-jclouds-hostedService")
-         .toLowerCase();
-
-   private Predicate<String> operationSucceeded;
-   private Predicate<HostedService> hostedServiceCreated;
-   private Predicate<HostedService> hostedServiceGone;
-
-   private String location;
-
-   @BeforeClass(groups = { "integration", "live" })
-   public void setup() {
-      super.setup();
-      // TODO: filter locations on those who have compute
-      location = Iterables.get(api.getLocationApi().list(), 0).name();
-      operationSucceeded = retry(new Predicate<String>() {
-         public boolean apply(String input) {
-            return api.getOperationApi().get(input).status() == Operation.Status.SUCCEEDED;
-         }
-      }, 600, 5, 5, SECONDS);
-      hostedServiceCreated = retry(new Predicate<HostedService>() {
-         public boolean apply(HostedService input) {
-            return api().get(input.name()).status() == Status.CREATED;
-         }
-      }, 600, 5, 5, SECONDS);
-      hostedServiceGone = retry(new Predicate<HostedService>() {
-         public boolean apply(HostedService input) {
-            return api().get(input.name()) == null;
-         }
-      }, 600, 5, 5, SECONDS);
-   }
-
-   private HostedService hostedService;
-
-   public void testCreateHostedService() {
-
-      String requestId = api().createWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location);
-      assertTrue(operationSucceeded.apply(requestId), requestId);
-      Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
-
-      hostedService = api().get(HOSTED_SERVICE);
-      Logger.getAnonymousLogger().info("created hostedService: " + hostedService);
-
-      assertEquals(hostedService.name(), HOSTED_SERVICE);
-
-      checkHostedService(hostedService);
-
-      assertTrue(hostedServiceCreated.apply(hostedService), hostedService.toString());
-      hostedService = api().get(hostedService.name());
-      Logger.getAnonymousLogger().info("hostedService available: " + hostedService);
-
-   }
-
-   @Test(dependsOnMethods = "testCreateHostedService")
-   public void testDeleteHostedService() {
-      String requestId = api().delete(hostedService.name());
-      assertTrue(operationSucceeded.apply(requestId), requestId);
-      Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
-
-      assertTrue(hostedServiceGone.apply(hostedService), hostedService.toString());
-      Logger.getAnonymousLogger().info("hostedService deleted: " + hostedService);
-   }
-
-   @Override @AfterClass(groups = "live")
-   protected void tearDown() {
-      String requestId = api().delete(HOSTED_SERVICE);
-      if (requestId != null) {
-         operationSucceeded.apply(requestId);
-      }
-
-      super.tearDown();
-   }
-
-   @Test
-   protected void testList() {
-      List<HostedService> response = api().list();
-
-      for (HostedService hostedService : api().list()) {
-         checkHostedService(hostedService);
-      }
-
-      if (response.size() > 0) {
-         HostedService hostedService = response.iterator().next();
-         assertEquals(api().get(hostedService.name()), hostedService);
-      }
-   }
-
-   private void checkHostedService(HostedService hostedService) {
-      assertNotNull(hostedService.name(), "ServiceName cannot be null for " + hostedService);
-      assertTrue(hostedService.location() != null || hostedService.affinityGroup() != null,
-            "Location or AffinityGroup must be present for " + hostedService);
-      assertNotNull(hostedService.label(), "Label cannot be null for " + hostedService);
-      assertNotNull(hostedService.status(), "Status cannot be null for " + hostedService);
-      assertNotEquals(hostedService.status(), UNRECOGNIZED, "Status cannot be UNRECOGNIZED for " + hostedService);
-      assertNotNull(hostedService.created(), "Created cannot be null for " + hostedService);
-      assertNotNull(hostedService.lastModified(), "LastModified cannot be null for " + hostedService);
-      assertNotNull(hostedService.extendedProperties(), "ExtendedProperties cannot be null for " + hostedService);
-   }
-
-   private HostedServiceApi api() {
-      return api.getHostedServiceApi();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
deleted file mode 100644
index 9d0cf80..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.xml.HostedServiceHandlerTest;
-import org.jclouds.azurecompute.xml.ListHostedServicesHandlerTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-@Test(groups = "unit", testName = "HostedServiceApiMockTest")
-public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
-
-   public void listWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(xmlResponse("/hostedservices.xml"));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertEquals(api.list(), ListHostedServicesHandlerTest.expected());
-
-         assertSent(server, "GET", "/services/hostedservices?embed-detail=true");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void listWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertTrue(api.list().isEmpty());
-
-         assertSent(server, "GET", "/services/hostedservices?embed-detail=true");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void getWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(xmlResponse("/hostedservice.xml"));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertEquals(api.get("myservice"), HostedServiceHandlerTest.expected());
-
-         assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void getWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertNull(api.get("myservice"));
-
-         assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void createWithLabelInLocation() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertEquals(api.createWithLabelInLocation("myservice", "service mine", "West US"), "request-1");
-
-         assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location.xml");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void deleteWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertEquals(api.delete("myservice"), "request-1");
-
-         assertSent(server, "DELETE", "/services/hostedservices/myservice");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void deleteWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertNull(api.delete("myservice"));
-
-         assertSent(server, "DELETE", "/services/hostedservices/myservice");
-      } finally {
-         server.shutdown();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/xml/CloudServiceHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/CloudServiceHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/CloudServiceHandlerTest.java
new file mode 100644
index 0000000..5a71396
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/CloudServiceHandlerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Collections;
+
+import org.jclouds.azurecompute.domain.CloudService;
+import org.jclouds.azurecompute.domain.CloudService.Status;
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "HostedServiceHandlerTest")
+public class CloudServiceHandlerTest extends BaseHandlerTest {
+   private static final DateService DATE_SERVICE = new SimpleDateFormatDateService();
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/hostedservice.xml");
+      CloudService result = factory.create(new CloudServiceHandler(DATE_SERVICE)).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static CloudService expected() {
+      return CloudService.create( //
+            "neotys", // name
+            "West Europe", // location
+            null, // affinityGroup
+            "neotys", // label
+            "Implicitly created cloud service2012-08-06 14:55", // description
+            Status.CREATED, // status
+            DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T14:55:17Z"), // created
+            DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T15:50:34Z"), // lastModified
+            Collections.<String, String>emptyMap() // extendedProperties
+      );
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java
deleted file mode 100644
index aefdca4..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.util.Collections;
-
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.date.DateService;
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "HostedServiceHandlerTest")
-public class HostedServiceHandlerTest extends BaseHandlerTest {
-   private static final DateService DATE_SERVICE = new SimpleDateFormatDateService();
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/hostedservice.xml");
-      HostedService result = factory.create(new HostedServiceHandler(DATE_SERVICE)).parse(is);
-
-      assertEquals(result, expected());
-   }
-
-   public static HostedService expected() {
-      return HostedService.create( //
-            "neotys", // name
-            "West Europe", // location
-            null, // affinityGroup
-            "neotys", // label
-            "Implicitly created hosted service2012-08-06 14:55", // description
-            Status.CREATED, // status
-            DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T14:55:17Z"), // created
-            DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T15:50:34Z"), // lastModified
-            Collections.<String, String>emptyMap() // extendedProperties
-      );
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListCloudServicesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListCloudServicesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListCloudServicesHandlerTest.java
new file mode 100644
index 0000000..1a99c06
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListCloudServicesHandlerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.CloudService;
+import org.jclouds.azurecompute.domain.CloudService.Status;
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListHostedServicesHandlerTest")
+public class ListCloudServicesHandlerTest extends BaseHandlerTest {
+   private static final DateService DATE_SERVICE = new SimpleDateFormatDateService();
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/hostedservices.xml");
+      ListCloudServicesHandler handler = new ListCloudServicesHandler(new CloudServiceHandler(DATE_SERVICE));
+      List<CloudService> result = factory.create(handler).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<CloudService> expected() {
+      return ImmutableList.of( //
+            CloudService.create( //
+                  "neotys", // name
+                  "West Europe", // location
+                  null, // affinityGroup
+                  "neotys", // label
+                  "Implicitly created cloud service2012-08-06 14:55", // description
+                  Status.CREATED, // status
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T14:55:17Z"), // created
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T15:50:34Z"), // lastModified
+                  Collections.<String, String>emptyMap() // extendedProperties
+            ), //
+            CloudService.create( //
+                  "neotys3", // name
+                  "West Europe", // location
+                  null, // affinityGroup
+                  "neotys3", // label
+                  null, // description
+                  Status.CREATED, // status
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-07T09:00:02Z"), // created
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-07T09:00:02Z"), // lastModified
+                  Collections.<String, String>emptyMap() // extendedProperties
+            ));
+   }
+}


[15/21] git commit: Cleanup Azure compute ImageParams input value type.

Posted by ad...@apache.org.
Cleanup Azure compute ImageParams input value type.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/13884f47
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/13884f47
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/13884f47

Branch: refs/heads/1.8.x
Commit: 13884f47a140abdf5d2dc8a6bc98fc264292f7d2
Parents: 79f6529
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Oct 21 21:43:39 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:05:40 2014 -0700

----------------------------------------------------------------------
 .../binders/BindOSImageParamsToXmlPayload.java  |  49 ------
 .../azurecompute/binders/ImageParamsToXML.java  |  43 +++++
 .../azurecompute/domain/ImageParams.java        | 163 ++++++++-----------
 .../jclouds/azurecompute/features/ImageApi.java |  22 +--
 .../azurecompute/functions/ImageParamsName.java |  13 +-
 5 files changed, 127 insertions(+), 163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/13884f47/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
deleted file mode 100644
index 1c1ec1e..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.binders;
-
-import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
-
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-import com.jamesmurty.utils.XMLBuilder;
-
-@Singleton
-public class BindOSImageParamsToXmlPayload implements Binder {
-
-
-   @Override
-   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
-      ImageParams params = ImageParams.class.cast(input);
-      try {
-         String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
-                                .e("Label").t(params.getLabel()).up()
-                                .e("MediaLink").t(params.getMediaLink().toASCIIString()).up()
-                                .e("Name").t(params.getName()).up()
-                                .e("OS").t(params.getOS() == LINUX ? "Linux" : "Windows").up()
-                                .up().asString();
-         return (R) request.toBuilder().payload(xml).build();
-      } catch (Exception e) {
-         throw propagate(e);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/13884f47/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
new file mode 100644
index 0000000..040184b
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.binders;
+
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
+
+import org.jclouds.azurecompute.domain.ImageParams;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.jamesmurty.utils.XMLBuilder;
+
+public final class ImageParamsToXML implements Binder {
+   @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+      ImageParams params = ImageParams.class.cast(input);
+      try {
+         String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
+                                .e("Label").t(params.label()).up()
+                                .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
+                                .e("Name").t(params.name()).up()
+                                .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
+                                .up().asString();
+         return (R) request.toBuilder().payload(xml).build();
+      } catch (Exception e) {
+         throw propagate(e);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/13884f47/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
index d02110c..4f5cbfb 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
@@ -16,6 +16,8 @@
  */
 package org.jclouds.azurecompute.domain;
 
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.net.URI;
@@ -25,143 +27,116 @@ import org.jclouds.azurecompute.domain.Image.OSType;
 import com.google.common.base.Objects;
 import com.google.common.base.Objects.ToStringHelper;
 
-/**
- * The Add OS Image operation adds an OS image that is currently stored in a storage account in your
- * subscription to the image repository.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
- */
-public class ImageParams {
+/** To create a new operating system image. */
+public final class ImageParams {
 
-   public static Builder builder() {
-      return new Builder();
+   /** Specifies a name that is used to identify the image when you create a Virtual Machine. */
+   public String name() {
+      return name;
+   }
+
+   /** Specifies the friendly name of the image. */
+   public String label() {
+      return label;
+   }
+
+   /** Specifies the location of the vhd file for the image. */
+   public URI mediaLink() {
+      return mediaLink;
+   }
+
+   /** {@link Image#os() Os type} of the image. */
+   public OSType os() {
+      return os;
    }
 
    public Builder toBuilder() {
       return builder().fromImageParams(this);
    }
 
-   public static class Builder {
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   public static final class Builder {
+      private String name;
       private String label;
       private URI mediaLink;
       private OSType os;
-      private String name;
 
-      /**
-       * @see ImageParams#getLabel()
-       */
+      public Builder name(String name) {
+         this.name = name;
+         return this;
+      }
+
       public Builder label(String label) {
          this.label = label;
          return this;
       }
 
-      /**
-       * @see ImageParams#getMediaLink()
-       */
       public Builder mediaLink(URI mediaLink) {
          this.mediaLink = mediaLink;
          return this;
       }
 
-      /**
-       * @see ImageParams#getName()
-       */
-      public Builder name(String name) {
-         this.name = name;
-         return this;
-      }
-
-      /**
-       * @see ImageParams#getOS()
-       */
       public Builder os(OSType os) {
          this.os = os;
          return this;
       }
 
       public ImageParams build() {
-         return new ImageParams(label, mediaLink, name, os);
+         return ImageParams.create(name, label, mediaLink, os);
       }
 
       public Builder fromImageParams(ImageParams in) {
-         return this.label(in.getLabel()).mediaLink(in.getMediaLink()).name(in.getName()).os(in.getOS());
+         return name(in.name())
+               .label(in.label())
+               .mediaLink(in.mediaLink())
+               .os(in.os());
       }
    }
 
-   private final String label;
-   private final URI mediaLink;
-   private final String name;
-   private final OSType os;
-
-   private ImageParams(String label, URI mediaLink, String name, OSType os) {
-      this.label = checkNotNull(label, "label");
-      this.name = checkNotNull(name, "name for %s", label);
-      this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", label);
-      this.os = checkNotNull(os, "os for %s", label);
-   }
-
-   /**
-    * The operating system type of the OS image.
-    */
-   public OSType getOS() {
-      return os;
-   }
-
-   /**
-    * The name of the hosted service. This name is the DNS prefix name and can be used to access the
-    * hosted service.
-    *
-    * For example, if the service name is MyService you could access the access the service by
-    * calling: http://MyService.cloudapp.net
-    */
-   public String getName() {
-      return name;
+   private static ImageParams create(String name, String label, URI mediaLink, OSType os) {
+      return new ImageParams(name, label, mediaLink, os);
    }
 
-   /**
-    * The location of the blob in the blob store in which the media for the image is located. The
-    * blob location belongs to a storage account in the subscription specified by the
-    * <subscription-id> value in the operation call.
-    *
-    * Example:
-    *
-    * http://example.blob.core.windows.net/disks/myimage.vhd
-    */
-   public URI getMediaLink() {
-      return mediaLink;
+   // TODO: Remove from here down with @AutoValue.
+   private ImageParams(String name, String label, URI mediaLink, OSType os) {
+      this.name = checkNotNull(name, "name");
+      this.label = checkNotNull(label, "label");
+      this.mediaLink = checkNotNull(mediaLink, "mediaLink");
+      this.os = checkNotNull(os, "os");
    }
 
-   /**
-    * The description of the image.
-    */
-   public String getLabel() {
-      return label;
-   }
+   private final String name;
+   private final String label;
+   private final URI mediaLink;
+   private final OSType os;
 
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(name);
+   @Override public int hashCode() {
+      return Objects.hashCode(name, label, mediaLink, os);
    }
 
-   @Override
-   public boolean equals(Object obj) {
-      if (this == obj)
+   @Override public boolean equals(Object object) {
+      if (this == object) {
          return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
+      }
+      if (object instanceof ImageParams) {
+         ImageParams that = ImageParams.class.cast(object);
+         return equal(name, that.name)
+               && equal(label, that.label)
+               && equal(mediaLink, that.mediaLink)
+               && equal(os, that.os);
+      } else {
          return false;
-      ImageParams other = (ImageParams) obj;
-      return Objects.equal(this.name, other.name);
-   }
-
-   @Override
-   public String toString() {
-      return string().toString();
+      }
    }
 
-   private ToStringHelper string() {
-      return Objects.toStringHelper(this).add("label", label).add("mediaLink", mediaLink).add("name", name)
-               .add("os", os);
+   @Override public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("label", label)
+            .add("mediaLink", mediaLink)
+            .add("os", os).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/13884f47/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
index cdf7029..7ccad03 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
@@ -16,7 +16,12 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
 import java.util.List;
+
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -26,8 +31,8 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import org.jclouds.azurecompute.binders.BindOSImageParamsToXmlPayload;
+
+import org.jclouds.azurecompute.binders.ImageParamsToXML;
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.ImageParams;
 import org.jclouds.azurecompute.functions.ImageParamsName;
@@ -40,9 +45,6 @@ import org.jclouds.rest.annotations.ParamParser;
 import org.jclouds.rest.annotations.ResponseParser;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
 /**
  * The Service Management API includes operations for managing the OS images in your subscription.
  *
@@ -50,7 +52,7 @@ import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
  */
 @Path("/services/images")
 @Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
-@Consumes(MediaType.APPLICATION_XML)
+@Consumes(APPLICATION_XML)
 public interface ImageApi {
 
    /**
@@ -69,9 +71,9 @@ public interface ImageApi {
     */
    @Named("AddImage")
    @POST
-   @Produces(MediaType.APPLICATION_XML)
+   @Produces(APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   String add(@BinderParam(BindOSImageParamsToXmlPayload.class) ImageParams params);
+   String add(@BinderParam(ImageParamsToXML.class) ImageParams params);
 
    /**
     * The Update OS Image operation updates an OS image that in your image repository.
@@ -79,10 +81,10 @@ public interface ImageApi {
    @Named("UpdateImage")
    @PUT
    @Path("/{imageName}")
-   @Produces(MediaType.APPLICATION_XML)
+   @Produces(APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
    String update(@PathParam("imageName") @ParamParser(ImageParamsName.class)
-               @BinderParam(BindOSImageParamsToXmlPayload.class) ImageParams params);
+               @BinderParam(ImageParamsToXML.class) ImageParams params);
 
    /**
     * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure.

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/13884f47/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
index 077b63c..3b2c458 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
@@ -16,19 +16,12 @@
  */
 package org.jclouds.azurecompute.functions;
 
-import com.google.common.base.Function;
-import javax.inject.Singleton;
 import org.jclouds.azurecompute.domain.ImageParams;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Function;
 
-@Singleton
 public class ImageParamsName implements Function<Object, String> {
-   @Override
-   public String apply(Object input) {
-      checkArgument(checkNotNull(input, "input") instanceof ImageParams,
-               "this function is only valid for ImageParams!");
-      return checkNotNull(ImageParams.class.cast(input), "ImageParams").getName();
+   @Override public String apply(Object input) {
+      return ImageParams.class.cast(input).name();
    }
 }


[04/21] git commit: Cleanup output-only Deployment object.

Posted by ad...@apache.org.
Cleanup output-only Deployment object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/867190ed
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/867190ed
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/867190ed

Branch: refs/heads/1.8.x
Commit: 867190ed7305b97bc80f00227f150acdbf240b8b
Parents: 99bbd4d
Author: Adrian Cole <ad...@gmail.com>
Authored: Thu Oct 16 09:01:39 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:34:44 2014 -0700

----------------------------------------------------------------------
 .../BindDeploymentParamsToXmlPayload.java       |  11 +-
 .../jclouds/azurecompute/domain/Deployment.java | 343 +++++++------------
 .../azurecompute/domain/DeploymentParams.java   |   2 +-
 .../azurecompute/domain/DeploymentSlot.java     |  42 ---
 .../azurecompute/domain/DeploymentStatus.java   |  43 ---
 .../azurecompute/domain/InstanceStatus.java     | 155 ---------
 .../jclouds/azurecompute/domain/RoleSize.java   |  23 +-
 .../azurecompute/xml/DeploymentHandler.java     | 172 ++++++----
 .../features/DeploymentApiMockTest.java         |  20 +-
 .../azurecompute/parse/GetDeploymentTest.java   |  62 ----
 .../azurecompute/xml/DeploymentHandlerTest.java |  86 +++++
 azurecompute/src/test/resources/deployment.xml  | 126 +++----
 12 files changed, 398 insertions(+), 687 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
index 1c127f1..22aa011 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
@@ -16,15 +16,20 @@
  */
 package org.jclouds.azurecompute.binders;
 
-import com.google.common.base.Throwables;
-import com.jamesmurty.utils.XMLBuilder;
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+
 import javax.inject.Singleton;
+
 import org.jclouds.azurecompute.domain.DeploymentParams;
 import org.jclouds.azurecompute.domain.InputEndpoint;
 import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.rest.Binder;
 
+import com.google.common.base.Throwables;
+import com.jamesmurty.utils.XMLBuilder;
+
 @Singleton
 public class BindDeploymentParamsToXmlPayload implements Binder {
 
@@ -95,7 +100,7 @@ public class BindDeploymentParamsToXmlPayload implements Binder {
             .e("SourceImageName").t(params.getSourceImageName()).up()
             .e("OS").t("Linux").up()
             .up() //OSVirtualHardDisk
-            .e("RoleSize").t(params.getSize().value()).up()
+            .e("RoleSize").t(UPPER_UNDERSCORE.to(UPPER_CAMEL, params.getSize().name())).up()
             .up() //Role
             .up(); //RoleList
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
index 6bd179b..7a6986f 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java
@@ -16,147 +16,73 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import java.net.URI;
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
 
-public class Deployment {
+import org.jclouds.javax.annotation.Nullable;
 
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public static class Builder {
-      private String deploymentName;
-      private DeploymentSlot deploymentSlot;
-      private DeploymentStatus deploymentStatus;
-      private String deploymentLabel;
-      private URI deploymentURL;
-      private String roleName;
-      private String instanceName;
-      private InstanceStatus instanceStatus;
-      private String instanceStateDetails;
-      private String instanceErrorCode;
-      private RoleSize instanceSize;
-      private String privateIpAddress;
-      private String publicIpAddress;
-
-      public Builder deploymentName(final String deploymentName) {
-         this.deploymentName = deploymentName;
-         return this;
-      }
-
-      public Builder deploymentSlot(final DeploymentSlot deploymentSlot) {
-         this.deploymentSlot = deploymentSlot;
-         return this;
-      }
-
-      public Builder deploymentStatus(final DeploymentStatus deploymentStatus) {
-         this.deploymentStatus = deploymentStatus;
-         return this;
-      }
+import com.google.common.base.Objects;
 
-      public Builder deploymentLabel(final String deploymentLabel) {
-         this.deploymentLabel = deploymentLabel;
-         return this;
-      }
-
-      public Builder deploymentURL(final URI deploymentURL) {
-         this.deploymentURL = deploymentURL;
-         return this;
-      }
-
-      public Builder instanceSize(final RoleSize instanceSize) {
-         this.instanceSize = instanceSize;
-         return this;
-      }
-
-      public Builder instanceName(final String instanceName) {
-         this.instanceName = instanceName;
-         return this;
-      }
+public final class Deployment {
 
-      public Builder instanceStatus(final InstanceStatus instanceStatus) {
-         this.instanceStatus = instanceStatus;
-         return this;
-      }
-
-      public Builder instanceStateDetails(final String instanceStateDetails) {
-         this.instanceStateDetails = instanceStateDetails;
-         return this;
-      }
-
-      public Builder instanceErrorCode(final String instanceErrorCode) {
-         this.instanceErrorCode = instanceErrorCode;
-         return this;
-      }
-
-      public Builder privateIpAddress(final String privateIpAddress) {
-         this.privateIpAddress = privateIpAddress;
-         return this;
-      }
-
-      public Builder publicIpAddress(final String publicIpAddress) {
-         this.publicIpAddress = publicIpAddress;
-         return this;
-      }
-
-      public Builder roleName(final String roleName) {
-         this.roleName = roleName;
-         return this;
-      }
+   public enum Slot {
+      PRODUCTION, STAGING,
+      UNRECOGNIZED;
+   }
 
-      public Deployment build() {
-         return new Deployment(deploymentName, deploymentSlot, deploymentStatus, deploymentLabel, deploymentURL,
-               roleName, instanceName, instanceStatus, instanceStateDetails, instanceErrorCode, instanceSize,
-               privateIpAddress, publicIpAddress);
-      }
+   public enum Status {
+      RUNNING, SUSPENDED, RUNNING_TRANSITIONING, SUSPENDED_TRANSITIONING, STARTING, SUSPENDING, DEPLOYING, DELETING,
+      UNRECOGNIZED;
+   }
 
+   public enum InstanceStatus {
+      CREATING_VM, STARTING_VM, CREATING_ROLE, STARTING_ROLE, READY_ROLE, BUSY_ROLE, STOPPING_ROLE, STOPPING_VM,
+      DELETING_VM, STOPPED_VM, RESTARTING_ROLE, CYCLING_ROLE, FAILED_STARTING_ROLE, FAILED_STARTING_VM, UNRESPONSIVE_ROLE,
+      STOPPED_DEALLOCATED, PREPARING,
+      /** Unknown to Azure. */
+      UNKNOWN,
+      /** Not parsable into one of the above. */
+      UNRECOGNIZED,
    }
 
-   /**
-    * The user-supplied name for this deployment.
-    */
-   private final String deploymentName;
+   /** The user-supplied name for this deployment. */
+   public String name() {
+      return name;
+   }
 
-   /**
-    * The environment to which the hosted service is deployed, either staging
-    * or production.
-    */
-   private final DeploymentSlot deploymentSlot;
+   /** The environment to which the hosted service is deployed. */
+   public Slot slot() {
+      return slot;
+   }
 
-   /**
-    * The status of the deployment.
-    */
-   private final DeploymentStatus deploymentStatus;
+   public Status status() {
+      return status;
+   }
 
    /**
     * The user-supplied name of the deployment returned as a base-64 encoded
     * string. This name can be used identify the deployment for your tracking
     * purposes.
     */
-   private final String deploymentLabel;
-
-   /**
-    * The URL used to access the hosted service. For example, if the service
-    * name is MyService you could access the access the service by calling:
-    * http://MyService.cloudapp.net
-    */
-   private final URI deploymentURL;
+   public String label() {
+      return label;
+   }
 
-   /**
-    * Specifies the name for the virtual machine. The name must be unique
-    * within Windows Azure.
-    */
-   private final String roleName;
+   /** Specifies the name for the virtual machine. The name must be unique within Windows Azure. */
+   public String virtualMachineName() {
+      return virtualMachineName;
+   }
 
-   /**
-    * The name of the specific role instance (if any).
-    */
-   private final String instanceName;
+   /** The name of the specific role instance (if any). */
+   @Nullable public String instanceName() {
+      return instanceName;
+   }
 
-   /**
-    * The current status of this instance.
-    */
-   private final InstanceStatus instanceStatus;
+   /** The current status of this instance. */
+   public InstanceStatus instanceStatus() {
+      return instanceStatus;
+   }
 
    /**
     * The instance state is returned as an English human-readable string that,
@@ -166,7 +92,9 @@ public class Deployment {
     * For example, when the instance is first being initialized a
     * "Preparing Windows for first use." could be returned.
     */
-   private final String instanceStateDetails;
+   @Nullable public String instanceStateDetails() {
+      return instanceStateDetails;
+   }
 
    /**
     * Error code of the latest role or VM start
@@ -187,123 +115,102 @@ public class Deployment {
     * For web and worker roles this field returns an error code that can be provided to Windows Azure support to assist
     * in resolution of errors. Typically this field will be empty.
     */
-   private final String instanceErrorCode;
-
-   /**
-    * The size of the role instance
-    */
-   private final RoleSize instanceSize;
-   private final String privateIpAddress;
-   private final String publicIpAddress;
-
-   public Deployment(String deploymentName, DeploymentSlot deploymentSlot, DeploymentStatus deploymentStatus,
-         String deploymentLabel, URI deploymentURL, String roleName, String instanceName, InstanceStatus instanceStatus,
-         String instanceStateDetails, String instanceErrorCode, RoleSize instanceSize, String privateIpAddress,
-         String publicIpAddress) {
-      this.deploymentName = deploymentName;
-      this.deploymentSlot = deploymentSlot;
-      this.deploymentStatus = deploymentStatus;
-      this.deploymentLabel = deploymentLabel;
-      this.deploymentURL = deploymentURL;
-      this.roleName = roleName;
-      this.instanceName = instanceName;
-      this.instanceStatus = instanceStatus;
-      this.instanceStateDetails = instanceStateDetails;
-      this.instanceErrorCode = instanceErrorCode;
-      this.instanceSize = instanceSize;
-      this.privateIpAddress = privateIpAddress;
-      this.publicIpAddress = publicIpAddress;
-   }
-
-   public String getDeploymentName() {
-      return deploymentName;
-   }
-
-   public DeploymentSlot getDeploymentSlot() {
-      return deploymentSlot;
-   }
-
-   public DeploymentStatus getDeploymentStatus() {
-      return deploymentStatus;
-   }
-
-   public String getDeploymentLabel() {
-      return deploymentLabel;
-   }
-
-   public URI getDeploymentURL() {
-      return deploymentURL;
-   }
-
-   public String getRoleName() {
-      return roleName;
-   }
-
-   public String getInstanceName() {
-      return instanceName;
-   }
-
-   public InstanceStatus getInstanceStatus() {
-      return instanceStatus;
-   }
-
-   public String getInstanceStateDetails() {
-      return instanceStateDetails;
-   }
-
-   public String getInstanceErrorCode() {
+   @Nullable public String instanceErrorCode() {
       return instanceErrorCode;
    }
 
-   public RoleSize getInstanceSize() {
+   public RoleSize instanceSize() {
       return instanceSize;
    }
 
-   public String getPrivateIpAddress() {
+   public String privateIpAddress() {
       return privateIpAddress;
    }
 
-   public String getPublicIpAddress() {
+   public String publicIpAddress() {
       return publicIpAddress;
    }
 
-   @Override
-   public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((deploymentName == null) ? 0 : deploymentName.hashCode());
-      return result;
+   public static Deployment create(String name, Slot slot, Status status, String label, String virtualMachineName,
+         String instanceName, InstanceStatus instanceStatus, String instanceStateDetails, String instanceErrorCode,
+         RoleSize instanceSize, String privateIpAddress, String publicIpAddress) {
+      return new Deployment(name, slot, status, label, virtualMachineName, instanceName, instanceStatus, instanceStateDetails,
+            instanceErrorCode, instanceSize, privateIpAddress, publicIpAddress);
    }
 
+   // TODO: Remove from here down with @AutoValue.
+   private Deployment(String name, Slot slot, Status status, String label, String virtualMachineName, String instanceName,
+            InstanceStatus instanceStatus, String instanceStateDetails, String instanceErrorCode, RoleSize instanceSize,
+            String privateIpAddress, String publicIpAddress) {
+      this.name = checkNotNull(name, "name");
+      this.slot = checkNotNull(slot, "slot");
+      this.status = checkNotNull(status, "status");
+      this.label = checkNotNull(label, "label");
+      this.virtualMachineName = checkNotNull(virtualMachineName, "virtualMachineName");
+      this.instanceName = instanceName;
+      this.instanceStatus = checkNotNull(instanceStatus, "instanceStatus");
+      this.instanceStateDetails = instanceStateDetails;
+      this.instanceErrorCode = instanceErrorCode;
+      this.instanceSize = checkNotNull(instanceSize, "instanceSize");
+      this.privateIpAddress = checkNotNull(privateIpAddress, "privateIpAddress");
+      this.publicIpAddress = checkNotNull(publicIpAddress, "publicIpAddress");
+   }
+
+   private final String name;
+   private final Slot slot;
+   private final Status status;
+   private final String label;
+   private final String virtualMachineName;
+   private final String instanceName;
+   private final InstanceStatus instanceStatus;
+   private final String instanceStateDetails;
+   private final String instanceErrorCode;
+   private final RoleSize instanceSize;
+   private final String privateIpAddress;
+   private final String publicIpAddress;
+
    @Override
-   public boolean equals(Object obj) {
-      if (this == obj) {
+   public boolean equals(Object object) {
+      if (this == object) {
          return true;
       }
-      if (obj == null) {
-         return false;
-      }
-      if (getClass() != obj.getClass()) {
-         return false;
-      }
-      Deployment other = (Deployment) obj;
-      if (deploymentName == null) {
-         if (other.deploymentName != null) {
-            return false;
-         }
-      } else if (!deploymentName.equals(other.deploymentName)) {
+      if (object instanceof Deployment) {
+         Deployment that = Deployment.class.cast(object);
+         return equal(name, that.name)
+               && equal(slot, that.slot)
+               && equal(label, that.label)
+               && equal(virtualMachineName, that.virtualMachineName)
+               && equal(instanceName, that.instanceName)
+               && equal(instanceStatus, that.instanceStatus)
+               && equal(instanceStateDetails, that.instanceStateDetails)
+               && equal(instanceErrorCode, that.instanceErrorCode)
+               && equal(instanceSize, that.instanceSize)
+               && equal(privateIpAddress, that.privateIpAddress)
+               && equal(publicIpAddress, that.publicIpAddress);
+      } else {
          return false;
       }
-      return true;
+   }
+
+   @Override
+   public int hashCode() {
+      return Objects.hashCode(name, slot, label, virtualMachineName, instanceName, instanceStatus, instanceStateDetails,
+            instanceErrorCode, instanceSize, privateIpAddress, publicIpAddress);
    }
 
    @Override
    public String toString() {
-      return "Deployment [deploymentName=" + deploymentName + ", deploymentSlot=" + deploymentSlot
-            + ", deploymentStatus=" + deploymentStatus + ", deploymentLabel=" + deploymentLabel + ", deploymentURL="
-            + deploymentURL + ", roleName=" + roleName + ", instanceName=" + instanceName + ", instanceStatus="
-            + instanceStatus + ", instanceStateDetails=" + instanceStateDetails + ", instanceErrorCode="
-            + instanceErrorCode + ", instanceSize=" + instanceSize + ", privateIpAddress=" + privateIpAddress
-            + ", publicIpAddress=" + publicIpAddress + "]";
+      return toStringHelper(this)
+            .add("name", name)
+            .add("slot", slot)
+            .add("label", label)
+            .add("virtualMachineName", virtualMachineName)
+            .add("instanceName", instanceName)
+            .add("instanceStatus", instanceStatus)
+            .add("instanceStateDetails", instanceStateDetails)
+            .add("instanceErrorCode", instanceErrorCode)
+            .add("instanceSize", instanceSize)
+            .add("privateIpAddress", privateIpAddress)
+            .add("publicIpAddress", publicIpAddress).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index 8b53671..504cd49 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -93,7 +93,7 @@ public class DeploymentParams {
       }
 
       public Builder fromDeploymentParams(DeploymentParams in) {
-         // TODO Since the roleName should be unique, is it a good idea to copy it ?
+         // TODO Since the virtualMachineName should be unique, is it a good idea to copy it ?
          return this.name(in.getName()).sourceImageName(in.getSourceImageName()).username(in.getUsername())
                .password(in.getPassword()).size(in.getSize());
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java
deleted file mode 100644
index 2e76b88..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import com.google.common.base.CaseFormat;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public enum DeploymentSlot {
-   PRODUCTION, STAGING;
-
-   public String value() {
-      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-   }
-
-   @Override
-   public String toString() {
-      return value();
-   }
-
-   public static DeploymentSlot fromValue(String type) {
-      try {
-         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
-      } catch (IllegalArgumentException e) {
-         return null;
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java
deleted file mode 100644
index eb34aa5..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import com.google.common.base.CaseFormat;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public enum DeploymentStatus {
-	RUNNING, SUSPENDED, RUNNING_TRANSITIONING, SUSPENDED_TRANSITIONING, STARTING, SUSPENDING, DEPLOYING, DELETING;
-
-	public String value() {
-		return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-	}
-
-	@Override
-	public String toString() {
-		return value();
-	}
-
-	public static DeploymentStatus fromValue(String type) {
-		try {
-			return valueOf(CaseFormat.UPPER_CAMEL.to(
-					CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
-		} catch (IllegalArgumentException e) {
-			return null;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java
deleted file mode 100644
index 51b5d24..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import com.google.common.base.CaseFormat;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public enum InstanceStatus {
-
-	/**
-	 * The role state is currently unknown. The state should automatically be
-	 * resolved once the role state is detected, so no action is required.
-	 */
-	ROLE_STATE_UNKNOWN,
-
-	/**
-	 * The host agent is currently creating resources for the Virtual Machine
-	 * (VM).
-	 */
-	CREATING_V_M,
-
-	/**
-	 * The host agent is starting the Virtual Machine.
-	 */
-	STARTING_V_M,
-
-	/**
-	 * Windows Azure is creating resources for the role.
-	 */
-	CREATING_ROLE,
-
-	/**
-	 * Windows Azure is starting the role.
-	 */
-	STARTING_ROLE,
-
-	/**
-	 * The role instance has started and is ready to be used.
-	 */
-	READY_ROLE,
-
-	/**
-	 * The role instance is unavailable for requests. This state is usually
-	 * generated while the role is being created or stopped.
-	 */
-	BUSY_ROLE,
-
-	/**
-	 * Windows Azure is stopping the role.
-	 */
-	STOPPING_ROLE,
-
-	/**
-	 * The host agent is stopping the Virtual Machine. This status also
-	 * indicates that the role has already been stopped.
-	 */
-	STOPPING_V_M,
-
-	/**
-	 * The Virtual Machine is being deleted by the host agent.
-	 */
-	DELETING_V_M,
-
-	/**
-	 * The Virtual Machine is not running. This is the final state of the
-	 * shutdown process, and no other status messages should be received after
-	 * StoppedVM.
-	 */
-	STOPPED_V_M,
-
-	/**
-	 * The role has unexpectedly stopped or has failed to start. This status
-	 * indicates that there is a problem with the role that is causing it to
-	 * crash or preventing it from starting, and must be corrected before the
-	 * role can be started. The InstanceStateDetails and InstanceErrorCode
-	 * fields can hold information about the role error that caused this state,
-	 * which may be useful for identifying and debugging the problem.
-	 */
-	RESTARTING_ROLE,
-
-	/**
-	 * The role has continually crashed after being started by Windows Azure.
-	 * This status indicates that there is a problem with the role that prevents
-	 * it from starting, and may be generated after the StartingRole even
-	 * ReadyRole statuses are received. The problem in the role must be found
-	 * and corrected before the role can be started. The InstanceStateDetails
-	 * and InstanceErrorCode fields can hold information about the role error
-	 * that caused this state, which may be useful for identifying and debugging
-	 * the problem.
-	 */
-	CYCLING_ROLE,
-
-	/**
-	 * The role has continually failed to start. This status indicates that
-	 * there is a problem with the role that prevents it from starting, and may
-	 * be generated after the process returns StartingRole. The problem in the
-	 * role must be found and corrected before the role can be started. The
-	 * InstanceStateDetails and InstanceErrorCode fields can hold information
-	 * about the role error that caused this state, which may be useful for
-	 * identifying and debugging the problem.
-	 */
-	FAILED_STARTING_ROLE,
-
-	/**
-	 * A Windows Azure or container error is preventing the Virtual Machine from
-	 * starting. This status is generated by Windows Azure, and does not
-	 * indicate an error with the role. It may be generated after the
-	 * StartingRole state.
-	 */
-	FAILED_STARTING_V_M,
-
-	/**
-	 * The role has timed out before receiving a status message and is not
-	 * responding to requests.
-	 */
-	UNRESPONSIVE_ROLE,
-
-	/**
-	 * UNDOCUMENTED BY AZURE
-	 */
-	PROVISIONING;
-
-	public String value() {
-		return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-	}
-
-	@Override
-	public String toString() {
-		return value();
-	}
-
-	public static InstanceStatus fromValue(String type) {
-		try {
-			return valueOf(CaseFormat.UPPER_CAMEL.to(
-					CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
-		} catch (IllegalArgumentException e) {
-			return ROLE_STATE_UNKNOWN;
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
index 6839091..5e2aa8b 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java
@@ -16,27 +16,6 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.CaseFormat;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
 public enum RoleSize {
-   EXTRA_SMALL, SMALL, MEDIUM, LARGE, EXTRA_LARGE;
-
-   public String value() {
-      return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-   }
-
-   @Override
-   public String toString() {
-      return value();
-   }
-
-   public static RoleSize fromValue(String type) {
-      try {
-         return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
-      } catch (IllegalArgumentException e) {
-         return null;
-      }
-   }
+   EXTRA_SMALL, SMALL, MEDIUM, LARGE, EXTRA_LARGE, UNRECOGNIZED;
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
index 8d92c72..50e8294 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java
@@ -16,100 +16,130 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import com.google.common.collect.Lists;
-import java.net.URI;
-import java.util.List;
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
 import org.jclouds.azurecompute.domain.Deployment;
-import org.jclouds.azurecompute.domain.DeploymentSlot;
-import org.jclouds.azurecompute.domain.DeploymentStatus;
-import org.jclouds.azurecompute.domain.InstanceStatus;
+import org.jclouds.azurecompute.domain.Deployment.InstanceStatus;
+import org.jclouds.azurecompute.domain.Deployment.Slot;
+import org.jclouds.azurecompute.domain.Deployment.Status;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.http.functions.ParseSax;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
 
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+import com.google.common.annotations.VisibleForTesting;
 
 /**
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460804" >api</a>
+ * @see <a href="http://msdn.microsoft.com/en-us/library/ee460804" >Response body description</a>.
  */
-public class DeploymentHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Deployment> {
+public final class DeploymentHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Deployment> {
+   private String name;
+   private Slot slot;
+   private Status status;
+   private String label;
+   private String virtualMachineName;
+   private String instanceName;
+   private InstanceStatus instanceStatus;
+   private String instanceStateDetails;
+   private String instanceErrorCode;
+   private RoleSize instanceSize;
+   private String privateIpAddress;
+   private String publicIpAddress;
 
-   private List<String> elements = Lists.newArrayList();
-   private StringBuilder currentText = new StringBuilder();
-   private Deployment.Builder builder = Deployment.builder();
+   private int depth;
+   private final StringBuilder currentText = new StringBuilder();
 
-   @Override
-   public Deployment getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = Deployment.builder();
-      }
+   @Override public Deployment getResult() { // Fields don't need to be reset as this isn't used in a loop.
+      return Deployment.create(name, slot, status, label, virtualMachineName, instanceName, instanceStatus, //
+            instanceStateDetails, instanceErrorCode, instanceSize, privateIpAddress, publicIpAddress);
    }
 
-   @Override
-   public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
-      elements.add(qName);
+   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+      depth++;
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
-      if (equalsOrSuffix(qName, "Name") && "Deployment".equals(elements.get(elements.size() - 2))) {
-         builder.deploymentName(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "DeploymentSlot")) {
-         final String dpltSlot = currentOrNull(currentText);
-         if (dpltSlot != null) {
-            builder.deploymentSlot(DeploymentSlot.fromValue(dpltSlot));
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("Name") && depth == 2) {
+         name = currentOrNull(currentText);
+      } else if (qName.equals("DeploymentSlot")) {
+         String slotText = currentOrNull(currentText);
+         if (slotText != null) {
+            slot = parseSlot(slotText);
          }
-      } else if (equalsOrSuffix(qName, "Status")) {
-         String deploymentStatus = currentOrNull(currentText);
-         if (deploymentStatus != null) {
-            builder.deploymentStatus(DeploymentStatus.fromValue(deploymentStatus));
+      } else if (qName.equals("Status")) {
+         String statusText = currentOrNull(currentText);
+         if (statusText != null) {
+            status = parseStatus(statusText);
          }
-      } else if (equalsOrSuffix(qName, "Label")) {
-         String label = currentOrNull(currentText);
-         if (label != null) {
-            builder.deploymentLabel(new String(base64().decode(label), UTF_8));
+      } else if (qName.equals("Label")) {
+         String labelText = currentOrNull(currentText);
+         if (labelText != null) {
+            label = new String(base64().decode(labelText), UTF_8);
          }
-      } else if (equalsOrSuffix(qName, "Url")) {
-         final String url = currentOrNull(currentText);
-         if (url != null) {
-            builder.deploymentURL(URI.create(url));
+      } else if (qName.equals("RoleName")) {
+         virtualMachineName = currentOrNull(currentText);
+      } else if (qName.equals("InstanceName")) {
+         instanceName = currentOrNull(currentText);
+      } else if (qName.equals("InstanceStatus")) {
+         String instanceStatusText = currentOrNull(currentText);
+         if (instanceStatusText != null) {
+            instanceStatus = parseInstanceStatus(instanceStatusText);
          }
-      } else if (equalsOrSuffix(qName, "RoleName")) {
-         builder.roleName(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "InstanceName")) {
-         builder.instanceName(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "InstanceStatus")) {
-         String instanceStatus = currentOrNull(currentText);
-         if (instanceStatus != null) {
-            builder.instanceStatus(InstanceStatus.fromValue(instanceStatus));
+      } else if (qName.equals("InstanceStateDetails")) {
+         instanceStateDetails = currentOrNull(currentText);
+      } else if (qName.equals("InstanceErrorCode")) {
+         instanceErrorCode = currentOrNull(currentText);
+      } else if (qName.equals("InstanceSize")) {
+         String instanceSizeText = currentOrNull(currentText);
+         if (instanceSizeText != null) {
+            instanceSize = parseRoleSize(instanceSizeText);
          }
-      } else if (equalsOrSuffix(qName, "InstanceStateDetails")) {
-         builder.instanceStateDetails(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "InstanceErrorCode")) {
-         builder.instanceErrorCode(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "InstanceSize")) {
-         String instanceSize = currentOrNull(currentText);
-         if (instanceSize != null) {
-            builder.instanceSize(RoleSize.fromValue(instanceSize));
-         }
-      } else if (equalsOrSuffix(qName, "IpAddress")) {
-         builder.privateIpAddress(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "Vip")) {
-         builder.publicIpAddress(currentOrNull(currentText));
+      } else if (qName.equals("IpAddress")) {
+         privateIpAddress = currentOrNull(currentText);
+      } else if (qName.equals("Vip")) {
+         publicIpAddress = currentOrNull(currentText);
       }
-
       currentText.setLength(0);
-      elements.remove(elements.size() - 1);
+      depth--;
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       currentText.append(ch, start, length);
    }
+
+   private static Status parseStatus(String status) {
+      try {
+         return Status.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, status));
+      } catch (IllegalArgumentException e) {
+         return Status.UNRECOGNIZED;
+      }
+   }
+
+   private static Slot parseSlot(String slot) {
+      try {
+         return Slot.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, slot));
+      } catch (IllegalArgumentException e) {
+         return Slot.UNRECOGNIZED;
+      }
+   }
+
+   @VisibleForTesting static InstanceStatus parseInstanceStatus(String instanceStatus) {
+      try {
+         // Azure isn't exactly upper-camel, as some states end in VM, not Vm.
+         return InstanceStatus.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, instanceStatus).replace("V_M", "VM"));
+      } catch (IllegalArgumentException e) {
+         return InstanceStatus.UNRECOGNIZED;
+      }
+   }
+
+   private static RoleSize parseRoleSize(String roleSize) {
+      try {
+         return RoleSize.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, roleSize));
+      } catch (IllegalArgumentException e) {
+         return RoleSize.UNRECOGNIZED;
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index e0bd956..90f34a9 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -16,16 +16,18 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
 import org.jclouds.azurecompute.domain.DeploymentParams;
 import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.parse.GetDeploymentTest;
+import org.jclouds.azurecompute.xml.DeploymentHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "DeploymentApiMockTest")
 public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
@@ -42,7 +44,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
                .sourceImageName("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd")
                .storageAccount("portalvhds0g7xhnq2x7t21").build();
 
-         assertThat(api.create(params)).isEqualTo("request-1");
+         assertEquals(api.create(params), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices/myservice/deployments", "/deploymentparams.xml");
       } finally {
@@ -57,7 +59,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         assertThat(api.get("mydeployment")).isEqualTo(GetDeploymentTest.expected());
+         assertEquals(api.get("mydeployment"), DeploymentHandlerTest.expected());
 
          assertSent(server, "GET", "/services/hostedservices/myservice/deployments/mydeployment");
       } finally {
@@ -72,7 +74,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         assertThat(api.get("mydeployment")).isNull();
+         assertNull(api.get("mydeployment"));
 
          assertSent(server, "GET", "/services/hostedservices/myservice/deployments/mydeployment");
       } finally {
@@ -87,7 +89,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         assertThat(api.delete("mydeployment")).isEqualTo("request-1");
+         assertEquals(api.delete("mydeployment"), "request-1");
 
          assertSent(server, "DELETE", "/services/hostedservices/myservice/deployments/mydeployment");
       } finally {
@@ -102,7 +104,7 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         assertThat(api.delete("mydeployment")).isNull();
+         assertNull(api.delete("mydeployment"));
 
          assertSent(server, "DELETE", "/services/hostedservices/myservice/deployments/mydeployment");
       } finally {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java
deleted file mode 100644
index 76bad81..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.jclouds.azurecompute.domain.Deployment;
-import org.jclouds.azurecompute.domain.DeploymentSlot;
-import org.jclouds.azurecompute.domain.DeploymentStatus;
-import org.jclouds.azurecompute.domain.InstanceStatus;
-import org.jclouds.azurecompute.domain.RoleSize;
-import org.jclouds.azurecompute.xml.DeploymentHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "GetDeploymentTest")
-public class GetDeploymentTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/deployment.xml");
-
-      Deployment expected = expected();
-
-      DeploymentHandler handler = injector.getInstance(DeploymentHandler.class);
-      Deployment result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-   }
-
-   public static Deployment expected() {
-      return Deployment.builder()
-         .deploymentName("neotysss")
-         .deploymentSlot(DeploymentSlot.PRODUCTION)
-         .deploymentStatus(DeploymentStatus.RUNNING)
-         .deploymentLabel("neotysss")
-         .deploymentURL(URI.create("http://neotysss.cloudapp.net/"))
-         .roleName("neotysss")
-         .instanceName("neotysss")
-         .instanceStatus(InstanceStatus.READY_ROLE)
-         .instanceSize(RoleSize.MEDIUM)
-         .privateIpAddress("10.59.244.162")
-         .publicIpAddress("168.63.27.148")
-         .build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
new file mode 100644
index 0000000..d622b42
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/DeploymentHandlerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.jclouds.azurecompute.xml.DeploymentHandler.parseInstanceStatus;
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.azurecompute.domain.Deployment;
+import org.jclouds.azurecompute.domain.Deployment.InstanceStatus;
+import org.jclouds.azurecompute.domain.Deployment.Slot;
+import org.jclouds.azurecompute.domain.Deployment.Status;
+import org.jclouds.azurecompute.domain.RoleSize;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "DeploymentHandlerTest")
+public class DeploymentHandlerTest extends BaseHandlerTest {
+
+   /**
+    * Covers values listed <a href="http://msdn.microsoft.com/en-us/library/azure/ee460804.aspx#RoleInstanceList">here</a>.
+    */
+   public void parseInstanceStatus_Recognized() {
+      assertEquals(parseInstanceStatus("Unknown"), InstanceStatus.UNKNOWN);
+      assertEquals(parseInstanceStatus("CreatingVM"), InstanceStatus.CREATING_VM);
+      assertEquals(parseInstanceStatus("StartingVM"), InstanceStatus.STARTING_VM);
+      assertEquals(parseInstanceStatus("CreatingRole"), InstanceStatus.CREATING_ROLE);
+      assertEquals(parseInstanceStatus("StartingRole"), InstanceStatus.STARTING_ROLE);
+      assertEquals(parseInstanceStatus("ReadyRole"), InstanceStatus.READY_ROLE);
+      assertEquals(parseInstanceStatus("BusyRole"), InstanceStatus.BUSY_ROLE);
+      assertEquals(parseInstanceStatus("StoppingRole"), InstanceStatus.STOPPING_ROLE);
+      assertEquals(parseInstanceStatus("StoppingVM"), InstanceStatus.STOPPING_VM);
+      assertEquals(parseInstanceStatus("DeletingVM"), InstanceStatus.DELETING_VM);
+      assertEquals(parseInstanceStatus("StoppedVM"), InstanceStatus.STOPPED_VM);
+      assertEquals(parseInstanceStatus("RestartingRole"), InstanceStatus.RESTARTING_ROLE);
+      assertEquals(parseInstanceStatus("CyclingRole"), InstanceStatus.CYCLING_ROLE);
+      assertEquals(parseInstanceStatus("FailedStartingRole"), InstanceStatus.FAILED_STARTING_ROLE);
+      assertEquals(parseInstanceStatus("FailedStartingVM"), InstanceStatus.FAILED_STARTING_VM);
+      assertEquals(parseInstanceStatus("UnresponsiveRole"), InstanceStatus.UNRESPONSIVE_ROLE);
+      assertEquals(parseInstanceStatus("StoppedDeallocated"), InstanceStatus.STOPPED_DEALLOCATED);
+      assertEquals(parseInstanceStatus("Preparing"), InstanceStatus.PREPARING);
+   }
+
+   public void parseInstanceStatus_Unrecognized() {
+      assertEquals(parseInstanceStatus("FooAddedToday"), InstanceStatus.UNRECOGNIZED);
+   }
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/deployment.xml");
+      Deployment result = factory.create(new DeploymentHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static Deployment expected() {
+      return Deployment.create( //
+            "deployment_name", // name
+            Slot.PRODUCTION, // slot
+            Status.RUNNING, // status
+            "neotysss", // label
+            "role_name_from_role_list", // virtualMachineName
+            "instance_name", // instanceName
+            InstanceStatus.READY_ROLE, // instanceStatus
+            null, // instanceStateDetails
+            null, // instanceErrorCode
+            RoleSize.MEDIUM, // instanceSize
+            "10.59.244.162", // privateIpAddress
+            "168.63.27.148" // publicIpAddress
+      );
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/867190ed/azurecompute/src/test/resources/deployment.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/deployment.xml b/azurecompute/src/test/resources/deployment.xml
index c44fc7a..b3029d6 100644
--- a/azurecompute/src/test/resources/deployment.xml
+++ b/azurecompute/src/test/resources/deployment.xml
@@ -1,70 +1,74 @@
 <Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
-    <Name>neotysss</Name>
-    <DeploymentSlot>Production</DeploymentSlot>
-    <PrivateID>05aa8ec5d8ee4215894431c7db401b31</PrivateID>
-    <Status>Running</Status>
-    <Label>bmVvdHlzc3M=</Label>
-    <Url>http://neotysss.cloudapp.net/</Url>
-    <Configuration>PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJuZW90eXNzcyI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4=</Configuration>
-    <RoleInstanceList>
-        <RoleInstance>
-        <RoleName>neotysss</RoleName>
-        <InstanceName>neotysss</InstanceName>
-        <InstanceStatus>ReadyRole</InstanceStatus>
-        <InstanceUpgradeDomain>0</InstanceUpgradeDomain>
-        <InstanceFaultDomain>0</InstanceFaultDomain>
-        <InstanceSize>Medium</InstanceSize>
-        <InstanceStateDetails/>
-        <IpAddress>10.59.244.162</IpAddress>
-        <InstanceEndpoints>
+  <Name>deployment_name</Name>
+  <DeploymentSlot>Production</DeploymentSlot>
+  <PrivateID>05aa8ec5d8ee4215894431c7db401b31</PrivateID>
+  <Status>Running</Status>
+  <Label>bmVvdHlzc3M=</Label>
+  <Url>http://neotysss.cloudapp.net/</Url>
+  <Configuration>
+    PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJuZW90eXNzcyI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4=
+  </Configuration>
+  <RoleInstanceList>
+    <RoleInstance>
+      <RoleName>role_name_from_instance</RoleName>
+      <InstanceName>instance_name</InstanceName>
+      <InstanceStatus>ReadyRole</InstanceStatus>
+      <InstanceUpgradeDomain>0</InstanceUpgradeDomain>
+      <InstanceFaultDomain>0</InstanceFaultDomain>
+      <InstanceSize>Medium</InstanceSize>
+      <InstanceStateDetails/>
+      <IpAddress>10.59.244.162</IpAddress>
+      <InstanceEndpoints>
         <InstanceEndpoint>
-            <Name>SSH</Name>
-            <Vip>168.63.27.148</Vip>
-            <PublicPort>22</PublicPort>
-            <LocalPort>22</LocalPort>
-            <Protocol>tcp</Protocol>
+          <Name>SSH</Name>
+          <Vip>168.63.27.148</Vip>
+          <PublicPort>22</PublicPort>
+          <LocalPort>22</LocalPort>
+          <Protocol>tcp</Protocol>
         </InstanceEndpoint>
-        </InstanceEndpoints>
-        <PowerState>Started</PowerState>
-        <HostName>neotys</HostName>
+      </InstanceEndpoints>
+      <PowerState>Started</PowerState>
+      <HostName>host_name</HostName>
     </RoleInstance>
-    </RoleInstanceList>
-    <UpgradeDomainCount>1</UpgradeDomainCount>
-    <RoleList>
-        <Role i:type="PersistentVMRole">
-        <RoleName>neotysss</RoleName>
-        <OsVersion/>
-        <RoleType>PersistentVMRole</RoleType>
-        <ConfigurationSets>
+  </RoleInstanceList>
+  <UpgradeDomainCount>1</UpgradeDomainCount>
+  <RoleList>
+    <Role i:type="PersistentVMRole">
+      <RoleName>role_name_from_role_list</RoleName>
+      <OsVersion/>
+      <RoleType>PersistentVMRole</RoleType>
+      <ConfigurationSets>
         <ConfigurationSet i:type="NetworkConfigurationSet">
-            <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
-            <InputEndpoints>
+          <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
+          <InputEndpoints>
             <InputEndpoint>
-                <LocalPort>22</LocalPort>
-                <Name>SSH</Name>
-                <Port>22</Port>
-                <Protocol>tcp</Protocol>
-                <Vip>168.63.27.148</Vip>
+              <LocalPort>22</LocalPort>
+              <Name>SSH</Name>
+              <Port>22</Port>
+              <Protocol>tcp</Protocol>
+              <Vip>168.63.27.148</Vip>
             </InputEndpoint>
-            </InputEndpoints>
-            <SubnetNames/>
+          </InputEndpoints>
+          <SubnetNames/>
         </ConfigurationSet>
-        </ConfigurationSets>
-        <DataVirtualHardDisks/>
-        <OSVirtualHardDisk>
-            <HostCaching>ReadWrite</HostCaching>
-            <DiskName>neotysss-neotysss-0-20120824091357</DiskName>
-            <MediaLink>http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink>
-            <SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName>
-            <OS>Windows</OS>
-        </OSVirtualHardDisk>
-        <RoleSize>Medium</RoleSize>
+      </ConfigurationSets>
+      <DataVirtualHardDisks/>
+      <OSVirtualHardDisk>
+        <HostCaching>ReadWrite</HostCaching>
+        <DiskName>neotysss-neotysss-0-20120824091357</DiskName>
+        <MediaLink>
+          http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd
+        </MediaLink>
+        <SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName>
+        <OS>Windows</OS>
+      </OSVirtualHardDisk>
+      <RoleSize>Medium</RoleSize>
     </Role>
-    </RoleList>
-    <SdkVersion/>
-    <Locked>false</Locked>
-    <RollbackAllowed>false</RollbackAllowed>
-    <CreatedTime>2012-08-24T09:13:53Z</CreatedTime>
-    <LastModifiedTime>2012-08-27T08:55:13Z</LastModifiedTime>
-    <ExtendedProperties/>
-</Deployment>
\ No newline at end of file
+  </RoleList>
+  <SdkVersion/>
+  <Locked>false</Locked>
+  <RollbackAllowed>false</RollbackAllowed>
+  <CreatedTime>2012-08-24T09:13:53Z</CreatedTime>
+  <LastModifiedTime>2012-08-27T08:55:13Z</LastModifiedTime>
+  <ExtendedProperties/>
+</Deployment>


[06/21] git commit: Cleanup output-only HostedService object.

Posted by ad...@apache.org.
Cleanup output-only HostedService object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/497c90b1
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/497c90b1
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/497c90b1

Branch: refs/heads/1.8.x
Commit: 497c90b164265e1a306a8e2b26be16b9d4d6be25
Parents: 867190e
Author: Adrian Cole <ac...@twitter.com>
Authored: Thu Oct 16 18:54:55 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:36:51 2014 -0700

----------------------------------------------------------------------
 .../domain/DetailedHostedServiceProperties.java | 173 -------------
 .../azurecompute/domain/HostedService.java      | 241 +++++++++----------
 .../domain/HostedServiceProperties.java         | 169 -------------
 .../HostedServiceWithDetailedProperties.java    |  63 -----
 .../azurecompute/features/HostedServiceApi.java |  40 ++-
 .../DetailedHostedServicePropertiesHandler.java |  73 ------
 .../azurecompute/xml/HostedServiceHandler.java  | 126 ++++++----
 .../xml/HostedServicePropertiesHandler.java     |  64 -----
 ...tedServiceWithDetailedPropertiesHandler.java |  42 ----
 .../xml/ListHostedServicesHandler.java          |  43 ++--
 .../features/HostedServiceApiLiveTest.java      |  99 +++-----
 .../features/HostedServiceApiMockTest.java      |  74 ++----
 .../parse/GetHostedServiceDetailsTest.java      |  65 -----
 .../parse/GetHostedServiceTest.java             |  55 -----
 .../parse/ListHostedServicesTest.java           |  79 ------
 .../xml/HostedServiceHandlerTest.java           |  55 +++++
 .../xml/ListHostedServicesHandlerTest.java      |  71 ++++++
 .../src/test/resources/hostedservice.xml        |   9 +-
 .../test/resources/hostedservice_details.xml    |  13 -
 .../src/test/resources/hostedservices.xml       |   6 +-
 20 files changed, 424 insertions(+), 1136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java
deleted file mode 100644
index 76abdc5..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import java.util.Date;
-import java.util.Map;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public class DetailedHostedServiceProperties extends HostedServiceProperties {
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public Builder toBuilder() {
-      return new Builder().fromDetailedHostedServiceProperties(this);
-   }
-
-   public static class Builder extends HostedServiceProperties.Builder<Builder> {
-
-      protected String rawStatus;
-      protected Status status;
-      protected Date created;
-      protected Date lastModified;
-      protected ImmutableMap.Builder<String, String> extendedProperties = ImmutableMap.<String, String>builder();
-
-      /**
-       * @see DetailedHostedServiceProperties#getRawStatus()
-       */
-      public Builder rawStatus(String rawStatus) {
-         this.rawStatus = rawStatus;
-         return this;
-      }
-
-      /**
-       * @see DetailedHostedServiceProperties#getStatus()
-       */
-      public Builder status(Status status) {
-         this.status = status;
-         return this;
-      }
-
-      /**
-       * @see DetailedHostedServiceProperties#getCreated()
-       */
-      public Builder created(Date created) {
-         this.created = created;
-         return this;
-      }
-
-      /**
-       * @see DetailedHostedServiceProperties#getLastModified()
-       */
-      public Builder lastModified(Date lastModified) {
-         this.lastModified = lastModified;
-         return this;
-      }
-
-      /**
-       * @see DetailedHostedServiceProperties#getExtendedProperties()
-       */
-      public Builder extendedProperties(Map<String, String> extendedProperties) {
-         this.extendedProperties.putAll(checkNotNull(extendedProperties, "extendedProperties"));
-         return this;
-      }
-
-      /**
-       * @see DetailedHostedServiceProperties#getExtendedProperties()
-       */
-      public Builder addExtendedProperty(String name, String value) {
-         this.extendedProperties.put(checkNotNull(name, "name"), checkNotNull(value, "value"));
-         return this;
-      }
-
-      @Override protected Builder self() {
-         return this;
-      }
-
-      public DetailedHostedServiceProperties build() {
-         return new DetailedHostedServiceProperties(description, location, affinityGroup, label, rawStatus, status,
-               created, lastModified, extendedProperties.build());
-      }
-
-      public Builder fromDetailedHostedServiceProperties(DetailedHostedServiceProperties in) {
-         return fromHostedServiceProperties(in).rawStatus(in.getRawStatus()).status(in.getStatus())
-               .created(in.getCreated()).lastModified(in.getLastModified())
-               .extendedProperties(in.getExtendedProperties());
-      }
-   }
-
-   protected final String rawStatus;
-   protected final Status status;
-   protected final Date created;
-   protected final Date lastModified;
-   protected final Map<String, String> extendedProperties;
-
-   protected DetailedHostedServiceProperties(Optional<String> description, Optional<String> location,
-         Optional<String> affinityGroup, String label, String rawStatus, Status status, Date created, Date lastModified,
-         Map<String, String> extendedProperties) {
-      super(description, location, affinityGroup, label);
-      this.rawStatus = checkNotNull(rawStatus, "rawStatus of %s", description);
-      this.status = checkNotNull(status, "status of %s", description);
-      this.created = checkNotNull(created, "created of %s", description);
-      this.lastModified = checkNotNull(lastModified, "lastModified of %s", description);
-      this.extendedProperties = ImmutableMap
-            .copyOf(checkNotNull(extendedProperties, "extendedProperties of %s", description));
-   }
-
-   /**
-    * The status of the hosted service.
-    */
-   public Status getStatus() {
-      return status;
-   }
-
-   /**
-    * The status of the hosted service unparsed.
-    */
-   public String getRawStatus() {
-      return rawStatus;
-   }
-
-   /**
-    * The date that the hosted service was created.
-    */
-   public Date getCreated() {
-      return created;
-   }
-
-   /**
-    * The date that the hosted service was last updated.
-    */
-   public Date getLastModified() {
-      return lastModified;
-   }
-
-   /**
-    * Represents the name of an extended hosted service property. Each extended property must have
-    * both a defined name and value. You can have a maximum of 50 extended property name/value
-    * pairs.
-    *
-    * The maximum length of the Name element is 64 characters, only alphanumeric characters and
-    * underscores are valid in the Name, and the name must start with a letter. Each extended
-    * property value has a maximum length of 255 characters.
-    */
-   public Map<String, String> getExtendedProperties() {
-      return extendedProperties;
-   }
-
-   @Override
-   public ToStringHelper string() {
-      return super.string().add("status", rawStatus).add("created", created).add("lastModified", lastModified)
-            .add("extendedProperties", extendedProperties);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
index a0d1a32..6ef400b 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java
@@ -16,168 +16,163 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import java.net.URI;
-
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import java.util.Date;
+import java.util.Map;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
 /**
- * System properties for the specified hosted service
+ * System properties for the specified hosted service. These properties include the service name and
+ * service type; the name of the affinity group to which the service belongs, or its location if it
+ * is not part of an affinity group.
  *
  * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
  */
-public class HostedService {
-   public static enum Status {
-
-      CREATING,
-
-      CREATED,
-
-      DELETING,
-
-      DELETED,
-
-      CHANGING,
-
-      RESOLVING_DNS,
-
+public final class HostedService {
+   public enum Status {
+      CREATING, CREATED, DELETING, DELETED, CHANGING, RESOLVING_DNS,
       UNRECOGNIZED;
-
-      public String value() {
-         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-      }
-
-      @Override
-      public String toString() {
-         return value();
-      }
-
-      public static Status fromValue(String status) {
-         try {
-            return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
-         } catch (IllegalArgumentException e) {
-            return UNRECOGNIZED;
-         }
-      }
    }
 
-   public static Builder<?> builder() {
-      return new ConcreteBuilder();
+   /**
+    * The name of the hosted service. This name is the DNS prefix name and can be used to access the
+    * hosted service.
+    *
+    * <p/>For example, if the service name is MyService you could access the access the service by
+    * calling: http://MyService.cloudapp.net
+    */
+   public String name() {
+      return name;
    }
 
-   public Builder<?> toBuilder() {
-      return new ConcreteBuilder().fromHostedService(this);
+   /**
+    * The geo-location of the hosted service in Windows Azure, if the hosted service is not
+    * associated with an affinity group. If a location has been specified, the AffinityGroup element
+    * is not returned.
+    */
+   @Nullable public String location() {
+      return location;
    }
 
-   public abstract static class Builder<T extends Builder<T>> {
-      protected abstract T self();
-
-      protected URI url;
-      protected String name;
-      protected HostedServiceProperties properties;
-
-      /**
-       * @see HostedService#getUrl()
-       */
-      public T url(URI url) {
-         this.url = url;
-         return self();
-      }
-
-      /**
-       * @see HostedService#getName()
-       */
-      public T name(String name) {
-         this.name = name;
-         return self();
-      }
-
-      /**
-       * @see HostedService#getProperties()
-       */
-      public T properties(HostedServiceProperties properties) {
-         this.properties = properties;
-         return self();
-      }
-
-      public HostedService build() {
-         return new HostedService(url, name, properties);
-      }
+   /**
+    * The affinity group with which this hosted service is associated, if any. If the service is
+    * associated with an affinity group, the Location element is not returned.
+    */
+   @Nullable public String affinityGroup() {
+      return affinityGroup;
+   }
 
-      public T fromHostedService(HostedService in) {
-         return this.url(in.getUrl()).name(in.getName()).properties(in.getProperties());
-      }
+   /**
+    * The name can be up to 100 characters in length. The name can be used identify the storage account for your
+    * tracking purposes.
+    */
+   public String label() {
+      return label;
    }
 
-   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
-      @Override
-      protected ConcreteBuilder self() {
-         return this;
-      }
+   @Nullable public String description() {
+      return description;
    }
 
-   protected final URI url;
-   protected final String name;
-   protected final HostedServiceProperties properties;
+   public Status status() {
+      return status;
+   }
 
-   protected HostedService(URI url, String name, HostedServiceProperties properties) {
-      this.url = checkNotNull(url, "url");
-      this.name = checkNotNull(name, "name");
-      this.properties = checkNotNull(properties, "properties");
+   public Date created() {
+      return created;
    }
 
-   /**
-    * The Service Management API request URI used to perform Get Hosted Service Properties requests
-    * against the hosted service.
-    */
-   public URI getUrl() {
-      return url;
+   public Date lastModified() {
+      return lastModified;
    }
 
    /**
-    * The name of the hosted service. This name is the DNS prefix name and can be used to access the
-    * hosted service.
+    * Represents the name of an extended hosted service property. Each extended property must have
+    * both a defined name and value. You can have a maximum of 50 extended property name/value
+    * pairs.
     *
-    * For example, if the service name is MyService you could access the access the service by
-    * calling: http://MyService.cloudapp.net
+    * <p/>The maximum length of the Name element is 64 characters, only alphanumeric characters and
+    * underscores are valid in the Name, and the name must start with a letter. Each extended
+    * property value has a maximum length of 255 characters.
     */
-   public String getName() {
-      return name;
+   public Map<String, String> extendedProperties() {
+      return extendedProperties;
    }
 
-   /**
-    * Provides the url of the database properties to be used for this DB HostedService.
-    */
-   public HostedServiceProperties getProperties() {
-      return properties;
+   public static HostedService create(String name, String location, String affinityGroup, String label,
+         String description, Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
+      return new HostedService(name, location, affinityGroup, label, description, status, created, lastModified,
+            extendedProperties);
    }
 
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(url);
+   // TODO: Remove from here down with @AutoValue.
+   private HostedService(String name, String location, String affinityGroup, String label, String description,
+         Status status, Date created, Date lastModified, Map<String, String> extendedProperties) {
+      this.name = checkNotNull(name, "name");
+      this.location = location;
+      this.affinityGroup = affinityGroup;
+      this.label = checkNotNull(label, "label");
+      this.description = description;
+      this.status = checkNotNull(status, "status");
+      this.created = checkNotNull(created, "created");
+      this.lastModified = checkNotNull(lastModified, "lastModified");
+      this.extendedProperties = checkNotNull(extendedProperties, "extendedProperties");
    }
 
+   private final String name;
+   private final String location;
+   private final String affinityGroup;
+   private final String label;
+   private final String description;
+   private final Status status;
+   private final Date created;
+   private final Date lastModified;
+   private final Map<String, String> extendedProperties;
+
    @Override
-   public boolean equals(Object obj) {
-      if (this == obj)
+   public boolean equals(Object object) {
+      if (this == object) {
          return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
+      }
+      if (object instanceof HostedService) {
+         HostedService that = HostedService.class.cast(object);
+         return equal(name, that.name)
+               && equal(location, that.location)
+               && equal(affinityGroup, that.affinityGroup)
+               && equal(label, that.label)
+               && equal(description, that.description)
+               && equal(status, that.status)
+               && equal(created, that.created)
+               && equal(lastModified, that.lastModified)
+               && equal(extendedProperties, that.extendedProperties);
+      } else {
          return false;
-      HostedService other = (HostedService) obj;
-      return Objects.equal(this.url, other.url);
+      }
    }
 
    @Override
-   public String toString() {
-      return string().toString();
+   public int hashCode() {
+      return Objects.hashCode(name, location, affinityGroup, label, description, status, created, lastModified,
+            extendedProperties);
    }
 
-   protected ToStringHelper string() {
-      return Objects.toStringHelper(this).omitNullValues().add("url", url).add("name", name)
-               .add("properties", properties);
+   @Override
+   public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("location", location)
+            .add("affinityGroup", affinityGroup)
+            .add("label", label)
+            .add("description", description)
+            .add("status", status)
+            .add("created", created)
+            .add("lastModified", lastModified)
+            .add("extendedProperties", extendedProperties).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java
deleted file mode 100644
index 4d539ed..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * System properties for the specified hosted service. These properties include the service name and
- * service type; the name of the affinity group to which the service belongs, or its location if it
- * is not part of an affinity group.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class HostedServiceProperties {
-   public static Builder<?> builder() {
-      return new ConcreteBuilder();
-   }
-
-   public Builder<?> toBuilder() {
-      return new ConcreteBuilder().fromHostedServiceProperties(this);
-   }
-
-   public abstract static class Builder<T extends Builder<T>> {
-      protected abstract T self();
-
-      protected Optional<String> description = Optional.absent();
-      protected Optional<String> location = Optional.absent();
-      protected Optional<String> affinityGroup = Optional.absent();
-      protected String label;
-
-      /**
-       * @see HostedServiceProperties#getDescription()
-       */
-      public T description(String description) {
-         this.description = Optional.fromNullable(description);
-         return self();
-      }
-
-      /**
-       * @see HostedServiceProperties#getLocation()
-       */
-      public T location(String location) {
-         this.location = Optional.fromNullable(location);
-         return self();
-      }
-
-      /**
-       * @see HostedServiceProperties#getAffinityGroup()
-       */
-      public T affinityGroup(String affinityGroup) {
-         this.affinityGroup = Optional.fromNullable(affinityGroup);
-         return self();
-      }
-
-      /**
-       * @see HostedServiceProperties#getLabel()
-       */
-      public T label(String label) {
-         this.label = label;
-         return self();
-      }
-
-      public HostedServiceProperties build() {
-         return new HostedServiceProperties(description, location, affinityGroup, label);
-      }
-
-      public T fromHostedServiceProperties(HostedServiceProperties in) {
-         return this.description(in.getDescription().orNull()).location(in.getLocation().orNull())
-                  .affinityGroup(in.getAffinityGroup().orNull()).label(in.getLabel());
-      }
-   }
-
-   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
-      @Override
-      protected ConcreteBuilder self() {
-         return this;
-      }
-   }
-
-   protected final Optional<String> description;
-   protected final Optional<String> location;
-   protected final Optional<String> affinityGroup;
-   protected final String label;
-
-   protected HostedServiceProperties(Optional<String> description, Optional<String> location,
-            Optional<String> affinityGroup, String label) {
-      this.description = checkNotNull(description, "description");
-      this.location = checkNotNull(location, "location");
-      this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup");
-      this.label = checkNotNull(label, "label");
-   }
-
-   /**
-    * The description for the hosted service..
-    */
-   public Optional<String> getDescription() {
-      return description;
-   }
-
-   /**
-    * The geo-location of the hosted service in Windows Azure, if the hosted service is not
-    * associated with an affinity group. If a location has been specified, the AffinityGroup element
-    * is not returned.
-    */
-   public Optional<String> getLocation() {
-      return location;
-   }
-
-   /**
-    * The affinity group with which this hosted service is associated, if any. If the service is
-    * associated with an affinity group, the Location element is not returned.
-    */
-   public Optional<String> getAffinityGroup() {
-      return affinityGroup;
-   }
-
-   /**
-    *  The name can be up to 100 characters in length. The name can be used identify the storage account for your tracking purposes.
-    */
-   public String getLabel() {
-      return label;
-   }
-
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(description, location, affinityGroup, label);
-   }
-
-   @Override
-   public boolean equals(Object obj) {
-      if (this == obj)
-         return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
-         return false;
-      HostedServiceProperties other = (HostedServiceProperties) obj;
-      return Objects.equal(this.description, other.description) && Objects.equal(this.location, other.location)
-               && Objects.equal(this.affinityGroup, other.affinityGroup) && Objects.equal(this.label, other.label);
-   }
-
-   @Override
-   public String toString() {
-      return string().toString();
-   }
-
-   protected ToStringHelper string() {
-      return Objects.toStringHelper(this).omitNullValues().add("description", description.orNull())
-               .add("location", location.orNull()).add("affinityGroup", affinityGroup.orNull()).add("label", label);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java
deleted file mode 100644
index 66c6640..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import java.net.URI;
-
-public class HostedServiceWithDetailedProperties extends HostedService {
-
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public Builder toBuilder() {
-      return new Builder().fromHostedServiceWithDetailedProperties(this);
-   }
-
-   public static class Builder extends HostedService.Builder<Builder> {
-
-      @Override
-      public Builder properties(HostedServiceProperties properties) {
-         this.properties = DetailedHostedServiceProperties.class.cast(properties);
-         return this;
-      }
-
-      public HostedServiceWithDetailedProperties build() {
-         return new HostedServiceWithDetailedProperties(url, name,
-               DetailedHostedServiceProperties.class.cast(properties));
-      }
-
-      public Builder fromHostedServiceWithDetailedProperties(HostedServiceWithDetailedProperties in) {
-         return fromHostedService(in);
-      }
-
-      @Override protected Builder self() {
-         return this;
-      }
-   }
-
-   protected HostedServiceWithDetailedProperties(URI url, String serviceName,
-         DetailedHostedServiceProperties properties) {
-      super(url, serviceName, properties);
-   }
-
-   @Override
-   public DetailedHostedServiceProperties getProperties() {
-      return DetailedHostedServiceProperties.class.cast(properties);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
index 9e6b9a2..bdfeda6 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
@@ -16,7 +16,12 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
 import java.util.List;
+
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -25,15 +30,14 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
+
 import org.jclouds.azurecompute.binders.BindCreateHostedServiceToXmlPayload;
 import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties;
 import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
 import org.jclouds.azurecompute.options.CreateHostedServiceOptions;
 import org.jclouds.azurecompute.xml.HostedServiceHandler;
-import org.jclouds.azurecompute.xml.HostedServiceWithDetailedPropertiesHandler;
 import org.jclouds.azurecompute.xml.ListHostedServicesHandler;
+import org.jclouds.javax.annotation.Nullable;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.MapBinder;
@@ -42,9 +46,6 @@ import org.jclouds.rest.annotations.QueryParams;
 import org.jclouds.rest.annotations.ResponseParser;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
 /**
  * The Service Management API includes operations for managing the hosted services beneath your
  * subscription.
@@ -53,7 +54,7 @@ import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
  */
 @Path("/services/hostedservices")
 @Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
-@Consumes(MediaType.APPLICATION_XML)
+@Consumes(APPLICATION_XML)
 public interface HostedServiceApi {
 
    /**
@@ -64,9 +65,10 @@ public interface HostedServiceApi {
     */
    @Named("ListHostedServices")
    @GET
+   @QueryParams(keys = "embed-detail", values = "true")
    @XMLResponseParser(ListHostedServicesHandler.class)
    @Fallback(EmptyListOnNotFoundOr404.class)
-   List<HostedServiceWithDetailedProperties> list();
+   List<HostedService> list();
 
    /**
     * The Create Hosted Service operation creates a new hosted service in Windows Azure.
@@ -88,7 +90,7 @@ public interface HostedServiceApi {
    @Named("CreateHostedService")
    @POST
    @MapBinder(BindCreateHostedServiceToXmlPayload.class)
-   @Produces(MediaType.APPLICATION_XML)
+   @Produces(APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
    String createServiceWithLabelInLocation(@PayloadParam("name") String name,
          @PayloadParam("label") String label, @PayloadParam("location") String location);
@@ -103,7 +105,7 @@ public interface HostedServiceApi {
    @Named("CreateHostedService")
    @POST
    @MapBinder(BindCreateHostedServiceToXmlPayload.class)
-   @Produces(MediaType.APPLICATION_XML)
+   @Produces(APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
    String createServiceWithLabelInLocation(@PayloadParam("name") String name,
          @PayloadParam("label") String label, @PayloadParam("location") String location,
@@ -121,24 +123,10 @@ public interface HostedServiceApi {
    @Named("GetHostedServiceProperties")
    @GET
    @Path("/{name}")
-   @XMLResponseParser(HostedServiceHandler.class)
-   @Fallback(NullOnNotFoundOr404.class)
-   HostedService get(@PathParam("name") String name);
-
-   /**
-    * like {@link #get(String)}, except additional data such as status and deployment information is
-    * returned.
-    *
-    * @param name
-    *           the unique DNS Prefix value in the Windows Azure Management Portal
-    */
-   @Named("GetHostedServiceProperties")
-   @GET
-   @Path("/{name}")
    @QueryParams(keys = "embed-detail", values = "true")
-   @XMLResponseParser(HostedServiceWithDetailedPropertiesHandler.class)
+   @XMLResponseParser(HostedServiceHandler.class)
    @Fallback(NullOnNotFoundOr404.class)
-   HostedServiceWithDetailedProperties getDetails(@PathParam("name") String name);
+   @Nullable HostedService get(@PathParam("name") String name);
 
    /**
     * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure.

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java
deleted file mode 100644
index ad77ab4..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import javax.inject.Inject;
-import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.date.DateService;
-import org.xml.sax.SAXException;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class DetailedHostedServicePropertiesHandler extends HostedServicePropertiesHandler {
-
-   private final DateService dateService;
-
-   @Inject
-   private DetailedHostedServicePropertiesHandler(DateService dateService) {
-      this.dateService = dateService;
-   }
-
-   private DetailedHostedServiceProperties.Builder builder = DetailedHostedServiceProperties.builder();
-
-   private String name;
-
-   @Override
-   public DetailedHostedServiceProperties getResult() {
-      try {
-         return builder.fromHostedServiceProperties(super.getResult()).build();
-      } finally {
-         builder = DetailedHostedServiceProperties.builder();
-      }
-   }
-
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
-      if (equalsOrSuffix(qName, "DateCreated")) {
-         builder.created(dateService.iso8601SecondsDateParse(currentOrNull(currentText)));
-      } else if (equalsOrSuffix(qName, "DateLastModified")) {
-         builder.lastModified(dateService.iso8601SecondsDateParse(currentOrNull(currentText)));
-      } else if (equalsOrSuffix(qName, "Status")) {
-         String rawStatus = currentOrNull(currentText);
-         builder.rawStatus(rawStatus);
-         builder.status(Status.fromValue(rawStatus));
-      } else if (equalsOrSuffix(qName, "Name")) {
-         this.name = currentOrNull(currentText);
-      } else if (equalsOrSuffix(qName, "Value")) {
-         builder.addExtendedProperty(this.name, currentOrNull(currentText));
-         this.name = null;
-      } else {
-         super.endElement(uri, name, qName);
-      }
-      currentText = new StringBuilder();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
index 04f009a..5e3c3e9 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java
@@ -16,78 +16,112 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import java.net.URI;
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.util.Date;
+import java.util.Map;
+
 import javax.inject.Inject;
+
 import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedService.Builder;
+import org.jclouds.date.DateService;
 import org.jclouds.http.functions.ParseSax;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
 
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
 
 /**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
+ * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >Response body description</a>
  */
-public class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<HostedService> {
-
-   private final HostedServicePropertiesHandler hostedServicePropertiesHandler;
-
-   @Inject protected HostedServiceHandler(HostedServicePropertiesHandler hostedServicePropertiesHandler) {
-      this.hostedServicePropertiesHandler = hostedServicePropertiesHandler;
-   }
+public final class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<HostedService> {
+   private String name;
+   private String location;
+   private String affinityGroup;
+   private String label;
+   private String description;
+   private HostedService.Status status;
+   private Date created;
+   private Date lastModified;
+   private Map<String, String> extendedProperties = Maps.newLinkedHashMap();
 
+   private boolean inHostedServiceProperties;
+   private String propertyName;
    private StringBuilder currentText = new StringBuilder();
-   protected HostedService.Builder<?> builder = builder();
+   private final DateService dateService;
 
-   protected Builder<?> builder() {
-      return HostedService.builder();
+   @Inject HostedServiceHandler(DateService dateService) {
+      this.dateService = dateService;
    }
 
-   private boolean inHostedServiceProperties;
+   @Override public HostedService getResult() {
+      HostedService result = HostedService.create(name, location, affinityGroup, label, description, status, created, //
+            lastModified, ImmutableMap.copyOf(extendedProperties));
+      resetState(); // handler is called in a loop.
+      return result;
+   }
 
-   @Override
-   public HostedService getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = builder();
-      }
+   private void resetState() {
+      name = description = location = affinityGroup = label = null;
+      status = null;
+      created = lastModified = null;
+      extendedProperties.clear();
+      inHostedServiceProperties = false;
+      propertyName = null;
    }
 
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
-      if (equalsOrSuffix(qName, "HostedServiceProperties")) {
+   @Override public void startElement(String ignoredUri, String ignoredLocalName, String qName, Attributes ignoredAttributes) {
+      if (qName.equals("HostedServiceProperties")) {
          inHostedServiceProperties = true;
       }
-      if (inHostedServiceProperties) {
-         hostedServicePropertiesHandler.startElement(url, name, qName, attributes);
-      }
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
-
-      if (equalsOrSuffix(qName, "HostedServiceProperties")) {
-         builder.properties(hostedServicePropertiesHandler.getResult());
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("HostedServiceProperties")) {
          inHostedServiceProperties = false;
       } else if (inHostedServiceProperties) {
-         hostedServicePropertiesHandler.endElement(uri, name, qName);
-      } else if (equalsOrSuffix(qName, "Url")) {
-         builder.url(URI.create(currentOrNull(currentText)));
-      } else if (equalsOrSuffix(qName, "ServiceName")) {
-         builder.name(currentOrNull(currentText));
+         if (qName.equals("DateCreated")) {
+            created = dateService.iso8601SecondsDateParse(currentOrNull(currentText));
+         } else if (qName.equals("DateLastModified")) {
+            lastModified = dateService.iso8601SecondsDateParse(currentOrNull(currentText));
+         } else if (qName.equals("Status")) {
+            String statusText = currentOrNull(currentText);
+            if (statusText != null) {
+               status = status(statusText);
+            }
+         } else if (qName.equals("Name")) {
+            propertyName = currentOrNull(currentText);
+         } else if (qName.equals("Value")) {
+            extendedProperties.put(propertyName, currentOrNull(currentText));
+            propertyName = null;
+         } else if (qName.equals("Description")) {
+            description = currentOrNull(currentText);
+         } else if (qName.equals("Location")) {
+            location = currentOrNull(currentText);
+         } else if (qName.equals("AffinityGroup")) {
+            affinityGroup = currentOrNull(currentText);
+         } else if (qName.equals("Label")) {
+            label = new String(base64().decode(currentOrNull(currentText)), UTF_8);
+         }
+      } else if (qName.equals("ServiceName")) {
+         name = currentOrNull(currentText);
       }
       currentText = new StringBuilder();
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
-      if (inHostedServiceProperties) {
-         hostedServicePropertiesHandler.characters(ch, start, length);
-      } else {
-         currentText.append(ch, start, length);
+   @Override public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+
+   private static HostedService.Status status(String status) {
+      try {
+         return HostedService.Status.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, status));
+      } catch (IllegalArgumentException e) {
+         return HostedService.Status.UNRECOGNIZED;
       }
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java
deleted file mode 100644
index d3962c5..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import org.jclouds.azurecompute.domain.HostedServiceProperties;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.SAXException;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class HostedServicePropertiesHandler extends
-         ParseSax.HandlerForGeneratedRequestWithResult<HostedServiceProperties> {
-
-   protected StringBuilder currentText = new StringBuilder();
-   private HostedServiceProperties.Builder<?> builder = HostedServiceProperties.builder();
-
-   @Override
-   public HostedServiceProperties getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = HostedServiceProperties.builder();
-      }
-   }
-
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
-      if (equalsOrSuffix(qName, "Description")) {
-         builder.description(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "Location")) {
-         builder.location(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "AffinityGroup")) {
-         builder.affinityGroup(currentOrNull(currentText));
-      } else if (equalsOrSuffix(qName, "Label")) {
-         builder.label(new String(base64().decode(currentOrNull(currentText)), UTF_8));
-      }
-      currentText = new StringBuilder();
-   }
-
-   @Override
-   public void characters(char ch[], int start, int length) {
-      currentText.append(ch, start, length);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java
deleted file mode 100644
index 69193b1..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import javax.inject.Inject;
-import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties;
-
-public class HostedServiceWithDetailedPropertiesHandler extends HostedServiceHandler {
-
-   @Inject protected HostedServiceWithDetailedPropertiesHandler(
-            DetailedHostedServicePropertiesHandler hostedServicePropertiesHandler) {
-      super(hostedServicePropertiesHandler);
-   }
-
-   @Override
-   protected HostedServiceWithDetailedProperties.Builder builder() {
-      return HostedServiceWithDetailedProperties.builder();
-   }
-
-   @Override
-   public HostedServiceWithDetailedProperties getResult() {
-      try {
-         return HostedServiceWithDetailedProperties.class.cast(builder.build());
-      } finally {
-         builder = builder();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
index 875e787..15bb5b2 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java
@@ -16,42 +16,35 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.inject.Inject;
 import java.util.List;
-import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties;
+
+import javax.inject.Inject;
+
+import org.jclouds.azurecompute.domain.HostedService;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
 
 /**
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460781">doc</a>
+ * @see <a href="http://msdn.microsoft.com/en-us/library/ee460781">Response body description</a>
  */
-public class ListHostedServicesHandler extends
-         ParseSax.HandlerForGeneratedRequestWithResult<List<HostedServiceWithDetailedProperties>> {
-
-   private final HostedServiceWithDetailedPropertiesHandler hostedServiceHandler;
-
-   private Builder<HostedServiceWithDetailedProperties> hostedServices = ImmutableList
-            .<HostedServiceWithDetailedProperties> builder();
-
+public final class ListHostedServicesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<HostedService>> {
    private boolean inHostedService;
+   private final HostedServiceHandler hostedServiceHandler;
+   private final Builder<HostedService> hostedServices = ImmutableList.builder();
 
-   @Inject
-   public ListHostedServicesHandler(HostedServiceWithDetailedPropertiesHandler hostedServiceHandler) {
+   @Inject ListHostedServicesHandler(HostedServiceHandler hostedServiceHandler) {
       this.hostedServiceHandler = hostedServiceHandler;
    }
 
-   @Override
-   public List<HostedServiceWithDetailedProperties> getResult() {
+   @Override public List<HostedService> getResult() {
       return hostedServices.build();
    }
 
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
-      if (SaxUtils.equalsOrSuffix(qName, "HostedService")) {
+   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("HostedService")) {
          inHostedService = true;
       }
       if (inHostedService) {
@@ -59,8 +52,7 @@ public class ListHostedServicesHandler extends
       }
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   @Override public void endElement(String uri, String name, String qName) {
       if (qName.equals("HostedService")) {
          inHostedService = false;
          hostedServices.add(hostedServiceHandler.getResult());
@@ -69,8 +61,7 @@ public class ListHostedServicesHandler extends
       }
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       if (inHostedService) {
          hostedServiceHandler.characters(ch, start, length);
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
index 558689f..da816d3 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
@@ -16,37 +16,36 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.azurecompute.domain.HostedService.Status.UNRECOGNIZED;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 import java.util.List;
 import java.util.logging.Logger;
-import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties;
+
 import org.jclouds.azurecompute.domain.HostedService;
 import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties;
 import org.jclouds.azurecompute.domain.Operation;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
-import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 
 @Test(groups = "live", testName = "HostedServiceApiLiveTest")
 public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
 
    public static final String HOSTED_SERVICE = (System.getProperty("user.name") + "-jclouds-hostedService")
-            .toLowerCase();
+         .toLowerCase();
 
    private Predicate<String> operationSucceeded;
-   private Predicate<HostedServiceWithDetailedProperties> hostedServiceCreated;
+   private Predicate<HostedService> hostedServiceCreated;
    private Predicate<HostedService> hostedServiceGone;
 
    private String location;
@@ -61,19 +60,19 @@ public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
             return api.getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED;
          }
       }, 600, 5, 5, SECONDS);
-      hostedServiceCreated = retry(new Predicate<HostedServiceWithDetailedProperties>() {
-         public boolean apply(HostedServiceWithDetailedProperties input) {
-            return api().getDetails(input.getName()).getProperties().getStatus() == Status.CREATED;
+      hostedServiceCreated = retry(new Predicate<HostedService>() {
+         public boolean apply(HostedService input) {
+            return api().get(input.name()).status() == Status.CREATED;
          }
       }, 600, 5, 5, SECONDS);
       hostedServiceGone = retry(new Predicate<HostedService>() {
          public boolean apply(HostedService input) {
-            return api().get(input.getName()) == null;
+            return api().get(input.name()) == null;
          }
       }, 600, 5, 5, SECONDS);
    }
 
-   private HostedServiceWithDetailedProperties hostedService;
+   private HostedService hostedService;
 
    public void testCreateHostedService() {
 
@@ -81,22 +80,22 @@ public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
       assertTrue(operationSucceeded.apply(requestId), requestId);
       Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
 
-      hostedService = api().getDetails(HOSTED_SERVICE);
+      hostedService = api().get(HOSTED_SERVICE);
       Logger.getAnonymousLogger().info("created hostedService: " + hostedService);
 
-      assertEquals(hostedService.getName(), HOSTED_SERVICE);
+      assertEquals(hostedService.name(), HOSTED_SERVICE);
 
       checkHostedService(hostedService);
 
       assertTrue(hostedServiceCreated.apply(hostedService), hostedService.toString());
-      hostedService = api().getDetails(hostedService.getName());
+      hostedService = api().get(hostedService.name());
       Logger.getAnonymousLogger().info("hostedService available: " + hostedService);
 
    }
 
    @Test(dependsOnMethods = "testCreateHostedService")
    public void testDeleteHostedService() {
-      String requestId = api().delete(hostedService.getName());
+      String requestId = api().delete(hostedService.name());
       assertTrue(operationSucceeded.apply(requestId), requestId);
       Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
 
@@ -104,62 +103,40 @@ public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
       Logger.getAnonymousLogger().info("hostedService deleted: " + hostedService);
    }
 
-   @Override
-   @AfterClass(groups = "live")
+   @Override @AfterClass(groups = "live")
    protected void tearDown() {
       String requestId = api().delete(HOSTED_SERVICE);
-      if (requestId != null)
+      if (requestId != null) {
          operationSucceeded.apply(requestId);
+      }
 
       super.tearDown();
    }
 
    @Test
    protected void testList() {
-      List<HostedServiceWithDetailedProperties> response = api().list();
+      List<HostedService> response = api().list();
 
-      for (HostedServiceWithDetailedProperties hostedService : response) {
+      for (HostedService hostedService : api().list()) {
          checkHostedService(hostedService);
       }
 
       if (response.size() > 0) {
          HostedService hostedService = response.iterator().next();
-         Assert.assertEquals(api().getDetails(hostedService.getName()), hostedService);
+         assertEquals(api().get(hostedService.name()), hostedService);
       }
    }
 
-   private void checkHostedService(HostedServiceWithDetailedProperties hostedService) {
-      checkNotNull(hostedService.getUrl(), "Url cannot be null for a HostedService.");
-      checkNotNull(hostedService.getName(), "ServiceName cannot be null for HostedService %s", hostedService.getUrl());
-      checkNotNull(hostedService.getProperties(), "Properties cannot be null for HostedService %s",
-               hostedService.getUrl());
-      checkProperties(hostedService.getProperties());
-   }
-
-   private void checkProperties(DetailedHostedServiceProperties hostedService) {
-      checkNotNull(hostedService.getDescription(),
-               "While Description can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s",
-               hostedService);
-      checkNotNull(hostedService.getLocation(),
-               "While Location can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s",
-               hostedService);
-      checkNotNull(hostedService.getAffinityGroup(),
-               "While AffinityGroup can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s",
-               hostedService);
-      checkState(hostedService.getLocation().isPresent() || hostedService.getAffinityGroup().isPresent(),
-               "Location or AffinityGroup must be present for DetailedHostedServiceProperties: %s", hostedService);
-      checkNotNull(hostedService.getLabel(), "Label cannot be null for HostedService %s", hostedService);
-
-      checkNotNull(hostedService.getStatus(), "Status cannot be null for DetailedHostedServiceProperties: %s",
-               hostedService);
-      assertNotEquals(hostedService.getStatus(), Status.UNRECOGNIZED,
-               "Status cannot be UNRECOGNIZED for DetailedHostedServiceProperties: " + hostedService);
-      checkNotNull(hostedService.getCreated(), "Created cannot be null for DetailedHostedServiceProperties %s",
-               hostedService);
-      checkNotNull(hostedService.getLastModified(),
-               "LastModified cannot be null for DetailedHostedServiceProperties %s", hostedService);
-      checkNotNull(hostedService.getExtendedProperties(),
-               "ExtendedProperties cannot be null for DetailedHostedServiceProperties %s", hostedService);
+   private void checkHostedService(HostedService hostedService) {
+      assertNotNull(hostedService.name(), "ServiceName cannot be null for " + hostedService);
+      assertTrue(hostedService.location() != null || hostedService.affinityGroup() != null,
+            "Location or AffinityGroup must be present for " + hostedService);
+      assertNotNull(hostedService.label(), "Label cannot be null for " + hostedService);
+      assertNotNull(hostedService.status(), "Status cannot be null for " + hostedService);
+      assertNotEquals(hostedService.status(), UNRECOGNIZED, "Status cannot be UNRECOGNIZED for " + hostedService);
+      assertNotNull(hostedService.created(), "Created cannot be null for " + hostedService);
+      assertNotNull(hostedService.lastModified(), "LastModified cannot be null for " + hostedService);
+      assertNotNull(hostedService.extendedProperties(), "ExtendedProperties cannot be null for " + hostedService);
    }
 
    private HostedServiceApi api() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
index a2a4aaf..1ac320d 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
@@ -16,17 +16,19 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.google.common.collect.ImmutableMap;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.jclouds.azurecompute.options.CreateHostedServiceOptions.Builder.description;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.parse.GetHostedServiceDetailsTest;
-import org.jclouds.azurecompute.parse.GetHostedServiceTest;
-import org.jclouds.azurecompute.parse.ListHostedServicesTest;
+import org.jclouds.azurecompute.xml.HostedServiceHandlerTest;
+import org.jclouds.azurecompute.xml.ListHostedServicesHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.jclouds.azurecompute.options.CreateHostedServiceOptions.Builder.description;
+import com.google.common.collect.ImmutableMap;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "HostedServiceApiMockTest")
 public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
@@ -38,9 +40,9 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.list()).containsExactlyElementsOf(ListHostedServicesTest.expected());
+         assertEquals(api.list(), ListHostedServicesHandlerTest.expected());
 
-         assertSent(server, "GET", "/services/hostedservices");
+         assertSent(server, "GET", "/services/hostedservices?embed-detail=true");
       } finally {
          server.shutdown();
       }
@@ -53,9 +55,9 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.list()).isEmpty();
+         assertTrue(api.list().isEmpty());
 
-         assertSent(server, "GET", "/services/hostedservices");
+         assertSent(server, "GET", "/services/hostedservices?embed-detail=true");
       } finally {
          server.shutdown();
       }
@@ -68,37 +70,7 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.get("myservice")).isEqualTo(GetHostedServiceTest.expected());
-
-         assertSent(server, "GET", "/services/hostedservices/myservice");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void getWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertThat(api.get("myservice")).isNull();
-
-         assertSent(server, "GET", "/services/hostedservices/myservice");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void getDetailsWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(xmlResponse("/hostedservice_details.xml"));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertThat(api.getDetails("myservice")).isEqualTo(GetHostedServiceDetailsTest.expected());
+         assertEquals(api.get("myservice"), HostedServiceHandlerTest.expected());
 
          assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true");
       } finally {
@@ -106,14 +78,14 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       }
    }
 
-   public void getDetailsWhenNotFound() throws Exception {
+   public void getWhenNotFound() throws Exception {
       MockWebServer server = mockAzureManagementServer();
       server.enqueue(new MockResponse().setResponseCode(404));
 
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.getDetails("myservice")).isNull();
+         assertNull(api.get("myservice"));
 
          assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true");
       } finally {
@@ -128,8 +100,7 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.createServiceWithLabelInLocation("myservice", "service mine", "West US"))
-               .isEqualTo("request-1");
+         assertEquals(api.createServiceWithLabelInLocation("myservice", "service mine", "West US"), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location.xml");
       } finally {
@@ -144,9 +115,8 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.createServiceWithLabelInLocation("myservice", "service mine", "West US",
-               description("my description").extendedProperties(ImmutableMap.of("Role", "Production"))))
-               .isEqualTo("request-1");
+         assertEquals(api.createServiceWithLabelInLocation("myservice", "service mine", "West US",
+               description("my description").extendedProperties(ImmutableMap.of("Role", "Production"))), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location_options.xml");
       } finally {
@@ -161,7 +131,7 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.delete("myservice")).isEqualTo("request-1");
+         assertEquals(api.delete("myservice"), "request-1");
 
          assertSent(server, "DELETE", "/services/hostedservices/myservice");
       } finally {
@@ -176,7 +146,7 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertThat(api.delete("myservice")).isNull();
+         assertNull(api.delete("myservice"));
 
          assertSent(server, "DELETE", "/services/hostedservices/myservice");
       } finally {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java
deleted file mode 100644
index 8a71f50..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties;
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties;
-import org.jclouds.azurecompute.xml.HostedServiceWithDetailedPropertiesHandler;
-import org.jclouds.date.DateService;
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "DetailedHostedServiceProperties")
-public class GetHostedServiceDetailsTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/hostedservice_details.xml");
-
-      HostedService expected = expected();
-
-      HostedServiceWithDetailedPropertiesHandler handler = injector.getInstance(HostedServiceWithDetailedPropertiesHandler.class);
-      HostedServiceWithDetailedProperties result = HostedServiceWithDetailedProperties.class.cast(factory.create(handler).parse(is));
-
-      assertEquals(result.toString(), expected.toString());
-
-   }
-
-   private static final DateService dateService = new SimpleDateFormatDateService();
-
-   public static HostedServiceWithDetailedProperties expected() {
-      return HostedServiceWithDetailedProperties.builder()
-                          .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys"))
-                          .name("neotys")
-                          .properties(DetailedHostedServiceProperties.builder()
-                                                                     .description("Implicitly created hosted service2012-08-06 14:55")
-                                                                     .location("West Europe")
-                                                                     .label("neotys")
-                                                                     .rawStatus("Created")
-                                                                     .status(Status.CREATED)
-                                                                     .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z"))
-                                                                     .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z"))
-                                                                     .build())
-                          .build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java
deleted file mode 100644
index b5ccd31..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedServiceProperties;
-import org.jclouds.azurecompute.xml.HostedServiceHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "GetHostedServiceTest")
-public class GetHostedServiceTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/hostedservice.xml");
-
-      HostedService expected = expected();
-
-      HostedServiceHandler handler = injector.getInstance(HostedServiceHandler.class);
-      HostedService result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-
-   }
-
-   public static HostedService expected() {
-      return HostedService.builder()
-                          .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys"))
-                          .name("neotys")
-                          .properties(HostedServiceProperties.builder()
-                                                             .description("Implicitly created hosted service2012-08-06 14:55")
-                                                             .location("West Europe")
-                                                             .label("neotys")
-                                                             .build())
-                          .build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java
deleted file mode 100644
index 3eaf136..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import com.google.common.collect.ImmutableList;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.List;
-import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties;
-import org.jclouds.azurecompute.xml.ListHostedServicesHandler;
-import org.jclouds.date.DateService;
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "ListHostedServicesTest")
-public class ListHostedServicesTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/hostedservices.xml");
-
-      List<HostedServiceWithDetailedProperties> expected = expected();
-
-      ListHostedServicesHandler handler = injector.getInstance(ListHostedServicesHandler.class);
-      List<HostedServiceWithDetailedProperties> result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-
-   }
-
-   private static final DateService dateService = new SimpleDateFormatDateService();
-
-   public static List<HostedServiceWithDetailedProperties> expected() {
-      return ImmutableList.<HostedServiceWithDetailedProperties>builder()
-                         .add(HostedServiceWithDetailedProperties.builder()
-                                      .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys"))
-                                      .name("neotys")
-                                      .properties(DetailedHostedServiceProperties.builder()
-                                               .description("Implicitly created hosted service2012-08-06  14:55")
-                                               .location("West Europe")
-                                               .label("neotys")
-                                               .rawStatus("Created")
-                                               .status(Status.CREATED)
-                                               .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z"))
-                                               .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z"))
-                                               .build())
-                                      .build())
-                         .add(HostedServiceWithDetailedProperties.builder()
-                                      .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3"))
-                                      .name("neotys3")
-                                      .properties(DetailedHostedServiceProperties.builder()
-                                               .location("West Europe")
-                                               .label("neotys3")
-                                               .rawStatus("Created")
-                                               .status(Status.CREATED)
-                                               .created(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z"))
-                                               .lastModified(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z"))
-                                               .build())
-                                      .build()).build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java
new file mode 100644
index 0000000..aefdca4
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/HostedServiceHandlerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Collections;
+
+import org.jclouds.azurecompute.domain.HostedService;
+import org.jclouds.azurecompute.domain.HostedService.Status;
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "HostedServiceHandlerTest")
+public class HostedServiceHandlerTest extends BaseHandlerTest {
+   private static final DateService DATE_SERVICE = new SimpleDateFormatDateService();
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/hostedservice.xml");
+      HostedService result = factory.create(new HostedServiceHandler(DATE_SERVICE)).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static HostedService expected() {
+      return HostedService.create( //
+            "neotys", // name
+            "West Europe", // location
+            null, // affinityGroup
+            "neotys", // label
+            "Implicitly created hosted service2012-08-06 14:55", // description
+            Status.CREATED, // status
+            DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T14:55:17Z"), // created
+            DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T15:50:34Z"), // lastModified
+            Collections.<String, String>emptyMap() // extendedProperties
+      );
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java
new file mode 100644
index 0000000..f40f3c9
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.HostedService;
+import org.jclouds.azurecompute.domain.HostedService.Status;
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListHostedServicesHandlerTest")
+public class ListHostedServicesHandlerTest extends BaseHandlerTest {
+   private static final DateService DATE_SERVICE = new SimpleDateFormatDateService();
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/hostedservices.xml");
+      ListHostedServicesHandler handler = new ListHostedServicesHandler(new HostedServiceHandler(DATE_SERVICE));
+      List<HostedService> result = factory.create(handler).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<HostedService> expected() {
+      return ImmutableList.of( //
+            HostedService.create( //
+                  "neotys", // name
+                  "West Europe", // location
+                  null, // affinityGroup
+                  "neotys", // label
+                  "Implicitly created hosted service2012-08-06 14:55", // description
+                  Status.CREATED, // status
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T14:55:17Z"), // created
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T15:50:34Z"), // lastModified
+                  Collections.<String, String>emptyMap() // extendedProperties
+            ), //
+            HostedService.create( //
+                  "neotys3", // name
+                  "West Europe", // location
+                  null, // affinityGroup
+                  "neotys3", // label
+                  null, // description
+                  Status.CREATED, // status
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-07T09:00:02Z"), // created
+                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-07T09:00:02Z"), // lastModified
+                  Collections.<String, String>emptyMap() // extendedProperties
+            ));
+   }
+}


[19/21] git commit: Update to latest Azure Compute api version.

Posted by ad...@apache.org.
Update to latest Azure Compute api version.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/ae506a64
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/ae506a64
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/ae506a64

Branch: refs/heads/1.8.x
Commit: ae506a645256e6241b813b80d3185dc7926f6366
Parents: 9963357
Author: Adrian Cole <ac...@twitter.com>
Authored: Wed Oct 22 20:51:34 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:06:16 2014 -0700

----------------------------------------------------------------------
 azurecompute/pom.xml                                               | 2 +-
 .../java/org/jclouds/azurecompute/AzureManagementApiMetadata.java  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ae506a64/azurecompute/pom.xml
----------------------------------------------------------------------
diff --git a/azurecompute/pom.xml b/azurecompute/pom.xml
index a6f75f7..32c2d97 100644
--- a/azurecompute/pom.xml
+++ b/azurecompute/pom.xml
@@ -38,7 +38,7 @@
     <test.jclouds.azurecompute.subscription-id>FIXME_subscription-id</test.jclouds.azurecompute.subscription-id>
     <!-- note that there's no prefix of "test." in the url.  This is to ensure that jclouds inteprets the value, as opposed to maven -->
     <test.azurecompute.endpoint>https://management.core.windows.net/${jclouds.azurecompute.subscription-id}</test.azurecompute.endpoint>
-    <test.azurecompute.api-version>2012-03-01</test.azurecompute.api-version>
+    <test.azurecompute.api-version>2014-06-01</test.azurecompute.api-version>
     <test.azurecompute.build-version />
     <test.azurecompute.identity>/path/to/cert.p12</test.azurecompute.identity>
     <test.azurecompute.credential>password to cert</test.azurecompute.credential>

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ae506a64/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
index e941dfa..762261c 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
@@ -55,7 +55,7 @@ public class AzureManagementApiMetadata extends BaseHttpApiMetadata<AzureCompute
       protected Builder() {
          id("azurecompute")
          .name("Microsoft Azure Service Management Service API")
-         .version("2012-03-01")
+         .version("2014-06-01")
          .identityName("Path to Management Certificate .p12 file, or PEM string")
          .credentialName("Password to Management Certificate")
          .defaultEndpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}")


[10/21] git commit: Cleanup output-only Location object.

Posted by ad...@apache.org.
Cleanup output-only Location object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/9da97959
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/9da97959
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/9da97959

Branch: refs/heads/1.8.x
Commit: 9da97959dcb3b6fe7e965fad421f1770ec1a4dfd
Parents: 615c745
Author: Adrian Cole <ac...@twitter.com>
Authored: Mon Oct 20 08:45:21 2014 -0400
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:53:55 2014 -0700

----------------------------------------------------------------------
 .../jclouds/azurecompute/domain/Location.java   | 139 ++++++-------------
 .../azurecompute/xml/ListLocationsHandler.java  |  35 ++---
 .../azurecompute/xml/LocationHandler.java       |  43 +++---
 .../azurecompute/features/DiskApiLiveTest.java  |   2 +-
 .../features/HostedServiceApiLiveTest.java      |   2 +-
 .../azurecompute/features/ImageApiLiveTest.java |   2 +-
 .../features/LocationApiLiveTest.java           |  34 ++---
 .../features/LocationApiMockTest.java           |   4 +-
 .../azurecompute/parse/ListLocationsTest.java   |  79 -----------
 .../xml/ListLocationsHandlerTest.java           |  52 +++++++
 10 files changed, 142 insertions(+), 250 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
index 494f35a..0949d46 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java
@@ -16,134 +16,73 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-
+import static com.google.common.base.Objects.equal;
 import static com.google.common.base.Preconditions.checkNotNull;
 
-/**
- *
- * A geographical region in which a service or storage account will be hosted.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class Location {
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public Builder toBuilder() {
-      return builder().fromLocation(this);
-   }
-
-   public static class Builder {
-
-      private String name;
-      private String displayName;
-      private ImmutableSet.Builder<String> availableServices = ImmutableSet.<String> builder();
+import java.util.List;
 
-      /**
-       * @see Location#getName()
-       */
-      public Builder name(String name) {
-         this.name = name;
-         return this;
-      }
-
-      /**
-       * @see Location#getDisplayName()
-       */
-      public Builder displayName(String displayName) {
-         this.displayName = displayName;
-         return this;
-      }
-
-      /**
-       * @see Location#getAvailableServices()
-       */
-      public Builder addAvailableService(String availableService) {
-         this.availableServices.add(checkNotNull(availableService, "availableService"));
-         return this;
-      }
-
-      /**
-       * @see Location#getAvailableServices()
-       */
-      public Builder availableServices(Iterable<String> availableServices) {
-         this.availableServices = ImmutableSet.<String> builder().addAll(
-                  checkNotNull(availableServices, "availableServices"));
-         return this;
-      }
+import com.google.common.base.Objects;
 
-      public Location build() {
-         return new Location(name, displayName, availableServices.build());
-      }
+/** A data center location that is valid for your subscription. */
+public final class Location {
 
-      public Builder fromLocation(Location in) {
-         return this.name(in.getName()).displayName(in.getDisplayName()).availableServices(in.getAvailableServices());
-      }
+   /** The name of the data center location. Ex. {@code West Europe}. */
+   public String name() {
+      return name;
    }
 
-   private final String name;
-   private final String displayName;
-   private final Set<String> availableServices;
-
-   protected Location(String name, String displayName, Iterable<String> availableServices) {
-      this.name = checkNotNull(name, "name");
-      this.displayName = checkNotNull(displayName, "displayName for %s", name);
-      this.availableServices = ImmutableSet.copyOf(checkNotNull(availableServices, "availableServices for %s", name));
+   /** The localized name of the data center location. */
+   public String displayName() {
+      return displayName;
    }
 
-   /**
-    *
-    * The name of a data center location that is valid for your subscription. For example:
-    * {@code West Europe}
-    */
-   public String getName() {
-      return name;
+   /** Indicates the services available at this location. Ex. {@code Compute}. */
+   public List<String> availableServices() {
+      return availableServices;
    }
 
-   /**
-    * The localized name of data center location.
-    */
-   public String getDisplayName() {
-      return displayName;
+   public static Location create(String name, String displayName, List<String> availableServices) {
+      return new Location(name, displayName, availableServices);
    }
 
-   /**
-    * Indicates the services available at a location.
-    *
-    * Returned values are none, one, or both of the values listed below.
-    *
-    * Compute
-    *
-    * Storage
-    */
-   public Set<String> getAvailableServices() {
-      return availableServices;
+   // TODO: Remove from here down with @AutoValue.
+   private Location(String name, String displayName, List<String> availableServices) {
+      this.name = checkNotNull(name, "name");
+      this.displayName = checkNotNull(displayName, "displayName");
+      this.availableServices = checkNotNull(availableServices, "availableServices");
    }
 
+   private final String name;
+   private final String displayName;
+   private final List<String> availableServices;
+
    @Override
    public int hashCode() {
-      return Objects.hashCode(name);
+      return Objects.hashCode(name, displayName, availableServices);
    }
 
    @Override
    public boolean equals(Object obj) {
-      if (this == obj)
+      if (this == obj) {
          return true;
-      if (obj == null)
+      }
+      if (obj == null) {
          return false;
-      if (getClass() != obj.getClass())
+      }
+      if (getClass() != obj.getClass()) {
          return false;
+      }
       Location other = (Location) obj;
-      return Objects.equal(this.name, other.name);
+      return equal(this.name, other.name) &&
+            equal(this.displayName, other.displayName) &&
+            equal(this.availableServices, other.availableServices);
    }
 
    @Override
    public String toString() {
-      return Objects.toStringHelper(this).omitNullValues().add("name", name).add("displayName", displayName)
-               .add("availableServices", availableServices).toString();
+      return Objects.toStringHelper(this)
+            .add("name", name)
+            .add("displayName", displayName)
+            .add("availableServices", availableServices).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
index f257a6a..dc05df5 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java
@@ -16,46 +16,31 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.inject.Inject;
 import java.util.List;
+
 import org.jclouds.azurecompute.domain.Location;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Location>> {
 
-   private final LocationHandler locationHandler;
-
-   private Builder<Location> locations = ImmutableList.<Location> builder();
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
 
+public final class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Location>> {
    private boolean inLocation;
+   private final LocationHandler locationHandler = new LocationHandler();
+   private final Builder<Location> locations = ImmutableList.builder();
 
-   @Inject
-   public ListLocationsHandler(LocationHandler locationHandler) {
-      this.locationHandler = locationHandler;
-   }
-
-   @Override
-   public List<Location> getResult() {
+   @Override public List<Location> getResult() {
       return locations.build();
    }
 
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
-      if (SaxUtils.equalsOrSuffix(qName, "Location")) {
+   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("Location")) {
          inLocation = true;
       }
-      if (inLocation) {
-         locationHandler.startElement(url, name, qName, attributes);
-      }
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   @Override public void endElement(String uri, String name, String qName) {
       if (qName.equals("Location")) {
          inLocation = false;
          locations.add(locationHandler.getResult());

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java
index d2e229a..a16505a 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java
@@ -16,42 +16,45 @@
  */
 package org.jclouds.azurecompute.xml;
 
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.util.List;
+
 import org.jclouds.azurecompute.domain.Location;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.SAXException;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 
 /**
  * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
  */
-public class LocationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Location> {
+final class LocationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Location> {
+   private String name;
+   private String displayName;
+   private final List<String> availableServices = Lists.newArrayList();
 
-   private StringBuilder currentText = new StringBuilder();
-   private Location.Builder builder = Location.builder();
+   private final StringBuilder currentText = new StringBuilder();
 
-   @Override
-   public Location getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = Location.builder();
-      }
+   @Override public Location getResult() {
+      Location result = Location.create(name, displayName, ImmutableList.copyOf(availableServices));
+      name = displayName = null; // handler is called in a loop.
+      availableServices.clear();
+      return result;
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
       if (qName.equals("Name")) {
-         builder.name(SaxUtils.currentOrNull(currentText));
+         name = currentOrNull(currentText);
       } else if (qName.equals("DisplayName")) {
-         builder.displayName(SaxUtils.currentOrNull(currentText));
+         displayName = currentOrNull(currentText);
       } else if (qName.equals("AvailableService")) {
-         builder.addAvailableService(SaxUtils.currentOrNull(currentText));
+         availableServices.add(currentOrNull(currentText));
       }
-      currentText = new StringBuilder();
+      currentText.setLength(0);
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       currentText.append(ch, start, length);
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index 53531de..4e8caba 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -45,7 +45,7 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
       locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(),
                new Function<Location, String>() {
                   public String apply(Location in) {
-                     return in.getName();
+                     return in.name();
                   }
                }));
       images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function<Image, String>() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
index da816d3..eb0eec8 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
@@ -54,7 +54,7 @@ public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
    public void setup() {
       super.setup();
       // TODO: filter locations on those who have compute
-      location = Iterables.get(api.getLocationApi().list(), 0).getName();
+      location = Iterables.get(api.getLocationApi().list(), 0).name();
       operationSucceeded = retry(new Predicate<String>() {
          public boolean apply(String input) {
             return api.getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
index 2b1aaf0..71d4deb 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
@@ -43,7 +43,7 @@ public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
 
       locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
          public String apply(Location in) {
-            return in.getName();
+            return in.name();
          }
       }));
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java
index 455ef11..d270442 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java
@@ -16,42 +16,34 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 import java.util.Arrays;
 import java.util.List;
+
 import org.jclouds.azurecompute.domain.Location;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.Test;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
 @Test(groups = "live", testName = "LocationApiLiveTest")
 public class LocationApiLiveTest extends BaseAzureComputeApiLiveTest {
 
-   @Test
-   protected void testList() {
-      List<Location> response = api().list();
+   private static final List<String> KNOWN_SERVICES = Arrays
+         .asList("Compute", "Storage", "PersistentVMRole", "HighMemory");
 
-      for (Location location : response) {
+   @Test public void testList() {
+      for (Location location : api().list()) {
          checkLocation(location);
       }
-
    }
 
-   private Predicate<String> knownServices = Predicates
-         .in(Arrays.asList("Compute", "Storage", "PersistentVMRole", "HighMemory"));
-
    private void checkLocation(Location location) {
-      checkNotNull(location.getName(), "Name cannot be null for a Location.");
-      checkNotNull(location.getDisplayName(), "DisplayName cannot be null for Location %s", location.getName());
-      checkNotNull(location.getAvailableServices(), "AvailableServices cannot be null for Location %s",
-            location.getName());
-      checkState(Iterables.all(location.getAvailableServices(), knownServices),
-            "AvailableServices in Location %s didn't match %s: %s", location.getName(), knownServices,
-            location.getAvailableServices());
+      assertNotNull(location.name(), "Name cannot be null for a Location.");
+      assertNotNull(location.displayName(), "DisplayName cannot be null for: " + location);
+      assertNotNull(location.availableServices(), "AvailableServices cannot be null for: " + location.name());
+      assertTrue(KNOWN_SERVICES.containsAll(location.availableServices()),
+            "AvailableServices in " + location + " didn't match: " + KNOWN_SERVICES);
    }
 
    private LocationApi api() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
index 695b54d..b476ed1 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
@@ -19,7 +19,7 @@ package org.jclouds.azurecompute.features;
 import com.squareup.okhttp.mockwebserver.MockResponse;
 import com.squareup.okhttp.mockwebserver.MockWebServer;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.parse.ListLocationsTest;
+import org.jclouds.azurecompute.xml.ListLocationsHandlerTest;
 import org.testng.annotations.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ public class LocationApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          LocationApi api = api(server.getUrl("/")).getLocationApi();
 
-         assertThat(api.list()).containsExactlyElementsOf(ListLocationsTest.expected());
+         assertThat(api.list()).containsExactlyElementsOf(ListLocationsHandlerTest.expected());
 
          assertSent(server, "GET", "/locations");
       } finally {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java
deleted file mode 100644
index 5ec96b1..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import com.google.common.collect.ImmutableList;
-import java.io.InputStream;
-import java.util.List;
-import org.jclouds.azurecompute.domain.Location;
-import org.jclouds.azurecompute.xml.ListLocationsHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "LocationsTest")
-public class ListLocationsTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/locations.xml");
-
-      List<Location> expected = expected();
-
-      ListLocationsHandler handler = injector.getInstance(ListLocationsHandler.class);
-      List<Location> result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-
-   }
-
-   public static List<Location> expected() {
-      List<String> availableServices = ImmutableList.of("Compute", "Storage", "PersistentVMRole");
-      return ImmutableList.<Location>builder()
-                         .add(Location.builder()
-                                      .name("West US")
-                                      .displayName("West US")
-                                      .availableServices(availableServices)
-                                      .build())
-                         .add(Location.builder()
-                                      .name("East US")
-                                      .displayName("East US")
-                                      .availableServices(availableServices)
-                                      .build())
-                         .add(Location.builder()
-                                      .name("East Asia")
-                                      .displayName("East Asia")
-                                      .availableServices(availableServices)
-                                      .build())
-                         .add(Location.builder()
-                                      .name("Southeast Asia")
-                                      .displayName("Southeast Asia")
-                                      .availableServices(availableServices)
-                                      .build())
-                         .add(Location.builder()
-                                      .name("North Europe")
-                                      .displayName("North Europe")
-                                      .availableServices(availableServices)
-                                      .build())
-                         .add(Location.builder()
-                                      .name("West Europe")
-                                      .displayName("West Europe")
-                                      .availableServices(availableServices)
-                                      .build()).build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/9da97959/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
new file mode 100644
index 0000000..599d307
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListLocationsHandlerTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListLocationsHandlerTest")
+public class ListLocationsHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/locations.xml");
+      List<Location> result = factory.create(new ListLocationsHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<Location> expected() {
+      List<String> availableServices = ImmutableList.of("Compute", "Storage", "PersistentVMRole");
+      return ImmutableList.of( //
+            Location.create("West US", "West US", availableServices), //
+            Location.create("East US", "East US", availableServices), //
+            Location.create("East Asia", "East Asia", availableServices), //
+            Location.create("Southeast Asia", "Southeast Asia", availableServices), //
+            Location.create("North Europe", "North Europe", availableServices), //
+            Location.create("West Europe", "West Europe", availableServices) //
+      );
+   }
+
+}


[13/21] git commit: Cleanup Azure compute DeploymentParams input value type.

Posted by ad...@apache.org.
Cleanup Azure compute DeploymentParams input value type.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/2cd19ba8
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/2cd19ba8
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/2cd19ba8

Branch: refs/heads/1.8.x
Commit: 2cd19ba8395b786def25a3077721135273276a08
Parents: bd8717b
Author: Adrian Cole <ac...@twitter.com>
Authored: Mon Oct 20 13:45:15 2014 -0400
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:02:53 2014 -0700

----------------------------------------------------------------------
 .../BindDeploymentParamsToXmlPayload.java       | 118 -------
 .../binders/CreateDeploymentToXML.java          | 119 +++++++
 .../azurecompute/domain/DeploymentParams.java   | 308 ++++++++++++-------
 .../azurecompute/domain/InputEndpoint.java      | 137 ---------
 .../jclouds/azurecompute/domain/Protocol.java   |  23 --
 .../azurecompute/features/DeploymentApi.java    |  10 +-
 .../features/DeploymentApiMockTest.java         |  45 ++-
 .../azurecompute/xml/ListImagesHandlerTest.java |   2 +-
 .../test/resources/deploymentparams-windows.xml |   1 +
 .../src/test/resources/deploymentparams.xml     |   2 +-
 azurecompute/src/test/resources/images.xml      |   4 +-
 11 files changed, 359 insertions(+), 410 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
deleted file mode 100644
index 8b20634..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.binders;
-
-import static com.google.common.base.CaseFormat.UPPER_CAMEL;
-import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
-
-import javax.inject.Singleton;
-
-import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.azurecompute.domain.InputEndpoint;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-import com.google.common.base.Throwables;
-import com.jamesmurty.utils.XMLBuilder;
-
-@Singleton
-public class BindDeploymentParamsToXmlPayload implements Binder {
-
-   @Override
-   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
-      DeploymentParams params = DeploymentParams.class.cast(input);
-      try {
-         XMLBuilder builder = XMLBuilder.create("Deployment").a("xmlns", "http://schemas.microsoft.com/windowsazure")
-            .e("Name").t(params.getName()).up()
-            .e("DeploymentSlot").t("Production").up()
-            .e("Label").t(params.getName()).up()
-            .e("RoleList")
-            .e("Role")
-            .e("RoleName").t(params.getName()).up()
-            .e("RoleType").t("PersistentVMRole").up()
-            .e("ConfigurationSets");
-
-         if (params.getOsType() == OSType.WINDOWS) {
-            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
-            configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
-               .e("ComputerName").t(params.getUsername()).up()
-               .e("AdminPassword").t(params.getPassword()).up()
-               .e("ResetPasswordOnFirstLogon").t("false").up()
-               .e("EnableAutomaticUpdate").t("false").up()
-               .e("DomainJoin")
-               .e("Credentials")
-                  .e("Domain").t(params.getName()).up()
-                  .e("Username").t(params.getUsername()).up()
-                  .e("Password").t(params.getPassword()).up()
-               .up() // Credentials
-               .e("JoinDomain").t(params.getName()).up()
-               .up() // Domain Join
-               .e("StoredCertificateSettings").up()
-               .up(); // Windows ConfigurationSet
-         } else if (params.getOsType() == OSType.LINUX) {
-            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
-            configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
-               .e("HostName").t(params.getName()).up()
-               .e("UserName").t(params.getUsername()).up()
-               .e("UserPassword").t(params.getPassword()).up()
-               .e("DisableSshPasswordAuthentication").t("false").up()
-               .e("SSH").up()
-               .up(); // Linux ConfigurationSet
-         }
-
-         XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network
-         configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up();
-
-         XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints");
-         for (InputEndpoint endpoint : params.getEndpoints()) {
-            XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint");
-            inputBuilder.e("LocalPort").t(endpoint.getLocalPort().toString()).up()
-               .e("Name").t(endpoint.getName()).up()
-               .e("Port").t(endpoint.getExternalPort().toString()).up()
-               .e("Protocol").t(endpoint.getProtocol().name().toLowerCase()).up()
-               .up(); //InputEndpoint
-         }
-
-         inputEndpoints.up();
-         configBuilder.e("SubnetNames").up()
-            .up();
-
-         builder.up() //ConfigurationSets
-            .e("DataVirtualHardDisks").up()
-            .e("OSVirtualHardDisk")
-            .e("HostCaching").t("ReadWrite").up()
-            .e("MediaLink").t(url(params)).up()
-            .e("SourceImageName").t(params.getSourceImageName()).up()
-            .e("OS").t(params.getOsType() == LINUX ? "Linux" : "Windows").up()
-            .up() //OSVirtualHardDisk
-            .e("RoleSize").t(UPPER_UNDERSCORE.to(UPPER_CAMEL, params.getSize().name())).up()
-            .up() //Role
-            .up(); //RoleList
-
-         return (R) request.toBuilder().payload(builder.asString()).build();
-      } catch (Exception e) {
-         throw Throwables.propagate(e);
-      }
-   }
-
-   private static String url(DeploymentParams params) {
-      return String.format("http://%s.blob.core.windows.net/disks/%s/%s", params.getStorageAccount(), params.getName(),
-            params.getSourceImageName());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java
new file mode 100644
index 0000000..67573a8
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.binders;
+
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
+
+import java.util.Map;
+
+import org.jclouds.azurecompute.domain.DeploymentParams;
+import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+
+import com.jamesmurty.utils.XMLBuilder;
+
+public final class CreateDeploymentToXML implements MapBinder {
+
+   @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+      String name = postParams.get("name").toString();
+      DeploymentParams params = DeploymentParams.class.cast(postParams.get("params"));
+
+      try {
+         XMLBuilder builder = XMLBuilder.create("Deployment", "http://schemas.microsoft.com/windowsazure")
+            .e("Name").t(name).up()
+            .e("DeploymentSlot").t("Production").up()
+            .e("Label").t(name).up()
+            .e("RoleList")
+            .e("Role")
+            .e("RoleName").t(name).up()
+            .e("RoleType").t("PersistentVMRole").up()
+            .e("ConfigurationSets");
+
+         if (params.os() == OSType.WINDOWS) {
+            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
+            configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
+               .e("ComputerName").t(name).up()
+               .e("AdminPassword").t(params.password()).up()
+               .e("ResetPasswordOnFirstLogon").t("false").up()
+               .e("EnableAutomaticUpdate").t("false").up()
+               .e("DomainJoin")
+               .e("Credentials")
+                  .e("Domain").t(name).up()
+                  .e("Username").t(params.username()).up()
+                  .e("Password").t(params.password()).up()
+               .up() // Credentials
+               .e("JoinDomain").t(name).up()
+               .up() // Domain Join
+               .e("StoredCertificateSettings").up()
+               .up(); // Windows ConfigurationSet
+         } else if (params.os() == OSType.LINUX) {
+            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
+            configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
+               .e("HostName").t(name).up()
+               .e("UserName").t(params.username()).up()
+               .e("UserPassword").t(params.password()).up()
+               .e("DisableSshPasswordAuthentication").t("false").up()
+               .e("SSH").up()
+               .up(); // Linux ConfigurationSet
+         } else {
+            throw new IllegalArgumentException("Unrecognized os type " + params);
+         }
+
+         XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network
+         configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up();
+
+         XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints");
+         for (DeploymentParams.ExternalEndpoint endpoint : params.externalEndpoints()) {
+            XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint");
+            inputBuilder.e("LocalPort").t(Integer.toString(endpoint.localPort())).up()
+               .e("Name").t(endpoint.name()).up()
+               .e("Port").t(Integer.toString(endpoint.port())).up()
+               .e("Protocol").t(endpoint.protocol().toLowerCase()).up()
+               .up(); //InputEndpoint
+         }
+
+         inputEndpoints.up();
+         configBuilder.e("SubnetNames").up()
+            .up();
+
+         builder.up() //ConfigurationSets
+            .e("DataVirtualHardDisks").up()
+            .e("OSVirtualHardDisk")
+            .e("HostCaching").t("ReadWrite").up()
+            .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
+            .e("SourceImageName").t(params.sourceImageName()).up()
+            .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
+            .up() //OSVirtualHardDisk
+            .e("RoleSize").t(UPPER_UNDERSCORE.to(UPPER_CAMEL, params.size().name())).up()
+            .up() //Role
+            .up(); //RoleList
+
+         // TODO: Undeprecate this method as forcing users to wrap a String in guava's ByteSource is not great.
+         return (R) request.toBuilder().payload(builder.asString()).build();
+      } catch (Exception e) {
+         throw propagate(e);
+      }
+   }
+
+   @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+      throw new UnsupportedOperationException("use map form");
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index 8007750..2dd9ae5 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -16,12 +16,18 @@
  */
 package org.jclouds.azurecompute.domain;
 
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Collection;
 import java.util.List;
 
 import org.jclouds.azurecompute.domain.Image.OSType;
 
 import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
 /**
@@ -29,34 +35,138 @@ import com.google.common.collect.Lists;
  *
  * Warning : the OSType must be the one of the source image used to create the VM
  */
-public class DeploymentParams {
+// TODO: check which can be null.
+public final class DeploymentParams {
 
-   public static Builder builder() {
-      return new Builder();
+   public static final class ExternalEndpoint {
+
+      public String name() {
+         return name;
+      }
+
+      /** Either {@code tcp} or {@code udp}. */
+      public String protocol() {
+         return protocol;
+      }
+
+      public int port() {
+         return port;
+      }
+
+      public int localPort() {
+         return localPort;
+      }
+
+      public static ExternalEndpoint inboundTcpToLocalPort(int port, int localPort) {
+         return new ExternalEndpoint(String.format("tcp %s:%s", port, localPort), "tcp", port, localPort);
+      }
+
+      public static ExternalEndpoint inboundUdpToLocalPort(int port, int localPort) {
+         return new ExternalEndpoint(String.format("udp %s:%s", port, localPort), "udp", port, localPort);
+      }
+
+      // TODO: Remove from here down with @AutoValue.
+      private ExternalEndpoint(String name, String protocol, int port, int localPort) {
+         this.name = checkNotNull(name, "name");
+         this.protocol = checkNotNull(protocol, "protocol");
+         this.port = port;
+         this.localPort = localPort;
+      }
+
+      private final String name;
+      private final String protocol;
+      private final int port;
+      private final int localPort;
+
+      @Override public int hashCode() {
+         return Objects.hashCode(name, protocol, localPort, port);
+      }
+
+      @Override public boolean equals(Object object) {
+         if (this == object) {
+            return true;
+         }
+         if (object instanceof ExternalEndpoint) {
+            ExternalEndpoint that = ExternalEndpoint.class.cast(object);
+            return equal(name, that.name)
+                  && equal(protocol, that.protocol)
+                  && equal(localPort, that.localPort)
+                  && equal(port, that.port);
+         } else {
+            return false;
+         }
+      }
+
+      @Override public String toString() {
+         return toStringHelper(this)
+               .add("name", name)
+               .add("protocol", protocol)
+               .add("port", port)
+               .add("localPort", localPort).toString();
+      }
+   }
+
+   /**
+    * Specifies the name of a user to be created in the sudoers group of the
+    * virtual machine. User names are ASCII character strings 1 to 32
+    * characters in length.
+    */
+   public String username() {
+      return username;
+   }
+
+   /** The size of the virtual machine to allocate. The default value is Small. */
+   public RoleSize size() {
+      return size;
+   }
+
+   /**
+    * Specifies the associated password for the user name.
+    * Passwords are ASCII character strings 6 to 72 characters in
+    * length.
+    */
+   public String password() {
+      return password;
+   }
+
+   /** {@link Image#name() name} of the user or platform image. */
+   public String sourceImageName() {
+      return sourceImageName;
+   }
+
+   /** Indicates the {@link Image#mediaLink() location} when {@link #sourceImageName() source} is a platform image. */
+   public URI mediaLink() {
+      return mediaLink;
+   }
+
+   /** {@link Image#os() Os type} of the {@link #sourceImageName() source image}. */
+   public OSType os() {
+      return os;
+   }
+
+   public List<ExternalEndpoint> externalEndpoints() {
+      return externalEndpoints;
    }
 
    public Builder toBuilder() {
       return builder().fromDeploymentParams(this);
    }
 
-   public static class Builder {
+   public static Builder builder() {
+      return new Builder();
+   }
 
-      private String name;
-      private String sourceImageName;
+   public static final class Builder {
+      private RoleSize size = RoleSize.SMALL;
       private String username;
       private String password;
-      private String storageAccount;
-      private OSType osType;
-      private RoleSize size = RoleSize.SMALL;
-      private List<InputEndpoint> endpoints = Lists.newArrayList();
-
-      public Builder name(String name) {
-         this.name = name;
-         return this;
-      }
+      private String sourceImageName;
+      private URI mediaLink;
+      private OSType os;
+      private List<ExternalEndpoint> externalEndpoints = Lists.newArrayList();
 
-      public Builder sourceImageName(String sourceImageName) {
-         this.sourceImageName = sourceImageName;
+      public Builder size(RoleSize size) {
+         this.size = size;
          return this;
       }
 
@@ -70,141 +180,105 @@ public class DeploymentParams {
          return this;
       }
 
-      public Builder storageAccount(String storageAccount) {
-         this.storageAccount = storageAccount;
+      public Builder sourceImageName(String sourceImageName) {
+         this.sourceImageName = sourceImageName;
          return this;
       }
 
-      public Builder size(RoleSize size) {
-         this.size = size;
+      public Builder mediaLink(URI mediaLink) {
+         this.mediaLink = mediaLink;
+         return this;
+      }
+
+      public Builder os(OSType os) {
+         this.os = os;
          return this;
       }
 
-      public Builder osType(OSType osType) {
-         this.osType = osType;
+      public Builder externalEndpoint(ExternalEndpoint endpoint) {
+         externalEndpoints.add(endpoint);
          return this;
       }
 
-      public Builder endpoint(InputEndpoint endpoint) {
-         endpoints.add(endpoint);
+      public Builder externalEndpoints(Collection<ExternalEndpoint> externalEndpoints) {
+         externalEndpoints.addAll(externalEndpoints);
          return this;
       }
 
       public DeploymentParams build() {
-         return new DeploymentParams(name, sourceImageName, username, password, storageAccount, size, osType,
-               endpoints);
+         return DeploymentParams.create(size, username, password, sourceImageName, mediaLink, os,
+               ImmutableList.copyOf(externalEndpoints));
       }
 
       public Builder fromDeploymentParams(DeploymentParams in) {
-         // TODO Since the virtualMachineName should be unique, is it a good idea to copy it ?
-         return this.name(in.getName()).sourceImageName(in.getSourceImageName()).username(in.getUsername())
-               .password(in.getPassword()).size(in.getSize());
+         return size(in.size())
+               .username(in.username())
+               .password(in.password())
+               .sourceImageName(in.sourceImageName())
+               .mediaLink(in.mediaLink())
+               .os(in.os())
+               .externalEndpoints(in.externalEndpoints());
       }
    }
 
-   private final String name;
-   private final String sourceImageName;
-   private final String username;
-   private final String password;
-   private final String storageAccount;
-   private final RoleSize size;
-   private final OSType osType;
-   private final List<InputEndpoint> endpoints;
-
-   public DeploymentParams(String name, String sourceImageName, String username, String password, String storageAccount,
-         RoleSize size, OSType osType, final List<InputEndpoint> endpoints) {
-      this.name = name;
-      this.sourceImageName = sourceImageName;
-      this.username = username;
-      this.password = password;
-      this.storageAccount = storageAccount;
-      this.size = size;
-      this.osType = osType;
-      this.endpoints = endpoints;
-   }
-
-   /**
-    * Specifies the name for the deployment and its virtual machine. The name must be unique
-    * within Windows Azure.
-    */
-   public String getName() {
-      return name;
-   }
-
-   /**
-    * Specifies the name of an operating system image in the image repository.
-    */
-   public String getSourceImageName() {
-      return sourceImageName;
-   }
-
-   /**
-    * Specifies the name of a user to be created in the sudoer group of the
-    * virtual machine. User names are ASCII character strings 1 to 32
-    * characters in length.
-    */
-   public String getUsername() {
-      return username;
-   }
-
-   /**
-    * Specifies the associated password for the user name.
-    * PasswoazureManagement are ASCII character strings 6 to 72 characters in
-    * length.
-    */
-   public String getPassword() {
-      return password;
+   private static DeploymentParams create(RoleSize size, String username, String password, String sourceImageName,
+         URI mediaLink, OSType os, List<ExternalEndpoint> externalEndpoints) {
+      return new DeploymentParams(size, username, password, sourceImageName, mediaLink, os, externalEndpoints);
    }
 
-   public String getStorageAccount() {
-      return storageAccount;
+   // TODO: Remove from here down with @AutoValue.
+   private DeploymentParams(RoleSize size, String username, String password, String sourceImageName, URI mediaLink,
+         OSType os, List<ExternalEndpoint> externalEndpoints) {
+      this.size = checkNotNull(size, "size");
+      this.username = checkNotNull(username, "username");
+      this.password = checkNotNull(password, "password");
+      this.sourceImageName = checkNotNull(sourceImageName, "sourceImageName");
+      this.mediaLink = checkNotNull(mediaLink, "mediaLink");
+      this.os = checkNotNull(os, "os");
+      this.externalEndpoints = checkNotNull(externalEndpoints, "externalEndpoints");
    }
 
-   /**
-    * The size of the virtual machine to allocate. The default value is Small.
-    */
-   public RoleSize getSize() {
-      return size;
-   }
-
-   /**
-    * Os type of the given sourceImage
-    */
-   public OSType getOsType() {
-      return osType;
-   }
-
-   public List<InputEndpoint> getEndpoints() {
-      return endpoints;
-   }
+   private final RoleSize size;
+   private final String username;
+   private final String password;
+   private final String sourceImageName;
+   private final URI mediaLink;
+   private final OSType os;
+   private final List<ExternalEndpoint> externalEndpoints;
 
    @Override
    public int hashCode() {
-      return Objects.hashCode(name);
+      return Objects.hashCode(sourceImageName, username, password, mediaLink, size, os, externalEndpoints);
    }
 
    @Override
-   public boolean equals(Object obj) {
-      if (this == obj) {
+   public boolean equals(Object object) {
+      if (this == object) {
          return true;
       }
-      if (obj == null) {
+      if (object instanceof DeploymentParams) {
+         DeploymentParams that = DeploymentParams.class.cast(object);
+         return equal(size, that.size)
+               && equal(username, that.username)
+               && equal(password, that.password)
+               && equal(sourceImageName, that.sourceImageName)
+               && equal(mediaLink, that.mediaLink)
+               && equal(os, that.os)
+               && equal(externalEndpoints, that.externalEndpoints);
+      } else {
          return false;
       }
-      if (getClass() != obj.getClass()) {
-         return false;
-      }
-      DeploymentParams other = (DeploymentParams) obj;
-      return Objects.equal(this.name, other.name);
    }
 
    @Override
    public String toString() {
-      return string().toString();
-   }
-
-   private ToStringHelper string() {
-      return Objects.toStringHelper(this).add("name", name).add("sourceImageName", sourceImageName)
-            .add("size", size);
+      return toStringHelper(this)
+            .add("size", size)
+            .add("username", username)
+            .add("password", password)
+            .add("sourceImageName", sourceImageName)
+            .add("mediaLink", mediaLink)
+            .add("os", os)
+            .add("externalEndpoints", externalEndpoints).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java
deleted file mode 100644
index a06c0f5..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-public class InputEndpoint {
-
-	public static Builder builder() {
-		return new Builder();
-	}
-
-	public static class Builder {
-		private Integer localPort;
-		private Integer externalPort;
-		private String name;
-		private Protocol protocol;
-
-		public Builder localPort(Integer localPort) {
-			this.localPort = localPort;
-			return this;
-		}
-
-		public Builder externalPort(Integer externalPort) {
-			this.externalPort = externalPort;
-			return this;
-		}
-
-		public Builder name(String name) {
-			this.name = name;
-			return this;
-		}
-
-		public Builder protocol(Protocol protocol) {
-			this.protocol = protocol;
-			return this;
-		}
-
-		public InputEndpoint build(){
-			return new InputEndpoint(localPort, externalPort, name, protocol);
-		}
-
-	}
-
-	private final Integer localPort;
-	private final Integer externalPort;
-	private final String name;
-	private final Protocol protocol;
-
-	public InputEndpoint(Integer localPort, Integer externalPort, String name,
-			Protocol protocol) {
-		super();
-		this.localPort = localPort;
-		this.externalPort = externalPort;
-		this.name = name;
-		this.protocol = protocol;
-	}
-
-	public Integer getLocalPort() {
-		return localPort;
-	}
-
-	public Integer getExternalPort() {
-		return externalPort;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public Protocol getProtocol() {
-		return protocol;
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((externalPort == null) ? 0 : externalPort.hashCode());
-		result = prime * result
-				+ ((localPort == null) ? 0 : localPort.hashCode());
-		result = prime * result + ((name == null) ? 0 : name.hashCode());
-		result = prime * result
-				+ ((protocol == null) ? 0 : protocol.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;
-		InputEndpoint other = (InputEndpoint) obj;
-		if (externalPort == null) {
-			if (other.externalPort != null)
-				return false;
-		} else if (!externalPort.equals(other.externalPort))
-			return false;
-		if (localPort == null) {
-			if (other.localPort != null)
-				return false;
-		} else if (!localPort.equals(other.localPort))
-			return false;
-		if (name == null) {
-			if (other.name != null)
-				return false;
-		} else if (!name.equals(other.name))
-			return false;
-		if (protocol != other.protocol)
-			return false;
-		return true;
-	}
-
-	@Override
-	public String toString() {
-		return "InputEndPoint [localPort=" + localPort + ", externalPort="
-				+ externalPort + ", name=" + name + ", protocol=" + protocol
-				+ "]";
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
deleted file mode 100644
index 2e3d245..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-public enum Protocol {
-   TCP,
-   HTTP,
-   UDP
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
index ada88ac..37dfd4e 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
@@ -25,14 +25,15 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-import org.jclouds.azurecompute.binders.BindDeploymentParamsToXmlPayload;
+import org.jclouds.azurecompute.binders.CreateDeploymentToXML;
 import org.jclouds.azurecompute.domain.Deployment;
 import org.jclouds.azurecompute.domain.DeploymentParams;
 import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
 import org.jclouds.azurecompute.xml.DeploymentHandler;
-import org.jclouds.rest.annotations.BinderParam;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
 import org.jclouds.rest.annotations.ResponseParser;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
@@ -57,13 +58,14 @@ public interface DeploymentApi {
    Deployment get(@PathParam("name") String name);
 
    /**
-    * http://msdn.microsoft.com/en-us/library/jj157194
+    * @param name the name for the deployment and its virtual machine. The name must be unique within Windows Azure.
     */
    @Named("CreateVirtualMachineDeployment")
    @POST
    @Produces(MediaType.APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   String create(@BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams);
+   @MapBinder(CreateDeploymentToXML.class)
+   String create(@PayloadParam("name") String name, @PayloadParam("params") DeploymentParams params);
 
    /**
     * The Delete Deployment operation deletes the specified deployment from Windows Azure.

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index d31e699..e665557 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -16,14 +16,17 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static org.jclouds.azurecompute.domain.DeploymentParams.ExternalEndpoint.inboundTcpToLocalPort;
+import static org.jclouds.azurecompute.domain.DeploymentParams.ExternalEndpoint.inboundUdpToLocalPort;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 
 import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.DeploymentHandlerTest;
+import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
 import org.testng.annotations.Test;
 
 import com.squareup.okhttp.mockwebserver.MockResponse;
@@ -32,19 +35,23 @@ import com.squareup.okhttp.mockwebserver.MockWebServer;
 @Test(groups = "unit", testName = "DeploymentApiMockTest")
 public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
 
-   public void create() throws Exception {
+   public void createLinux() throws Exception {
       MockWebServer server = mockAzureManagementServer();
       server.enqueue(requestIdResponse("request-1"));
 
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         DeploymentParams params = DeploymentParams.builder().osType(OSType.LINUX).name("mydeployment")
-               .username("username").password("testpwd").size(RoleSize.MEDIUM)
-               .sourceImageName("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd")
-               .storageAccount("portalvhds0g7xhnq2x7t21").build();
+         Image image = ListImagesHandlerTest.expected().get(5); // CentOS
 
-         assertEquals(api.create(params), "request-1");
+         DeploymentParams params = DeploymentParams.builder()
+               .size(RoleSize.MEDIUM)
+               .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+               .username("username").password("testpwd")
+               .externalEndpoint(inboundTcpToLocalPort(80, 8080))
+               .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
+
+         assertEquals(api.create("mydeployment", params), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices/myservice/deployments", "/deploymentparams.xml");
       } finally {
@@ -52,6 +59,30 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       }
    }
 
+   public void createWindows() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
+
+         Image image = ListImagesHandlerTest.expected().get(1); // Windows
+
+         DeploymentParams params = DeploymentParams.builder()
+               .size(RoleSize.MEDIUM)
+               .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+               .username("username").password("testpwd")
+               .externalEndpoint(inboundTcpToLocalPort(80, 8080))
+               .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
+
+         assertEquals(api.create("mydeployment", params), "request-1");
+
+         assertSent(server, "POST", "/services/hostedservices/myservice/deployments", "/deploymentparams-windows.xml");
+      } finally {
+         server.shutdown();
+      }
+   }
+
    public void getWhenFound() throws Exception {
       MockWebServer server = mockAzureManagementServer();
       server.enqueue(xmlResponse("/deployment.xml"));

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
index 1d288e4..ffd3de3 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
@@ -112,7 +112,7 @@ public class ListImagesHandlerTest extends BaseHandlerTest {
                   "This distribution of Linux is based on CentOS.", //description
                   "OpenLogic", // category
                   OSType.LINUX, // os
-                  null, // mediaLink
+                  URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"), // mediaLink
                   30, // logicalSizeInGB
                   Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
             ),

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/test/resources/deploymentparams-windows.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/deploymentparams-windows.xml b/azurecompute/src/test/resources/deploymentparams-windows.xml
new file mode 100644
index 0000000..a819115
--- /dev/null
+++ b/azurecompute/src/test/resources/deploymentparams-windows.xml
@@ -0,0 +1 @@
+<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType><ComputerName>mydeployment</ComputerName><AdminPassword>testpwd</AdminPassword><ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon><EnableAutomaticUpdate>false</EnableAutomaticUpdate><DomainJoin><Credentials><Domain>mydeployment</Domain><Username>username</Username><Password>testpwd</Password></Credentials><JoinDomain>mydeployment</JoinDomain></DomainJoin><StoredCertificateSettings/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints><InputEndpoint><LocalPort>8080</LocalPort><Name>tcp 80:8080</Name><Port>80</Port><Protocol>tcp</Protocol></InputEndpoint><InputE
 ndpoint><LocalPort>53</LocalPort><Name>udp 53:53</Name><Port>53</Port><Protocol>udp</Protocol></InputEndpoint></InputEndpoints><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardDisk><HostCaching>ReadWrite</HostCaching><MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink><SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName><OS>Windows</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/test/resources/deploymentparams.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/deploymentparams.xml b/azurecompute/src/test/resources/deploymentparams.xml
index fadaff1..415276f 100644
--- a/azurecompute/src/test/resources/deploymentparams.xml
+++ b/azurecompute/src/test/resources/deploymentparams.xml
@@ -1 +1 @@
-<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType><HostName>mydeployment</HostName><UserName>username</UserName><UserPassword>testpwd</UserPassword><DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication><SSH/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints/><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardDisk><HostCaching>ReadWrite</HostCaching><MediaLink>http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</MediaLink><SourceImageName>OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30
 GB.vhd</SourceImageName><OS>Linux</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
\ No newline at end of file
+<Deployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>mydeployment</Name><DeploymentSlot>Production</DeploymentSlot><Label>mydeployment</Label><RoleList><Role><RoleName>mydeployment</RoleName><RoleType>PersistentVMRole</RoleType><ConfigurationSets><ConfigurationSet><ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType><HostName>mydeployment</HostName><UserName>username</UserName><UserPassword>testpwd</UserPassword><DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication><SSH/></ConfigurationSet><ConfigurationSet><ConfigurationSetType>NetworkConfiguration</ConfigurationSetType><InputEndpoints><InputEndpoint><LocalPort>8080</LocalPort><Name>tcp 80:8080</Name><Port>80</Port><Protocol>tcp</Protocol></InputEndpoint><InputEndpoint><LocalPort>53</LocalPort><Name>udp 53:53</Name><Port>53</Port><Protocol>udp</Protocol></InputEndpoint></InputEndpoints><SubnetNames/></ConfigurationSet></ConfigurationSets><DataVirtualHardDisks/><OSVirtualHardD
 isk><HostCaching>ReadWrite</HostCaching><MediaLink>http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</MediaLink><SourceImageName>OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</SourceImageName><OS>Linux</OS></OSVirtualHardDisk><RoleSize>Medium</RoleSize></Role></RoleList></Deployment>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2cd19ba8/azurecompute/src/test/resources/images.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml
index deaeae5..8c01393 100644
--- a/azurecompute/src/test/resources/images.xml
+++ b/azurecompute/src/test/resources/images.xml
@@ -1,5 +1,4 @@
-<Images xmlns="http://schemas.microsoft.com/windowsazure"
-    >
+<Images xmlns="http://schemas.microsoft.com/windowsazure">
     <OSImage>
         <Category>Canonical</Category>
         <Label>Ubuntu Server 12.04 LTS</Label>
@@ -51,6 +50,7 @@
         <Label>OpenLogic CentOS 6.2</Label>
         <LogicalSizeInGB>30</LogicalSizeInGB>
         <Name>OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</Name>
+        <MediaLink>http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</MediaLink>
         <OS>Linux</OS>
         <Eula>http://www.openlogic.com/azure/service-agreement/</Eula>
         <Description>This distribution of Linux is based on CentOS.</Description>


[02/21] git commit: Removed unused JAXB annotations.

Posted by ad...@apache.org.
Removed unused JAXB annotations.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/af8e2c17
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/af8e2c17
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/af8e2c17

Branch: refs/heads/1.8.x
Commit: af8e2c1749f2bbe7ad56b13dc9da7f1dfd831779
Parents: 576c7bc
Author: Adrian Cole <ac...@twitter.com>
Authored: Thu Oct 16 19:01:17 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:34:29 2014 -0700

----------------------------------------------------------------------
 .../binders/BindDeploymentParamsToXmlPayload.java            | 2 +-
 .../main/java/org/jclouds/azurecompute/domain/Protocol.java  | 8 --------
 2 files changed, 1 insertion(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/af8e2c17/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
index 5c50740..1c127f1 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
@@ -79,7 +79,7 @@ public class BindDeploymentParamsToXmlPayload implements Binder {
             inputBuilder.e("LocalPort").t(endpoint.getLocalPort().toString()).up()
                .e("Name").t(endpoint.getName()).up()
                .e("Port").t(endpoint.getExternalPort().toString()).up()
-               .e("Protocol").t(endpoint.getProtocol().name()).up()
+               .e("Protocol").t(endpoint.getProtocol().name().toLowerCase()).up()
                .up(); //InputEndpoint
          }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/af8e2c17/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
index add7ee0..2e3d245 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java
@@ -16,16 +16,8 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlEnumValue;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlType(name = "Protocol") @XmlEnum
 public enum Protocol {
-   @XmlEnumValue("tcp")
    TCP,
-   @XmlEnumValue("http")
    HTTP,
-   @XmlEnumValue("udp")
    UDP
 }


[20/21] In latest Azure api, there are both OS images and Disk images.

Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
deleted file mode 100644
index f220f8c..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-public final class ListImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Image>> {
-   private boolean inOSImage;
-   private final ImageHandler imageHandler = new ImageHandler();
-   private final Builder<Image> images = ImmutableList.builder();
-
-   @Override
-   public List<Image> getResult() {
-      return images.build();
-   }
-
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) {
-      if (qName.equals("OSImage")) {
-         inOSImage = true;
-      }
-   }
-
-   @Override
-   public void endElement(String uri, String name, String qName) {
-      if (qName.equals("OSImage")) {
-         inOSImage = false;
-         images.add(imageHandler.getResult());
-      } else if (inOSImage) {
-         imageHandler.endElement(uri, name, qName);
-      }
-   }
-
-   @Override
-   public void characters(char ch[], int start, int length) {
-      if (inOSImage) {
-         imageHandler.characters(ch, start, length);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
new file mode 100644
index 0000000..a3b8819
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+public final class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<OSImage>> {
+   private boolean inOSImage;
+   private final OSImageHandler OSImageHandler = new OSImageHandler();
+   private final Builder<OSImage> images = ImmutableList.builder();
+
+   @Override
+   public List<OSImage> getResult() {
+      return images.build();
+   }
+
+   @Override
+   public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("OSImage")) {
+         inOSImage = true;
+      }
+   }
+
+   @Override
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("OSImage")) {
+         inOSImage = false;
+         images.add(OSImageHandler.getResult());
+      } else if (inOSImage) {
+         OSImageHandler.endElement(uri, name, qName);
+      }
+   }
+
+   @Override
+   public void characters(char ch[], int start, int length) {
+      if (inOSImage) {
+         OSImageHandler.characters(ch, start, length);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
new file mode 100644
index 0000000..c64b69f
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static com.google.common.base.Strings.emptyToNull;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
+ */
+final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<OSImage> {
+   private String name;
+   private final List<String> locations = Lists.newArrayList();
+   private String affinityGroup;
+   private String label;
+   private String category;
+   private String description;
+   private OSImage.Type os;
+   private URI mediaLink;
+   private Integer logicalSizeInGB;
+   private final List<String> eulas = Lists.newArrayList();
+
+   private final StringBuilder currentText = new StringBuilder();
+
+   @Override public OSImage getResult() {
+      OSImage result = OSImage
+            .create(name, ImmutableList.copyOf(locations), affinityGroup, label, description, category, os, mediaLink,
+                  logicalSizeInGB, ImmutableList.copyOf(eulas));
+      resetState(); // handler is called in a loop.
+      return result;
+   }
+
+   private void resetState() {
+      name = affinityGroup = label = description = category = null;
+      os = null;
+      mediaLink = null;
+      logicalSizeInGB = null;
+      eulas.clear();
+      locations.clear();
+   }
+
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("OS")) {
+         String osText = currentOrNull(currentText);
+         if (osText != null) {
+            os = OSImage.Type.valueOf(currentOrNull(currentText).toUpperCase());
+         }
+      } else if (qName.equals("Name")) {
+         name = currentOrNull(currentText);
+      } else if (qName.equals("LogicalSizeInGB")) {
+         String gb = currentOrNull(currentText);
+         if (gb != null) {
+            logicalSizeInGB = Integer.parseInt(gb);
+         }
+      } else if (qName.equals("Description")) {
+         description = currentOrNull(currentText);
+      } else if (qName.equals("Category")) {
+         category = currentOrNull(currentText);
+      } else if (qName.equals("Location")) {
+         String locationField = currentOrNull(currentText);
+         if (locationField != null) {
+            locations.addAll(Splitter.on(';').splitToList(locationField));
+         }
+      } else if (qName.equals("AffinityGroup")) {
+         affinityGroup = currentOrNull(currentText);
+      } else if (qName.equals("MediaLink")) {
+         String link = currentOrNull(currentText);
+         if (link != null) {
+            mediaLink = URI.create(link);
+         }
+      } else if (qName.equals("Eula")) {
+         String eulaField = currentOrNull(currentText);
+         if (eulaField != null) {
+            for (String eula : Splitter.on(';').split(eulaField)) {
+               if ((eula = emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eulas field.
+                  eulas.add(eula);
+               }
+            }
+         }
+      } else if (qName.equals("Label")) {
+         label = currentOrNull(currentText);
+      }
+      currentText.setLength(0);
+   }
+
+   @Override public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index e6662ac..a469df3 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 
 import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.DeploymentHandlerTest;
-import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
+import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest;
 import org.testng.annotations.Test;
 
 import com.squareup.okhttp.mockwebserver.MockResponse;
@@ -42,12 +42,12 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         Image image = ListImagesHandlerTest.expected().get(5); // CentOS
+         OSImage OSImage = ListOSImagesHandlerTest.expected().get(5); // CentOS
 
          DeploymentParams params = DeploymentParams.builder()
                .name("mydeployment")
                .size(RoleSize.MEDIUM)
-               .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+               .sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
                .username("username").password("testpwd")
                .externalEndpoint(inboundTcpToLocalPort(80, 8080))
                .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
@@ -67,12 +67,12 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         Image image = ListImagesHandlerTest.expected().get(1); // Windows
+         OSImage OSImage = ListOSImagesHandlerTest.expected().get(1); // Windows
 
          DeploymentParams params = DeploymentParams.builder()
                .name("mydeployment")
                .size(RoleSize.MEDIUM)
-               .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+               .sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
                .username("username").password("testpwd")
                .externalEndpoint(inboundTcpToLocalPort(80, 8080))
                .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index 0f54641..2f9499e 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -21,8 +21,8 @@ import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 import org.jclouds.azurecompute.domain.Disk;
-import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -46,8 +46,8 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
                      return in.name();
                   }
                }));
-      images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function<Image, String>() {
-         public String apply(Image in) {
+      images = ImmutableSet.copyOf(transform(api.getOSImageApi().list(), new Function<OSImage, String>() {
+         public String apply(OSImage in) {
             return in.name();
          }
       }));

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
deleted file mode 100644
index c4b36e4..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.features;
-
-import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Location;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "live", testName = "ImageApiLiveTest")
-public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
-
-   private ImmutableSet<String> locations;
-
-   @BeforeClass(groups = { "integration", "live" })
-   public void setup() {
-      super.setup();
-
-      locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
-         public String apply(Location in) {
-            return in.name();
-         }
-      }));
-   }
-
-   public void testList() {
-      for (Image image : api().list()) {
-         checkOSImage(image);
-      }
-   }
-
-   private void checkOSImage(Image image) {
-      assertNotNull(image.label(), "Label cannot be null for " + image);
-      assertNotNull(image.name(), "Name cannot be null for " + image);
-      assertNotNull(image.os(), "OS cannot be null for " + image);
-      assertTrue(image.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + image);
-
-      if (image.category() != null) {
-         assertNotEquals("", image.category().trim(), "Invalid Category for " + image);
-      }
-
-      if (image.mediaLink() != null) {
-         assertTrue(ImmutableSet.of("http", "https").contains(image.mediaLink().getScheme()),
-               "MediaLink should be an http(s) url" + image);
-      }
-      if (image.location() != null) {
-         assertTrue(locations.contains(image.location()), "Location not in " + locations + " :" + image);
-      }
-
-      // Ex. Dirty data in RightScale eula field comes out as an empty string.
-      assertFalse(image.eula().contains(""));
-      if (image.affinityGroup() != null) {
-         // TODO: list getAffinityGroups and check if there
-      }
-   }
-
-   private ImageApi api() {
-      return api.getImageApi();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
deleted file mode 100644
index 4e05102..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-@Test(groups = "unit", testName = "ImageApiMockTest")
-public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
-
-   public void listWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(xmlResponse("/images.xml"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertEquals(api.list(), ListImagesHandlerTest.expected());
-
-         assertSent(server, "GET", "/services/images");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void listWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertTrue(api.list().isEmpty());
-
-         assertSent(server, "GET", "/services/images");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void add() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
-               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
-
-         assertEquals(api.add(params), "request-1");
-
-         assertSent(server, "POST", "/services/images", "/imageparams.xml");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void update() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
-               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
-
-         assertEquals(api.update(params), "request-1");
-
-         assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void deleteWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertEquals(api.delete("myimage"), "request-1");
-
-         assertSent(server, "DELETE", "/services/images/myimage");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void deleteWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertNull(api.delete("myimage"));
-
-         assertSent(server, "DELETE", "/services/images/myimage");
-      } finally {
-         server.shutdown();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
index b476ed1..9360cb0 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
@@ -16,13 +16,14 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.ListLocationsHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "LocationApiMockTest")
 public class LocationApiMockTest extends BaseAzureComputeApiMockTest {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
new file mode 100644
index 0000000..785a5a1
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.features;
+
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "live", testName = "OSImageApiLiveTest")
+public class OSImageApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+   private ImmutableSet<String> locations;
+
+   @BeforeClass(groups = { "integration", "live" })
+   public void setup() {
+      super.setup();
+
+      locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
+         public String apply(Location in) {
+            return in.name();
+         }
+      }));
+   }
+
+   public void testList() {
+      for (OSImage OSImage : api().list()) {
+         checkOSImage(OSImage);
+      }
+   }
+
+   private void checkOSImage(OSImage OSImage) {
+      assertNotNull(OSImage.label(), "Label cannot be null for " + OSImage);
+      assertNotNull(OSImage.name(), "Name cannot be null for " + OSImage);
+      assertNotNull(OSImage.os(), "OS cannot be null for " + OSImage);
+      assertTrue(OSImage.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + OSImage);
+
+      if (OSImage.category() != null) {
+         assertNotEquals("", OSImage.category().trim(), "Invalid Category for " + OSImage);
+      }
+
+      if (OSImage.mediaLink() != null) {
+         assertTrue(ImmutableSet.of("http", "https").contains(OSImage.mediaLink().getScheme()),
+               "MediaLink should be an http(s) url" + OSImage);
+      }
+
+      assertTrue(locations.containsAll(OSImage.locations()), "Locations not in " + locations + " :" + OSImage);
+
+      // Ex. Dirty data in RightScale eula field comes out as an empty string.
+      assertFalse(OSImage.eula().contains(""));
+      if (OSImage.affinityGroup() != null) {
+         // TODO: list getAffinityGroups and check if there
+      }
+   }
+
+   private OSImageApi api() {
+      return api.getOSImageApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
new file mode 100644
index 0000000..70c5ec6
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
+import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+@Test(groups = "unit", testName = "OSImageApiMockTest")
+public class OSImageApiMockTest extends BaseAzureComputeApiMockTest {
+
+   public void listWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(xmlResponse("/images.xml"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertEquals(api.list(), ListOSImagesHandlerTest.expected());
+
+         assertSent(server, "GET", "/services/images");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void listWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertTrue(api.list().isEmpty());
+
+         assertSent(server, "GET", "/services/images");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void add() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX)
+               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
+
+         assertEquals(api.add(params), "request-1");
+
+         assertSent(server, "POST", "/services/images", "/imageparams.xml");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void update() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX)
+               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
+
+         assertEquals(api.update(params), "request-1");
+
+         assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void deleteWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertEquals(api.delete("myimage"), "request-1");
+
+         assertSent(server, "DELETE", "/services/images/myimage");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void deleteWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertNull(api.delete("myimage"));
+
+         assertSent(server, "DELETE", "/services/images/myimage");
+      } finally {
+         server.shutdown();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
index 7e3ce5a..41cce90 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
@@ -16,13 +16,14 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
-@Test(groups = "unit", testName = "ApiMockTest")
+@Test(groups = "unit", testName = "VirtualMachineApiMockTest")
 public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
 
    public void start() throws Exception {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
index 5e3fea4..a05d421 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
@@ -16,12 +16,13 @@
  */
 package org.jclouds.azurecompute.internal;
 
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
 import java.util.Properties;
+
 import org.jclouds.apis.BaseApiLiveTest;
 import org.jclouds.azurecompute.AzureComputeApi;
 
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
-
 public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi> {
 
    protected String subscriptionId;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
index c01d8f8..d846a44 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
@@ -16,23 +16,25 @@
  */
 package org.jclouds.azurecompute.internal;
 
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import java.io.IOException;
 import java.net.URL;
 import java.util.Set;
+
 import org.jclouds.ContextBuilder;
 import org.jclouds.azurecompute.AzureComputeApi;
 import org.jclouds.concurrent.config.ExecutorServiceModule;
 import org.jclouds.util.Strings2;
 
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import com.squareup.okhttp.mockwebserver.RecordedRequest;
 
 public class BaseAzureComputeApiMockTest {
    private final Set<Module> modules = ImmutableSet
@@ -81,7 +83,7 @@ public class BaseAzureComputeApiMockTest {
       RecordedRequest request = server.takeRequest();
       assertThat(request.getMethod()).isEqualTo(method);
       assertThat(request.getPath()).isEqualTo(path);
-      assertThat(request.getHeader("x-ms-version")).isEqualTo("2012-03-01");
+      assertThat(request.getHeader("x-ms-version")).isEqualTo("2014-06-01");
       assertThat(request.getHeader("Accept")).isEqualTo("application/xml");
       return request;
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
index 320c405..491653b 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
@@ -24,7 +24,7 @@ import java.util.List;
 
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.http.functions.BaseHandlerTest;
 import org.testng.annotations.Test;
 
@@ -47,7 +47,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
                   "West Europe", // location
                   null, // affinityGroup
                   null, //description
-                  OSType.LINUX, // os
+                  OSImage.Type.LINUX, // os
                   URI.create("http://blobs/vhds/testimage2-testimage2-2012-08-17.vhd"), // mediaLink
                   30, // logicalSizeInGB
                   null, // attachedTo
@@ -57,7 +57,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
                   "West Europe", // location
                   null, // affinityGroup
                   null, //description
-                  OSType.WINDOWS, // os
+                  OSImage.Type.WINDOWS, // os
                   URI.create("http://blobs/disks/neotysss/MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd"), // mediaLink
                   30, // logicalSizeInGB
                   Attachment.create("neotysss", "neotysss", "neotysss"), // attachedTo

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
deleted file mode 100644
index ffd3de3..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "ListImagesHandlerTest")
-public class ListImagesHandlerTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/images.xml");
-      List<Image> result = factory.create(new ListImagesHandler()).parse(is);
-
-      assertEquals(result, expected());
-   }
-
-   public static List<Image> expected() {
-      return ImmutableList.of( //
-            Image.create( //
-                  "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Ubuntu Server 12.04 LTS", // label
-                  "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
-                  "Canonical", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
-            ),
-            Image.create( //
-                  "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Windows Server 2008 R2 SP1, June 2012", // label
-                  "Windows Server 2008 R2 is a multi-purpose server.", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"), // mediaLink
-                  30, // logicalSizeInGB
-                  Collections.<String>emptyList() // eula
-            ),
-            Image.create( //
-                  "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Microsoft SQL Server 2012 Evaluation Edition", // label
-                  "SQL Server 2012 Evaluation Edition (64-bit).", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
-                                "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
-            ),
-            Image.create( //
-                  "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Windows Server 2012 Release Candidate, July 2012", // label
-                  "Windows Server 2012 incorporates Microsoft's experience building.", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Collections.<String>emptyList() // eula
-            ),
-            Image.create( //
-                  "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Windows Server 2008 R2 SP1, July 2012", // label
-                  "Windows Server 2008 R2 is a multi-purpose server.", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Collections.<String>emptyList() // eula
-            ),
-            Image.create( //
-                  "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "OpenLogic CentOS 6.2", // label
-                  "This distribution of Linux is based on CentOS.", //description
-                  "OpenLogic", // category
-                  OSType.LINUX, // os
-                  URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"), // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
-            ),
-            Image.create( //
-                  "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "openSUSE 12.1", // label
-                  "openSUSE is a free and Linux-based operating system!", //description
-                  "SUSE", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://opensuse.org/") // eula
-            ),
-            Image.create( //
-                  "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "SUSE Linux Enterprise Server", // label
-                  "SUSE Linux Enterprise Server is a highly reliable value.", //description
-                  "SUSE", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://www.novell.com/licensing/eula/") // eula
-            ),
-            Image.create( //
-                  "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
-                  null, // location
-                  null, // affinityGroup
-                  "RightImage-CentOS-6.4-x64-v13.4", // label
-                  null, //description
-                  "RightScale with Linux", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  10, // logicalSizeInGB
-                  Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
-            )
-      );
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
new file mode 100644
index 0000000..3809440
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListImagesHandlerTest")
+public class ListOSImagesHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/images.xml");
+      List<OSImage> result = factory.create(new ListOSImagesHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<OSImage> expected() {
+      return ImmutableList.of( //
+            OSImage.create( //
+                  "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Ubuntu Server 12.04 LTS", // label
+                  "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
+                  "Canonical", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
+                  Arrays.asList("East Asia", "Southeast Asia", "North Europe"), // locations
+                  null, // affinityGroup
+                  "Windows Server 2008 R2 SP1, June 2012", // label
+                  "Windows Server 2008 R2 is a multi-purpose server.", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"),
+                  // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Microsoft SQL Server 2012 Evaluation Edition", // label
+                  "SQL Server 2012 Evaluation Edition (64-bit).", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
+                        "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Windows Server 2012 Release Candidate, July 2012", // label
+                  "Windows Server 2012 incorporates Microsoft's experience building.", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Windows Server 2008 R2 SP1, July 2012", // label
+                  "Windows Server 2008 R2 is a multi-purpose server.", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            OSImage.create( //
+                  "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "OpenLogic CentOS 6.2", // label
+                  "This distribution of Linux is based on CentOS.", //description
+                  "OpenLogic", // category
+                  OSImage.Type.LINUX, // os
+                  URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"),
+                  // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
+            ),
+            OSImage.create( //
+                  "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "openSUSE 12.1", // label
+                  "openSUSE is a free and Linux-based operating system!", //description
+                  "SUSE", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://opensuse.org/") // eula
+            ),
+            OSImage.create( //
+                  "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "SUSE Linux Enterprise Server", // label
+                  "SUSE Linux Enterprise Server is a highly reliable value.", //description
+                  "SUSE", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.novell.com/licensing/eula/") // eula
+            ),
+            OSImage.create( //
+                  "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "RightImage-CentOS-6.4-x64-v13.4", // label
+                  null, //description
+                  "RightScale with Linux", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  10, // logicalSizeInGB
+                  Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
+            )
+      );
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/capturerolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/capturerolepayload.xml b/azurecompute/src/test/resources/capturerolepayload.xml
index 9414c52..36396ff 100644
--- a/azurecompute/src/test/resources/capturerolepayload.xml
+++ b/azurecompute/src/test/resources/capturerolepayload.xml
@@ -1 +1 @@
-<CaptureRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>myImageLabel</TargetImageLabel><TargetImageName>myImageName</TargetImageName></CaptureRoleOperation>
\ No newline at end of file
+<CaptureRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>myImageLabel</TargetImageLabel><TargetImageName>myImageName</TargetImageName></CaptureRoleOperation>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/images.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml
index 8c01393..e72370e 100644
--- a/azurecompute/src/test/resources/images.xml
+++ b/azurecompute/src/test/resources/images.xml
@@ -11,6 +11,7 @@
     <OSImage>
         <Category>Microsoft</Category>
         <Label>Windows Server 2008 R2 SP1, June 2012</Label>
+        <Location>East Asia;Southeast Asia;North Europe</Location>
         <LogicalSizeInGB>30</LogicalSizeInGB>
         <Name>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</Name>
         <MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink>

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/restartrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/restartrolepayload.xml b/azurecompute/src/test/resources/restartrolepayload.xml
index 4eca508..54ccf84 100644
--- a/azurecompute/src/test/resources/restartrolepayload.xml
+++ b/azurecompute/src/test/resources/restartrolepayload.xml
@@ -1 +1 @@
-<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>
\ No newline at end of file
+<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/shutdownrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/shutdownrolepayload.xml b/azurecompute/src/test/resources/shutdownrolepayload.xml
index 27beee8..5048ca3 100644
--- a/azurecompute/src/test/resources/shutdownrolepayload.xml
+++ b/azurecompute/src/test/resources/shutdownrolepayload.xml
@@ -1 +1 @@
-<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>
\ No newline at end of file
+<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/startrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/startrolepayload.xml b/azurecompute/src/test/resources/startrolepayload.xml
index 4e82022..6b6d7a3 100644
--- a/azurecompute/src/test/resources/startrolepayload.xml
+++ b/azurecompute/src/test/resources/startrolepayload.xml
@@ -1 +1 @@
-<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
\ No newline at end of file
+<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
\ No newline at end of file


[21/21] git commit: In latest Azure api, there are both OS images and Disk images.

Posted by ad...@apache.org.
In latest Azure api, there are both OS images and Disk images.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/d1a637f1
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/d1a637f1
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/d1a637f1

Branch: refs/heads/1.8.x
Commit: d1a637f1986ba4936799d5d276f5441664caa6e9
Parents: ae506a6
Author: Adrian Cole <ac...@twitter.com>
Authored: Wed Oct 22 21:03:10 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:08:14 2014 -0700

----------------------------------------------------------------------
 .../jclouds/azurecompute/AzureComputeApi.java   |   5 +-
 .../AzureComputeProviderMetadata.java           |   5 +-
 .../AzureManagementApiMetadata.java             |   8 +-
 .../binders/DeploymentParamsToXML.java          |   8 +-
 .../azurecompute/binders/ImageParamsToXML.java  |  43 -----
 .../binders/OSImageParamsToXML.java             |  43 +++++
 .../compute/AzureComputeServiceAdapter.java     |   9 +-
 .../AzureComputeServiceContextModule.java       |  17 +-
 .../compute/functions/AzureImageToImage.java    |  29 ---
 .../functions/DeploymentToNodeMetadata.java     |   3 +-
 .../compute/functions/OSImageToImage.java       |  30 +++
 .../compute/functions/RoleSizeToHardware.java   |   3 +-
 .../config/AzureComputeHttpApiModule.java       |   7 +-
 .../azurecompute/domain/DeploymentParams.java   |  20 +-
 .../org/jclouds/azurecompute/domain/Disk.java   |   9 +-
 .../org/jclouds/azurecompute/domain/Image.java  | 183 -------------------
 .../azurecompute/domain/ImageParams.java        | 142 --------------
 .../jclouds/azurecompute/domain/OSImage.java    | 176 ++++++++++++++++++
 .../azurecompute/domain/OSImageParams.java      | 140 ++++++++++++++
 .../jclouds/azurecompute/features/DiskApi.java  |   8 +-
 .../jclouds/azurecompute/features/ImageApi.java | 101 ----------
 .../azurecompute/features/LocationApi.java      |   6 +-
 .../azurecompute/features/OSImageApi.java       | 101 ++++++++++
 .../azurecompute/features/OperationApi.java     |   5 +-
 .../features/VirtualMachineApi.java             |   9 +-
 .../azurecompute/functions/ImageParamsName.java |  27 ---
 .../functions/OSImageParamsName.java            |  27 +++
 .../functions/ParseRequestIdHeader.java         |   6 +-
 .../suppliers/KeyStoreSupplier.java             |  13 +-
 .../suppliers/SSLContextWithKeysSupplier.java   |   9 +-
 .../jclouds/azurecompute/xml/DiskHandler.java   |   6 +-
 .../jclouds/azurecompute/xml/ImageHandler.java  | 109 -----------
 .../azurecompute/xml/ListImagesHandler.java     |  61 -------
 .../azurecompute/xml/ListOSImagesHandler.java   |  61 +++++++
 .../azurecompute/xml/OSImageHandler.java        | 113 ++++++++++++
 .../features/DeploymentApiMockTest.java         |  12 +-
 .../azurecompute/features/DiskApiLiveTest.java  |   6 +-
 .../azurecompute/features/ImageApiLiveTest.java |  84 ---------
 .../azurecompute/features/ImageApiMockTest.java | 132 -------------
 .../features/LocationApiMockTest.java           |   7 +-
 .../features/OSImageApiLiveTest.java            |  83 +++++++++
 .../features/OSImageApiMockTest.java            | 132 +++++++++++++
 .../features/VirtualMachineApiMockTest.java     |   7 +-
 .../internal/BaseAzureComputeApiLiveTest.java   |   5 +-
 .../internal/BaseAzureComputeApiMockTest.java   |  22 ++-
 .../azurecompute/xml/ListDisksHandlerTest.java  |   6 +-
 .../azurecompute/xml/ListImagesHandlerTest.java | 157 ----------------
 .../xml/ListOSImagesHandlerTest.java            | 158 ++++++++++++++++
 .../src/test/resources/capturerolepayload.xml   |   2 +-
 azurecompute/src/test/resources/images.xml      |   1 +
 .../src/test/resources/restartrolepayload.xml   |   2 +-
 .../src/test/resources/shutdownrolepayload.xml  |   2 +-
 .../src/test/resources/startrolepayload.xml     |   2 +-
 53 files changed, 1193 insertions(+), 1169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
index ec037a3..5946838 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
@@ -17,13 +17,14 @@
 package org.jclouds.azurecompute;
 
 import java.io.Closeable;
+
 import javax.ws.rs.PathParam;
 
 import org.jclouds.azurecompute.features.CloudServiceApi;
 import org.jclouds.azurecompute.features.DeploymentApi;
 import org.jclouds.azurecompute.features.DiskApi;
-import org.jclouds.azurecompute.features.ImageApi;
 import org.jclouds.azurecompute.features.LocationApi;
+import org.jclouds.azurecompute.features.OSImageApi;
 import org.jclouds.azurecompute.features.OperationApi;
 import org.jclouds.azurecompute.features.VirtualMachineApi;
 import org.jclouds.rest.annotations.Delegate;
@@ -81,7 +82,7 @@ public interface AzureComputeApi extends Closeable {
     * @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
     */
    @Delegate
-   ImageApi getImageApi();
+   OSImageApi getOSImageApi();
 
    /**
     * The Service Management API includes operations for Tracking Asynchronous Service Management

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
index 8fcb560..9c811ce 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
@@ -16,13 +16,14 @@
  */
 package org.jclouds.azurecompute;
 
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
 import java.net.URI;
 import java.util.Properties;
+
 import org.jclouds.providers.ProviderMetadata;
 import org.jclouds.providers.internal.BaseProviderMetadata;
 
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
-
 /**
  * Implementation of {@link ProviderMetadata} for Microsoft Azure Service Management Service.
  */

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
index 762261c..0caad94 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
@@ -16,16 +16,18 @@
  */
 package org.jclouds.azurecompute;
 
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
 import java.net.URI;
 import java.util.Properties;
+
 import org.jclouds.apis.ApiMetadata;
 import org.jclouds.azurecompute.compute.config.AzureComputeServiceContextModule;
 import org.jclouds.azurecompute.config.AzureComputeHttpApiModule;
 import org.jclouds.rest.internal.BaseHttpApiMetadata;
 
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
 
 /**
  * Implementation of {@link ApiMetadata} for Microsoft Service Management Service API

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
index c493c90..26301d6 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
@@ -19,10 +19,10 @@ package org.jclouds.azurecompute.binders;
 import static com.google.common.base.CaseFormat.UPPER_CAMEL;
 import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
 import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
+import static org.jclouds.azurecompute.domain.OSImage.Type.LINUX;
 
 import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.rest.Binder;
 
@@ -44,7 +44,7 @@ public final class DeploymentParamsToXML implements Binder {
             .e("RoleType").t("PersistentVMRole").up()
             .e("ConfigurationSets");
 
-         if (params.os() == OSType.WINDOWS) {
+         if (params.os() == OSImage.Type.WINDOWS) {
             XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
             configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
                .e("ComputerName").t(params.name()).up()
@@ -61,7 +61,7 @@ public final class DeploymentParamsToXML implements Binder {
                .up() // Domain Join
                .e("StoredCertificateSettings").up()
                .up(); // Windows ConfigurationSet
-         } else if (params.os() == OSType.LINUX) {
+         } else if (params.os() == OSImage.Type.LINUX) {
             XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
             configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
                .e("HostName").t(params.name()).up()

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
deleted file mode 100644
index 040184b..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.binders;
-
-import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
-
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-import com.jamesmurty.utils.XMLBuilder;
-
-public final class ImageParamsToXML implements Binder {
-   @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
-      ImageParams params = ImageParams.class.cast(input);
-      try {
-         String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
-                                .e("Label").t(params.label()).up()
-                                .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
-                                .e("Name").t(params.name()).up()
-                                .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
-                                .up().asString();
-         return (R) request.toBuilder().payload(xml).build();
-      } catch (Exception e) {
-         throw propagate(e);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java
new file mode 100644
index 0000000..3d87c8f
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.binders;
+
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.azurecompute.domain.OSImage.Type.LINUX;
+
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.jamesmurty.utils.XMLBuilder;
+
+public final class OSImageParamsToXML implements Binder {
+   @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+      OSImageParams params = OSImageParams.class.cast(input);
+      try {
+         String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
+                                .e("Label").t(params.label()).up()
+                                .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
+                                .e("Name").t(params.name()).up()
+                                .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
+                                .up().asString();
+         return (R) request.toBuilder().payload(xml).build();
+      } catch (Exception e) {
+         throw propagate(e);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
index 4ce0ee4..9663a75 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
@@ -17,9 +17,10 @@
 package org.jclouds.azurecompute.compute;
 
 import javax.inject.Singleton;
+
 import org.jclouds.azurecompute.AzureComputeApi;
 import org.jclouds.azurecompute.domain.Deployment;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.compute.ComputeServiceAdapter;
 import org.jclouds.compute.domain.Template;
@@ -29,7 +30,7 @@ import org.jclouds.compute.domain.Template;
  * jclouds {@link org.jclouds.compute.ComputeService}
  */
 @Singleton
-public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Deployment, RoleSize, Image, String> {
+public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Deployment, RoleSize, OSImage, String> {
 
    @Override
    public NodeAndInitialCredentials<Deployment> createNodeWithGroupEncodedIntoName(
@@ -45,13 +46,13 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Deploym
    }
 
    @Override
-   public Iterable<Image> listImages() {
+   public Iterable<OSImage> listImages() {
       // TODO Auto-generated method stub
       return null;
    }
 
    @Override
-   public Image getImage(String id) {
+   public OSImage getImage(String id) {
       // TODO Auto-generated method stub
       return null;
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
index 2edd8a0..b09b867 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
@@ -16,30 +16,31 @@
  */
 package org.jclouds.azurecompute.compute.config;
 
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
 import org.jclouds.azurecompute.compute.AzureComputeServiceAdapter;
-import org.jclouds.azurecompute.compute.functions.AzureImageToImage;
 import org.jclouds.azurecompute.compute.functions.DeploymentToNodeMetadata;
+import org.jclouds.azurecompute.compute.functions.OSImageToImage;
 import org.jclouds.azurecompute.compute.functions.RoleSizeToHardware;
 import org.jclouds.azurecompute.domain.Deployment;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.compute.ComputeServiceAdapter;
 import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
 import org.jclouds.compute.domain.Hardware;
 import org.jclouds.compute.domain.NodeMetadata;
 
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
 public class AzureComputeServiceContextModule
-      extends ComputeServiceAdapterContextModule<Deployment, RoleSize, Image, String> {
+      extends ComputeServiceAdapterContextModule<Deployment, RoleSize, OSImage, String> {
 
    @Override
    protected void configure() {
       super.configure();
-      bind(new TypeLiteral<ComputeServiceAdapter<Deployment, RoleSize, Image, String>>() {
+      bind(new TypeLiteral<ComputeServiceAdapter<Deployment, RoleSize, OSImage, String>>() {
       }).to(AzureComputeServiceAdapter.class);
-      bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
-      }).to(AzureImageToImage.class);
+      bind(new TypeLiteral<Function<OSImage, org.jclouds.compute.domain.Image>>() {
+      }).to(OSImageToImage.class);
       bind(new TypeLiteral<Function<RoleSize, Hardware>>() {
       }).to(RoleSizeToHardware.class);
       bind(new TypeLiteral<Function<Deployment, NodeMetadata>>() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java
deleted file mode 100644
index 4da1c34..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.compute.functions;
-
-import com.google.common.base.Function;
-import org.jclouds.azurecompute.domain.Image;
-
-public class AzureImageToImage implements Function<Image, org.jclouds.compute.domain.Image> {
-
-   @Override
-   public org.jclouds.compute.domain.Image apply(Image input) {
-      return null;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
index 7e02ee6..127ea02 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
@@ -16,10 +16,11 @@
  */
 package org.jclouds.azurecompute.compute.functions;
 
-import com.google.common.base.Function;
 import org.jclouds.azurecompute.domain.Deployment;
 import org.jclouds.compute.domain.NodeMetadata;
 
+import com.google.common.base.Function;
+
 public class DeploymentToNodeMetadata implements Function<Deployment, NodeMetadata> {
 
 	@Override

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java
new file mode 100644
index 0000000..9cd1e70
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.compute.functions;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.compute.domain.Image;
+
+import com.google.common.base.Function;
+
+public class OSImageToImage implements Function<OSImage, Image> {
+
+   @Override
+   public Image apply(OSImage input) {
+      return null;
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
index 09dbf78..97a9b2c 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
@@ -16,10 +16,11 @@
  */
 package org.jclouds.azurecompute.compute.functions;
 
-import com.google.common.base.Function;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.compute.domain.Hardware;
 
+import com.google.common.base.Function;
+
 public class RoleSizeToHardware implements Function<RoleSize, Hardware> {
 
 	@Override

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
index 8c85c0a..2d07471 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
@@ -16,16 +16,19 @@
  */
 package org.jclouds.azurecompute.config;
 
-import com.google.common.base.Supplier;
-import com.google.inject.TypeLiteral;
 import java.security.KeyStore;
+
 import javax.net.ssl.SSLContext;
+
 import org.jclouds.azurecompute.AzureComputeApi;
 import org.jclouds.azurecompute.suppliers.KeyStoreSupplier;
 import org.jclouds.azurecompute.suppliers.SSLContextWithKeysSupplier;
 import org.jclouds.rest.ConfiguresHttpApi;
 import org.jclouds.rest.config.HttpApiModule;
 
+import com.google.common.base.Supplier;
+import com.google.inject.TypeLiteral;
+
 @ConfiguresHttpApi
 public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> {
    @Override

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index ac06305..e75fa19 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -24,8 +24,6 @@ import java.net.URI;
 import java.util.Collection;
 import java.util.List;
 
-import org.jclouds.azurecompute.domain.Image.OSType;
-
 import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
@@ -134,18 +132,18 @@ public final class DeploymentParams {
       return password;
    }
 
-   /** {@link Image#name() name} of the user or platform image. */
+   /** {@link OSImage#name() name} of the user or platform image. */
    public String sourceImageName() {
       return sourceImageName;
    }
 
-   /** Indicates the {@link Image#mediaLink() location} when {@link #sourceImageName() source} is a platform image. */
+   /** Indicates the {@link OSImage#mediaLink() location} when {@link #sourceImageName() source} is a platform image. */
    public URI mediaLink() {
       return mediaLink;
    }
 
-   /** {@link Image#os() Os type} of the {@link #sourceImageName() source image}. */
-   public OSType os() {
+   /** {@link OSImage#os() Os type} of the {@link #sourceImageName() source image}. */
+   public OSImage.Type os() {
       return os;
    }
 
@@ -168,7 +166,7 @@ public final class DeploymentParams {
       private String password;
       private String sourceImageName;
       private URI mediaLink;
-      private OSType os;
+      private OSImage.Type os;
       private List<ExternalEndpoint> externalEndpoints = Lists.newArrayList();
 
       public Builder name(String name) {
@@ -201,7 +199,7 @@ public final class DeploymentParams {
          return this;
       }
 
-      public Builder os(OSType os) {
+      public Builder os(OSImage.Type os) {
          this.os = os;
          return this;
       }
@@ -234,13 +232,13 @@ public final class DeploymentParams {
    }
 
    private static DeploymentParams create(String name, RoleSize size, String username, String password, String sourceImageName,
-         URI mediaLink, OSType os, List<ExternalEndpoint> externalEndpoints) {
+         URI mediaLink, OSImage.Type os, List<ExternalEndpoint> externalEndpoints) {
       return new DeploymentParams(name, size, username, password, sourceImageName, mediaLink, os, externalEndpoints);
    }
 
    // TODO: Remove from here down with @AutoValue.
    private DeploymentParams(String name, RoleSize size, String username, String password, String sourceImageName, URI mediaLink,
-         OSType os, List<ExternalEndpoint> externalEndpoints) {
+         OSImage.Type os, List<ExternalEndpoint> externalEndpoints) {
       this.name = checkNotNull(name, "name");
       this.size = checkNotNull(size, "size");
       this.username = checkNotNull(username, "username");
@@ -257,7 +255,7 @@ public final class DeploymentParams {
    private final String password;
    private final String sourceImageName;
    private final URI mediaLink;
-   private final OSType os;
+   private final OSImage.Type os;
    private final List<ExternalEndpoint> externalEndpoints;
 
    @Override public int hashCode() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
index 07ebf56..888e9af 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
@@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.net.URI;
 
-import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.javax.annotation.Nullable;
 
 import com.google.common.base.Objects;
@@ -126,7 +125,7 @@ public final class Disk {
    }
 
    /** The operating system type of the OS image, or null if a data disk. */
-   @Nullable public OSType os() {
+   @Nullable public OSImage.Type os() {
       return os;
    }
 
@@ -165,13 +164,13 @@ public final class Disk {
    }
 
    public static Disk create(String name, String location, String affinityGroup, String description,
-         OSType os, URI mediaLink, Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
+         OSImage.Type os, URI mediaLink, Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
       return new Disk(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB, attachedTo,
             sourceImage);
    }
 
    // TODO: Remove from here down with @AutoValue.
-   private Disk(String name, String location, String affinityGroup, String description, OSType os, URI mediaLink,
+   private Disk(String name, String location, String affinityGroup, String description, OSImage.Type os, URI mediaLink,
          Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
       this.name = checkNotNull(name, "name");
       this.location = location;
@@ -188,7 +187,7 @@ public final class Disk {
    private final String location;
    private final String affinityGroup;
    private final String description;
-   private final OSType os;
+   private final OSImage.Type os;
    private final URI mediaLink;
    private final Integer logicalSizeInGB;
    private final Attachment attachedTo;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
deleted file mode 100644
index d533c41..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-
-/**
- * OS image from the image repository
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
- */
-public final class Image {
-   public enum OSType {
-      LINUX, WINDOWS;
-   }
-
-   public String name() {
-      return name;
-   }
-
-   /**
-    * The geo-location of the image in Windows Azure, if the image is not
-    * associated with an affinity group. If a location has been specified, the AffinityGroup element
-    * is not returned.
-    */
-   @Nullable public String location() {
-      return location;
-   }
-
-   /**
-    * The affinity group with which this image is associated, if any. If the service is
-    * associated with an affinity group, the Location element is not returned.
-    */
-   @Nullable public String affinityGroup() {
-      return affinityGroup;
-   }
-
-   /**
-    * The name can be up to 100 characters in length. The name can be used identify the storage account for your
-    * tracking purposes.
-    */
-   public String label() {
-      return label;
-   }
-
-   @Nullable public String description() {
-      return description;
-   }
-
-   /**
-    * The repository classification of image. All user images have the category "User", but
-    * categories for other images could be, for example "Canonical"
-    */
-   @Nullable public String category() {
-      return category;
-   }
-
-   /** The operating system type of the OS image. */
-   public OSType os() {
-      return os;
-   }
-
-   /**
-    * The location of the blob in the blob store in which the media for the image is located. The
-    * blob location belongs to a storage account in the subscription specified by the
-    * <subscription-id> value in the operation call.
-    *
-    * Example:
-    *
-    * http://example.blob.core.windows.net/disks/myimage.vhd
-    */
-   @Nullable public URI mediaLink() {
-      return mediaLink;
-   }
-
-   public int logicalSizeInGB() {
-      return logicalSizeInGB;
-   }
-
-   /** The eulas for the image, if available. */
-   // Not URI as some providers put non-uri data in, such as riverbed.
-   public List<String> eula() {
-      return eula;
-   }
-
-   public static Image create(String name, String location, String affinityGroup, String label, String description,
-         String category, OSType os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
-      return new Image(name, location, affinityGroup, label, description, category, os, mediaLink, logicalSizeInGB,
-            eula);
-   }
-
-   // TODO: Remove from here down with @AutoValue.
-   private Image(String name, String location, String affinityGroup, String label, String description, String category,
-         OSType os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
-      this.name = checkNotNull(name, "name");
-      this.location = location;
-      this.affinityGroup = affinityGroup;
-      this.label = checkNotNull(label, "label");
-      this.description = description;
-      this.category = category;
-      this.os = checkNotNull(os, "os");
-      this.mediaLink = mediaLink;
-      this.logicalSizeInGB = logicalSizeInGB;
-      this.eula = checkNotNull(eula, "eula");
-   }
-
-   private final String name;
-   private final String location;
-   private final String affinityGroup;
-   private final String label;
-   private final String category;
-   private final String description;
-   private final OSType os;
-   private final URI mediaLink;
-   private final int logicalSizeInGB;
-   private final List<String> eula;
-
-   @Override
-   public boolean equals(Object object) {
-      if (this == object) {
-         return true;
-      }
-      if (object instanceof Image) {
-         Image that = Image.class.cast(object);
-         return equal(name, that.name)
-               && equal(location, that.location)
-               && equal(affinityGroup, that.affinityGroup)
-               && equal(label, that.label)
-               && equal(description, that.description)
-               && equal(category, that.category)
-               && equal(os, that.os)
-               && equal(mediaLink, that.mediaLink)
-               && equal(logicalSizeInGB, that.logicalSizeInGB)
-               && equal(eula, that.eula);
-      } else {
-         return false;
-      }
-   }
-
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(name, location, affinityGroup, label, description, category, os, mediaLink,
-            logicalSizeInGB, eula);
-   }
-
-   @Override
-   public String toString() {
-      return toStringHelper(this)
-            .add("name", name)
-            .add("location", location)
-            .add("affinityGroup", affinityGroup)
-            .add("label", label)
-            .add("description", description)
-            .add("category", category)
-            .add("os", os)
-            .add("mediaLink", mediaLink)
-            .add("logicalSizeInGB", logicalSizeInGB)
-            .add("eula", eula).toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
deleted file mode 100644
index 4f5cbfb..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-
-import org.jclouds.azurecompute.domain.Image.OSType;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-
-/** To create a new operating system image. */
-public final class ImageParams {
-
-   /** Specifies a name that is used to identify the image when you create a Virtual Machine. */
-   public String name() {
-      return name;
-   }
-
-   /** Specifies the friendly name of the image. */
-   public String label() {
-      return label;
-   }
-
-   /** Specifies the location of the vhd file for the image. */
-   public URI mediaLink() {
-      return mediaLink;
-   }
-
-   /** {@link Image#os() Os type} of the image. */
-   public OSType os() {
-      return os;
-   }
-
-   public Builder toBuilder() {
-      return builder().fromImageParams(this);
-   }
-
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public static final class Builder {
-      private String name;
-      private String label;
-      private URI mediaLink;
-      private OSType os;
-
-      public Builder name(String name) {
-         this.name = name;
-         return this;
-      }
-
-      public Builder label(String label) {
-         this.label = label;
-         return this;
-      }
-
-      public Builder mediaLink(URI mediaLink) {
-         this.mediaLink = mediaLink;
-         return this;
-      }
-
-      public Builder os(OSType os) {
-         this.os = os;
-         return this;
-      }
-
-      public ImageParams build() {
-         return ImageParams.create(name, label, mediaLink, os);
-      }
-
-      public Builder fromImageParams(ImageParams in) {
-         return name(in.name())
-               .label(in.label())
-               .mediaLink(in.mediaLink())
-               .os(in.os());
-      }
-   }
-
-   private static ImageParams create(String name, String label, URI mediaLink, OSType os) {
-      return new ImageParams(name, label, mediaLink, os);
-   }
-
-   // TODO: Remove from here down with @AutoValue.
-   private ImageParams(String name, String label, URI mediaLink, OSType os) {
-      this.name = checkNotNull(name, "name");
-      this.label = checkNotNull(label, "label");
-      this.mediaLink = checkNotNull(mediaLink, "mediaLink");
-      this.os = checkNotNull(os, "os");
-   }
-
-   private final String name;
-   private final String label;
-   private final URI mediaLink;
-   private final OSType os;
-
-   @Override public int hashCode() {
-      return Objects.hashCode(name, label, mediaLink, os);
-   }
-
-   @Override public boolean equals(Object object) {
-      if (this == object) {
-         return true;
-      }
-      if (object instanceof ImageParams) {
-         ImageParams that = ImageParams.class.cast(object);
-         return equal(name, that.name)
-               && equal(label, that.label)
-               && equal(mediaLink, that.mediaLink)
-               && equal(os, that.os);
-      } else {
-         return false;
-      }
-   }
-
-   @Override public String toString() {
-      return toStringHelper(this)
-            .add("name", name)
-            .add("label", label)
-            .add("mediaLink", mediaLink)
-            .add("os", os).toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
new file mode 100644
index 0000000..5d1947c
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * OS image from the image repository
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
+ */
+public final class OSImage {
+   public enum Type {
+      LINUX, WINDOWS;
+   }
+
+   public String name() {
+      return name;
+   }
+
+   /** The geo-locations of the image, if the image is not associated with an affinity group. */
+   public List<String> locations() {
+      return locations;
+   }
+
+   /** The affinity group with which this image is associated, if any. */
+   @Nullable public String affinityGroup() {
+      return affinityGroup;
+   }
+
+   /**
+    * The name can be up to 100 characters in length. The name can be used identify the storage account for your
+    * tracking purposes.
+    */
+   public String label() {
+      return label;
+   }
+
+   @Nullable public String description() {
+      return description;
+   }
+
+   /**
+    * The repository classification of image. All user images have the category "User", but
+    * categories for other images could be, for example "Canonical"
+    */
+   @Nullable public String category() {
+      return category;
+   }
+
+   /** The operating system type of the OS image. */
+   public Type os() {
+      return os;
+   }
+
+   /**
+    * The locations of the blob in the blob store in which the media for the image is located. The
+    * blob locations belongs to a storage account in the subscription specified by the
+    * <subscription-id> value in the operation call.
+    *
+    * Example:
+    *
+    * http://example.blob.core.windows.net/disks/myimage.vhd
+    */
+   @Nullable public URI mediaLink() {
+      return mediaLink;
+   }
+
+   public int logicalSizeInGB() {
+      return logicalSizeInGB;
+   }
+
+   /** The eulas for the image, if available. */
+   // Not URI as some providers put non-uri data in, such as riverbed.
+   public List<String> eula() {
+      return eula;
+   }
+
+   public static OSImage create(String name, List<String> locations, String affinityGroup, String label,
+         String description, String category, Type os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
+      return new OSImage(name, locations, affinityGroup, label, description, category, os, mediaLink, logicalSizeInGB,
+            eula);
+   }
+
+   // TODO: Remove from here down with @AutoValue.
+   private OSImage(String name, List<String> locations, String affinityGroup, String label, String description,
+         String category, Type os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
+      this.name = checkNotNull(name, "name");
+      this.locations = locations;
+      this.affinityGroup = affinityGroup;
+      this.label = checkNotNull(label, "label");
+      this.description = description;
+      this.category = category;
+      this.os = checkNotNull(os, "os");
+      this.mediaLink = mediaLink;
+      this.logicalSizeInGB = logicalSizeInGB;
+      this.eula = checkNotNull(eula, "eula");
+   }
+
+   private final String name;
+   private final List<String>  locations;
+   private final String affinityGroup;
+   private final String label;
+   private final String category;
+   private final String description;
+   private final Type os;
+   private final URI mediaLink;
+   private final int logicalSizeInGB;
+   private final List<String> eula;
+
+   @Override
+   public boolean equals(Object object) {
+      if (this == object) {
+         return true;
+      }
+      if (object instanceof OSImage) {
+         OSImage that = OSImage.class.cast(object);
+         return equal(name, that.name)
+               && equal(locations, that.locations)
+               && equal(affinityGroup, that.affinityGroup)
+               && equal(label, that.label)
+               && equal(description, that.description)
+               && equal(category, that.category)
+               && equal(os, that.os)
+               && equal(mediaLink, that.mediaLink)
+               && equal(logicalSizeInGB, that.logicalSizeInGB)
+               && equal(eula, that.eula);
+      } else {
+         return false;
+      }
+   }
+
+   @Override
+   public int hashCode() {
+      return Objects.hashCode(name, locations, affinityGroup, label, description, category, os, mediaLink,
+            logicalSizeInGB, eula);
+   }
+
+   @Override
+   public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("locations", locations)
+            .add("affinityGroup", affinityGroup)
+            .add("label", label)
+            .add("description", description)
+            .add("category", category)
+            .add("os", os)
+            .add("mediaLink", mediaLink)
+            .add("logicalSizeInGB", logicalSizeInGB)
+            .add("eula", eula).toString();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
new file mode 100644
index 0000000..e696650
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/** To create a new operating system image. */
+public final class OSImageParams {
+
+   /** Specifies a name that is used to identify the image when you create a Virtual Machine. */
+   public String name() {
+      return name;
+   }
+
+   /** Specifies the friendly name of the image. */
+   public String label() {
+      return label;
+   }
+
+   /** Specifies the location of the vhd file for the image. */
+   public URI mediaLink() {
+      return mediaLink;
+   }
+
+   /** {@link OSImage#os() Os type} of the image. */
+   public OSImage.Type os() {
+      return os;
+   }
+
+   public Builder toBuilder() {
+      return builder().fromImageParams(this);
+   }
+
+   public static Builder builder() {
+      return new Builder();
+   }
+
+   public static final class Builder {
+      private String name;
+      private String label;
+      private URI mediaLink;
+      private OSImage.Type os;
+
+      public Builder name(String name) {
+         this.name = name;
+         return this;
+      }
+
+      public Builder label(String label) {
+         this.label = label;
+         return this;
+      }
+
+      public Builder mediaLink(URI mediaLink) {
+         this.mediaLink = mediaLink;
+         return this;
+      }
+
+      public Builder os(OSImage.Type os) {
+         this.os = os;
+         return this;
+      }
+
+      public OSImageParams build() {
+         return OSImageParams.create(name, label, mediaLink, os);
+      }
+
+      public Builder fromImageParams(OSImageParams in) {
+         return name(in.name())
+               .label(in.label())
+               .mediaLink(in.mediaLink())
+               .os(in.os());
+      }
+   }
+
+   private static OSImageParams create(String name, String label, URI mediaLink, OSImage.Type os) {
+      return new OSImageParams(name, label, mediaLink, os);
+   }
+
+   // TODO: Remove from here down with @AutoValue.
+   private OSImageParams(String name, String label, URI mediaLink, OSImage.Type os) {
+      this.name = checkNotNull(name, "name");
+      this.label = checkNotNull(label, "label");
+      this.mediaLink = checkNotNull(mediaLink, "mediaLink");
+      this.os = checkNotNull(os, "os");
+   }
+
+   private final String name;
+   private final String label;
+   private final URI mediaLink;
+   private final OSImage.Type os;
+
+   @Override public int hashCode() {
+      return Objects.hashCode(name, label, mediaLink, os);
+   }
+
+   @Override public boolean equals(Object object) {
+      if (this == object) {
+         return true;
+      }
+      if (object instanceof OSImageParams) {
+         OSImageParams that = OSImageParams.class.cast(object);
+         return equal(name, that.name)
+               && equal(label, that.label)
+               && equal(mediaLink, that.mediaLink)
+               && equal(os, that.os);
+      } else {
+         return false;
+      }
+   }
+
+   @Override public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("label", label)
+            .add("mediaLink", mediaLink)
+            .add("os", os).toString();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
index 1d43707..4390524 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
@@ -16,7 +16,11 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
 import java.util.List;
+
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -24,6 +28,7 @@ import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.MediaType;
+
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
 import org.jclouds.azurecompute.xml.ListDisksHandler;
@@ -32,9 +37,6 @@ import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.ResponseParser;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
 /**
  * The Service Management API includes operations for managing the disks in your subscription.
  *

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
deleted file mode 100644
index 3ca54c3..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.features;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_XML;
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
-import java.util.List;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-import org.jclouds.azurecompute.binders.ImageParamsToXML;
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.azurecompute.functions.ImageParamsName;
-import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
-import org.jclouds.azurecompute.xml.ListImagesHandler;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.ParamParser;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.rest.annotations.XMLResponseParser;
-
-/**
- * The Service Management API includes operations for managing the OS images in your subscription.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
- */
-@Path("/services/images")
-@Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
-@Consumes(APPLICATION_XML)
-public interface ImageApi {
-
-   /**
-    * The List Cloud Services operation lists the cloud services available under the current
-    * subscription.
-    */
-   @Named("ListImages")
-   @GET
-   @XMLResponseParser(ListImagesHandler.class)
-   @Fallback(EmptyListOnNotFoundOr404.class)
-   List<Image> list();
-
-   /**
-    * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to
-    * the image repository.
-    */
-   @Named("AddImage")
-   @POST
-   @Produces(APPLICATION_XML)
-   @ResponseParser(ParseRequestIdHeader.class)
-   String add(@BinderParam(ImageParamsToXML.class) ImageParams params);
-
-   /**
-    * The Update OS Image operation updates an OS image that in your image repository.
-    */
-   @Named("UpdateImage")
-   @PUT
-   @Path("/{imageName}")
-   @Produces(APPLICATION_XML)
-   @ResponseParser(ParseRequestIdHeader.class)
-   String update(@PathParam("imageName") @ParamParser(ImageParamsName.class)
-               @BinderParam(ImageParamsToXML.class) ImageParams params);
-
-   /**
-    * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure.
-    *
-    * @param imageName
-    *           the unique DNS Prefix value in the Windows Azure Management Portal
-    */
-   @Named("DeleteImage")
-   @DELETE
-   @Path("/{imageName}")
-   @Fallback(NullOnNotFoundOr404.class)
-   @ResponseParser(ParseRequestIdHeader.class)
-   String delete(@PathParam("imageName") String imageName);
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
index 2a77e68..0ef5ee0 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
@@ -16,20 +16,22 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+
 import java.util.List;
+
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.core.MediaType;
+
 import org.jclouds.azurecompute.domain.Location;
 import org.jclouds.azurecompute.xml.ListLocationsHandler;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-
 /**
  * The Service Management API includes operations for listing the available data center locations
  * for a cloud service in your subscription.

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java
new file mode 100644
index 0000000..42c58a0
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.features;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
+import java.util.List;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.jclouds.azurecompute.binders.OSImageParamsToXML;
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.azurecompute.functions.OSImageParamsName;
+import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
+import org.jclouds.azurecompute.xml.ListOSImagesHandler;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Headers;
+import org.jclouds.rest.annotations.ParamParser;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * The Service Management API includes operations for managing the OS images in your subscription.
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
+ */
+@Path("/services/images")
+@Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
+@Consumes(APPLICATION_XML)
+public interface OSImageApi {
+
+   /**
+    * The List Cloud Services operation lists the cloud services available under the current
+    * subscription.
+    */
+   @Named("ListImages")
+   @GET
+   @XMLResponseParser(ListOSImagesHandler.class)
+   @Fallback(EmptyListOnNotFoundOr404.class)
+   List<OSImage> list();
+
+   /**
+    * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to
+    * the image repository.
+    */
+   @Named("AddImage")
+   @POST
+   @Produces(APPLICATION_XML)
+   @ResponseParser(ParseRequestIdHeader.class)
+   String add(@BinderParam(OSImageParamsToXML.class) OSImageParams params);
+
+   /**
+    * The Update OS Image operation updates an OS image that in your image repository.
+    */
+   @Named("UpdateImage")
+   @PUT
+   @Path("/{imageName}")
+   @Produces(APPLICATION_XML)
+   @ResponseParser(ParseRequestIdHeader.class)
+   String update(@PathParam("imageName") @ParamParser(OSImageParamsName.class)
+               @BinderParam(OSImageParamsToXML.class) OSImageParams params);
+
+   /**
+    * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure.
+    *
+    * @param imageName
+    *           the unique DNS Prefix value in the Windows Azure Management Portal
+    */
+   @Named("DeleteImage")
+   @DELETE
+   @Path("/{imageName}")
+   @Fallback(NullOnNotFoundOr404.class)
+   @ResponseParser(ParseRequestIdHeader.class)
+   String delete(@PathParam("imageName") String imageName);
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
index 5ee97a6..ac4092b 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
@@ -16,20 +16,21 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.MediaType;
+
 import org.jclouds.azurecompute.domain.Operation;
 import org.jclouds.azurecompute.xml.OperationHandler;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
 /**
  * The Service Management API includes one operation for tracking the progress of asynchronous requests.
  *

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
index 5067029..9f54ed0 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
@@ -23,6 +23,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+
 import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
 import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.Payload;
@@ -48,7 +49,7 @@ public interface VirtualMachineApi {
    @Path("/{name}/Operations")
    @Produces(MediaType.APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   @Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>")
+   @Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>")
    String restart(@PathParam("name") String name);
 
    /**
@@ -59,7 +60,7 @@ public interface VirtualMachineApi {
    @Path("/{name}/Operations")
    @Produces(MediaType.APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   @Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>{imageLabel}</TargetImageLabel><TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>")
+   @Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>{imageLabel}</TargetImageLabel><TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>")
    String capture(@PathParam("name") String name, @PayloadParam("imageName") String imageName,
          @PayloadParam("imageLabel") String imageLabel);
 
@@ -71,7 +72,7 @@ public interface VirtualMachineApi {
    @Path("/{name}/Operations")
    @Produces(MediaType.APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   @Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>")
+   @Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>")
    String shutdown(@PathParam("name") String name);
 
    /**
@@ -82,6 +83,6 @@ public interface VirtualMachineApi {
    @Path("/{name}/Operations")
    @Produces(MediaType.APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   @Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>")
+   @Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>")
    String start(@PathParam("name") String name);
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
deleted file mode 100644
index 3b2c458..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.functions;
-
-import org.jclouds.azurecompute.domain.ImageParams;
-
-import com.google.common.base.Function;
-
-public class ImageParamsName implements Function<Object, String> {
-   @Override public String apply(Object input) {
-      return ImageParams.class.cast(input).name();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java
new file mode 100644
index 0000000..7b962e7
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.functions;
+
+import org.jclouds.azurecompute.domain.OSImageParams;
+
+import com.google.common.base.Function;
+
+public class OSImageParamsName implements Function<Object, String> {
+   @Override public String apply(Object input) {
+      return OSImageParams.class.cast(input).name();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
index 2a0d5aa..db229be 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
@@ -16,11 +16,13 @@
  */
 package org.jclouds.azurecompute.functions;
 
-import com.google.common.base.Function;
+import static org.jclouds.http.HttpUtils.releasePayload;
+
 import javax.inject.Singleton;
+
 import org.jclouds.http.HttpResponse;
 
-import static org.jclouds.http.HttpUtils.releasePayload;
+import com.google.common.base.Function;
 
 /**
  * Parses an x-ms-request-id the header

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
index d4955e1..d90bd16 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
@@ -16,9 +16,9 @@
  */
 package org.jclouds.azurecompute.suppliers;
 
-import com.google.common.base.Charsets;
-import com.google.common.base.Supplier;
-import com.google.common.io.ByteSource;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -34,15 +34,18 @@ import java.security.cert.CertificateFactory;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.KeySpec;
 import java.util.Collection;
+
 import javax.inject.Inject;
 import javax.inject.Singleton;
+
 import org.jclouds.crypto.Crypto;
 import org.jclouds.crypto.Pems;
 import org.jclouds.domain.Credentials;
 import org.jclouds.location.Provider;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
+import com.google.common.base.Charsets;
+import com.google.common.base.Supplier;
+import com.google.common.io.ByteSource;
 
 /**
  * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
index 1936bf8..da9a2a3 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
@@ -16,25 +16,28 @@
  */
 package org.jclouds.azurecompute.suppliers;
 
-import com.google.common.base.Supplier;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+
 import java.security.KeyManagementException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.security.UnrecoverableKeyException;
+
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
+
 import org.jclouds.domain.Credentials;
 import org.jclouds.http.HttpUtils;
 import org.jclouds.http.config.SSLModule.TrustAllCerts;
 import org.jclouds.location.Provider;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
+import com.google.common.base.Supplier;
 
 /**
  * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
index 3792527..b3ae8c2 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
@@ -22,7 +22,7 @@ import java.net.URI;
 
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.http.functions.ParseSax;
 import org.xml.sax.Attributes;
 
@@ -34,7 +34,7 @@ final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Di
    private String location;
    private String affinityGroup;
    private String description;
-   private OSType os;
+   private OSImage.Type os;
    private URI mediaLink;
    private Integer logicalSizeInGB;
    private Attachment attachedTo;
@@ -74,7 +74,7 @@ final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Di
       } else if (qName.equals("OS")) {
          String osText = currentOrNull(currentText);
          if (osText != null) {
-            os = OSType.valueOf(currentOrNull(currentText).toUpperCase());
+            os = OSImage.Type.valueOf(currentOrNull(currentText).toUpperCase());
          }
       } else if (qName.equals("Name")) {
          name = currentOrNull(currentText);

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
deleted file mode 100644
index f13dd5d..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import static com.google.common.base.Strings.emptyToNull;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.http.functions.ParseSax;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
- */
-final class ImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Image> {
-   private String name;
-   private String location;
-   private String affinityGroup;
-   private String label;
-   private String category;
-   private String description;
-   private OSType os;
-   private URI mediaLink;
-   private Integer logicalSizeInGB;
-   private final List<String> eula = Lists.newArrayList();
-
-   private final StringBuilder currentText = new StringBuilder();
-
-   @Override public Image getResult() {
-      Image result = Image.create(name, location, affinityGroup, label, description, category, os, mediaLink,
-            logicalSizeInGB, ImmutableList.copyOf(eula));
-      resetState(); // handler is called in a loop.
-      return result;
-   }
-
-   private void resetState() {
-      name = location = affinityGroup = label = description = category = null;
-      os = null;
-      mediaLink = null;
-      logicalSizeInGB = null;
-      eula.clear();
-   }
-
-   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
-      if (qName.equals("OS")) {
-         String osText = currentOrNull(currentText);
-         if (osText != null) {
-            os = OSType.valueOf(currentOrNull(currentText).toUpperCase());
-         }
-      } else if (qName.equals("Name")) {
-         name = currentOrNull(currentText);
-      } else if (qName.equals("LogicalSizeInGB")) {
-         String gb = currentOrNull(currentText);
-         if (gb != null) {
-            logicalSizeInGB = Integer.parseInt(gb);
-         }
-      } else if (qName.equals("Description")) {
-         description = currentOrNull(currentText);
-      } else if (qName.equals("Category")) {
-         category = currentOrNull(currentText);
-      } else if (qName.equals("Location")) {
-         location = currentOrNull(currentText);
-      } else if (qName.equals("AffinityGroup")) {
-         affinityGroup = currentOrNull(currentText);
-      } else if (qName.equals("MediaLink")) {
-         String link = currentOrNull(currentText);
-         if (link != null) {
-            mediaLink = URI.create(link);
-         }
-      } else if (qName.equals("Eula")) {
-         String eulaField = currentOrNull(currentText);
-         if (eulaField != null) {
-            for (String eula : Splitter.on(';').split(eulaField)) {
-               if ((eula = emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eula field.
-                  this.eula.add(eula);
-               }
-            }
-         }
-      } else if (qName.equals("Label")) {
-         label = currentOrNull(currentText);
-      }
-      currentText.setLength(0);
-   }
-
-   @Override public void characters(char ch[], int start, int length) {
-      currentText.append(ch, start, length);
-   }
-}


[16/21] git commit: Azure compute DeploymentParams name is not globally unique.

Posted by ad...@apache.org.
Azure compute DeploymentParams name is not globally unique.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/d1f10e3c
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/d1f10e3c
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/d1f10e3c

Branch: refs/heads/1.8.x
Commit: d1f10e3c54a87de7f1dafc3682c8bc8b54d490d8
Parents: 13884f4
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Oct 21 21:44:42 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:05:54 2014 -0700

----------------------------------------------------------------------
 .../binders/CreateDeploymentToXML.java          | 119 -------------------
 .../binders/DeploymentParamsToXML.java          | 112 +++++++++++++++++
 .../azurecompute/domain/DeploymentParams.java   |  39 ++++--
 .../azurecompute/features/DeploymentApi.java    |  16 +--
 .../features/DeploymentApiMockTest.java         |   6 +-
 5 files changed, 148 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1f10e3c/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java
deleted file mode 100644
index 67573a8..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/CreateDeploymentToXML.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.binders;
-
-import static com.google.common.base.CaseFormat.UPPER_CAMEL;
-import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
-import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
-
-import java.util.Map;
-
-import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.MapBinder;
-
-import com.jamesmurty.utils.XMLBuilder;
-
-public final class CreateDeploymentToXML implements MapBinder {
-
-   @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
-      String name = postParams.get("name").toString();
-      DeploymentParams params = DeploymentParams.class.cast(postParams.get("params"));
-
-      try {
-         XMLBuilder builder = XMLBuilder.create("Deployment", "http://schemas.microsoft.com/windowsazure")
-            .e("Name").t(name).up()
-            .e("DeploymentSlot").t("Production").up()
-            .e("Label").t(name).up()
-            .e("RoleList")
-            .e("Role")
-            .e("RoleName").t(name).up()
-            .e("RoleType").t("PersistentVMRole").up()
-            .e("ConfigurationSets");
-
-         if (params.os() == OSType.WINDOWS) {
-            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
-            configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
-               .e("ComputerName").t(name).up()
-               .e("AdminPassword").t(params.password()).up()
-               .e("ResetPasswordOnFirstLogon").t("false").up()
-               .e("EnableAutomaticUpdate").t("false").up()
-               .e("DomainJoin")
-               .e("Credentials")
-                  .e("Domain").t(name).up()
-                  .e("Username").t(params.username()).up()
-                  .e("Password").t(params.password()).up()
-               .up() // Credentials
-               .e("JoinDomain").t(name).up()
-               .up() // Domain Join
-               .e("StoredCertificateSettings").up()
-               .up(); // Windows ConfigurationSet
-         } else if (params.os() == OSType.LINUX) {
-            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
-            configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
-               .e("HostName").t(name).up()
-               .e("UserName").t(params.username()).up()
-               .e("UserPassword").t(params.password()).up()
-               .e("DisableSshPasswordAuthentication").t("false").up()
-               .e("SSH").up()
-               .up(); // Linux ConfigurationSet
-         } else {
-            throw new IllegalArgumentException("Unrecognized os type " + params);
-         }
-
-         XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network
-         configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up();
-
-         XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints");
-         for (DeploymentParams.ExternalEndpoint endpoint : params.externalEndpoints()) {
-            XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint");
-            inputBuilder.e("LocalPort").t(Integer.toString(endpoint.localPort())).up()
-               .e("Name").t(endpoint.name()).up()
-               .e("Port").t(Integer.toString(endpoint.port())).up()
-               .e("Protocol").t(endpoint.protocol().toLowerCase()).up()
-               .up(); //InputEndpoint
-         }
-
-         inputEndpoints.up();
-         configBuilder.e("SubnetNames").up()
-            .up();
-
-         builder.up() //ConfigurationSets
-            .e("DataVirtualHardDisks").up()
-            .e("OSVirtualHardDisk")
-            .e("HostCaching").t("ReadWrite").up()
-            .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
-            .e("SourceImageName").t(params.sourceImageName()).up()
-            .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
-            .up() //OSVirtualHardDisk
-            .e("RoleSize").t(UPPER_UNDERSCORE.to(UPPER_CAMEL, params.size().name())).up()
-            .up() //Role
-            .up(); //RoleList
-
-         // TODO: Undeprecate this method as forcing users to wrap a String in guava's ByteSource is not great.
-         return (R) request.toBuilder().payload(builder.asString()).build();
-      } catch (Exception e) {
-         throw propagate(e);
-      }
-   }
-
-   @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
-      throw new UnsupportedOperationException("use map form");
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1f10e3c/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
new file mode 100644
index 0000000..c493c90
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.binders;
+
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
+
+import org.jclouds.azurecompute.domain.DeploymentParams;
+import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.jamesmurty.utils.XMLBuilder;
+
+public final class DeploymentParamsToXML implements Binder {
+
+   @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+      DeploymentParams params = DeploymentParams.class.cast(input);
+
+      try {
+         XMLBuilder builder = XMLBuilder.create("Deployment", "http://schemas.microsoft.com/windowsazure")
+            .e("Name").t(params.name()).up()
+            .e("DeploymentSlot").t("Production").up()
+            .e("Label").t(params.name()).up()
+            .e("RoleList")
+            .e("Role")
+            .e("RoleName").t(params.name()).up()
+            .e("RoleType").t("PersistentVMRole").up()
+            .e("ConfigurationSets");
+
+         if (params.os() == OSType.WINDOWS) {
+            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
+            configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
+               .e("ComputerName").t(params.name()).up()
+               .e("AdminPassword").t(params.password()).up()
+               .e("ResetPasswordOnFirstLogon").t("false").up()
+               .e("EnableAutomaticUpdate").t("false").up()
+               .e("DomainJoin")
+               .e("Credentials")
+                  .e("Domain").t(params.name()).up()
+                  .e("Username").t(params.username()).up()
+                  .e("Password").t(params.password()).up()
+               .up() // Credentials
+               .e("JoinDomain").t(params.name()).up()
+               .up() // Domain Join
+               .e("StoredCertificateSettings").up()
+               .up(); // Windows ConfigurationSet
+         } else if (params.os() == OSType.LINUX) {
+            XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
+            configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
+               .e("HostName").t(params.name()).up()
+               .e("UserName").t(params.username()).up()
+               .e("UserPassword").t(params.password()).up()
+               .e("DisableSshPasswordAuthentication").t("false").up()
+               .e("SSH").up()
+               .up(); // Linux ConfigurationSet
+         } else {
+            throw new IllegalArgumentException("Unrecognized os type " + params);
+         }
+
+         XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network
+         configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up();
+
+         XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints");
+         for (DeploymentParams.ExternalEndpoint endpoint : params.externalEndpoints()) {
+            XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint");
+            inputBuilder.e("LocalPort").t(Integer.toString(endpoint.localPort())).up()
+               .e("Name").t(endpoint.name()).up()
+               .e("Port").t(Integer.toString(endpoint.port())).up()
+               .e("Protocol").t(endpoint.protocol().toLowerCase()).up()
+               .up(); //InputEndpoint
+         }
+
+         inputEndpoints.up();
+         configBuilder.e("SubnetNames").up()
+            .up();
+
+         builder.up() //ConfigurationSets
+            .e("DataVirtualHardDisks").up()
+            .e("OSVirtualHardDisk")
+            .e("HostCaching").t("ReadWrite").up()
+            .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
+            .e("SourceImageName").t(params.sourceImageName()).up()
+            .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
+            .up() //OSVirtualHardDisk
+            .e("RoleSize").t(UPPER_UNDERSCORE.to(UPPER_CAMEL, params.size().name())).up()
+            .up() //Role
+            .up(); //RoleList
+
+         // TODO: Undeprecate this method as forcing users to wrap a String in guava's ByteSource is not great.
+         return (R) request.toBuilder().payload(builder.asString()).build();
+      } catch (Exception e) {
+         throw propagate(e);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1f10e3c/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index 2dd9ae5..ac06305 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -106,6 +106,11 @@ public final class DeploymentParams {
       }
    }
 
+   /** The user-supplied name for this deployment. */
+   public String name() {
+      return name;
+   }
+
    /**
     * Specifies the name of a user to be created in the sudoers group of the
     * virtual machine. User names are ASCII character strings 1 to 32
@@ -157,6 +162,7 @@ public final class DeploymentParams {
    }
 
    public static final class Builder {
+      private String name;
       private RoleSize size = RoleSize.SMALL;
       private String username;
       private String password;
@@ -165,6 +171,11 @@ public final class DeploymentParams {
       private OSType os;
       private List<ExternalEndpoint> externalEndpoints = Lists.newArrayList();
 
+      public Builder name(String name) {
+         this.name = name;
+         return this;
+      }
+
       public Builder size(RoleSize size) {
          this.size = size;
          return this;
@@ -206,12 +217,13 @@ public final class DeploymentParams {
       }
 
       public DeploymentParams build() {
-         return DeploymentParams.create(size, username, password, sourceImageName, mediaLink, os,
+         return DeploymentParams.create(name, size, username, password, sourceImageName, mediaLink, os,
                ImmutableList.copyOf(externalEndpoints));
       }
 
       public Builder fromDeploymentParams(DeploymentParams in) {
-         return size(in.size())
+         return name(in.name())
+               .size(in.size())
                .username(in.username())
                .password(in.password())
                .sourceImageName(in.sourceImageName())
@@ -221,14 +233,15 @@ public final class DeploymentParams {
       }
    }
 
-   private static DeploymentParams create(RoleSize size, String username, String password, String sourceImageName,
+   private static DeploymentParams create(String name, RoleSize size, String username, String password, String sourceImageName,
          URI mediaLink, OSType os, List<ExternalEndpoint> externalEndpoints) {
-      return new DeploymentParams(size, username, password, sourceImageName, mediaLink, os, externalEndpoints);
+      return new DeploymentParams(name, size, username, password, sourceImageName, mediaLink, os, externalEndpoints);
    }
 
    // TODO: Remove from here down with @AutoValue.
-   private DeploymentParams(RoleSize size, String username, String password, String sourceImageName, URI mediaLink,
+   private DeploymentParams(String name, RoleSize size, String username, String password, String sourceImageName, URI mediaLink,
          OSType os, List<ExternalEndpoint> externalEndpoints) {
+      this.name = checkNotNull(name, "name");
       this.size = checkNotNull(size, "size");
       this.username = checkNotNull(username, "username");
       this.password = checkNotNull(password, "password");
@@ -238,6 +251,7 @@ public final class DeploymentParams {
       this.externalEndpoints = checkNotNull(externalEndpoints, "externalEndpoints");
    }
 
+   private final String name;
    private final RoleSize size;
    private final String username;
    private final String password;
@@ -246,19 +260,18 @@ public final class DeploymentParams {
    private final OSType os;
    private final List<ExternalEndpoint> externalEndpoints;
 
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(sourceImageName, username, password, mediaLink, size, os, externalEndpoints);
+   @Override public int hashCode() {
+      return Objects.hashCode(name, sourceImageName, username, password, mediaLink, size, os, externalEndpoints);
    }
 
-   @Override
-   public boolean equals(Object object) {
+   @Override public boolean equals(Object object) {
       if (this == object) {
          return true;
       }
       if (object instanceof DeploymentParams) {
          DeploymentParams that = DeploymentParams.class.cast(object);
-         return equal(size, that.size)
+         return equal(name, that.name)
+               && equal(size, that.size)
                && equal(username, that.username)
                && equal(password, that.password)
                && equal(sourceImageName, that.sourceImageName)
@@ -270,9 +283,9 @@ public final class DeploymentParams {
       }
    }
 
-   @Override
-   public String toString() {
+   @Override public String toString() {
       return toStringHelper(this)
+            .add("name", name)
             .add("size", size)
             .add("username", username)
             .add("password", password)

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1f10e3c/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
index 37dfd4e..69ceba6 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java
@@ -16,6 +16,8 @@
  */
 package org.jclouds.azurecompute.features;
 
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
 import javax.inject.Named;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -25,20 +27,18 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-import org.jclouds.azurecompute.binders.CreateDeploymentToXML;
+
+import org.jclouds.azurecompute.binders.DeploymentParamsToXML;
 import org.jclouds.azurecompute.domain.Deployment;
 import org.jclouds.azurecompute.domain.DeploymentParams;
 import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
 import org.jclouds.azurecompute.xml.DeploymentHandler;
+import org.jclouds.rest.annotations.BinderParam;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.PayloadParam;
 import org.jclouds.rest.annotations.ResponseParser;
 import org.jclouds.rest.annotations.XMLResponseParser;
 
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
 @Path("/services/hostedservices/{serviceName}/deployments")
 @Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
 @Consumes(MediaType.APPLICATION_XML)
@@ -57,15 +57,11 @@ public interface DeploymentApi {
    @Fallback(NullOnNotFoundOr404.class)
    Deployment get(@PathParam("name") String name);
 
-   /**
-    * @param name the name for the deployment and its virtual machine. The name must be unique within Windows Azure.
-    */
    @Named("CreateVirtualMachineDeployment")
    @POST
    @Produces(MediaType.APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   @MapBinder(CreateDeploymentToXML.class)
-   String create(@PayloadParam("name") String name, @PayloadParam("params") DeploymentParams params);
+   String create(@BinderParam(DeploymentParamsToXML.class) DeploymentParams params);
 
    /**
     * The Delete Deployment operation deletes the specified deployment from Windows Azure.

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1f10e3c/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index e665557..e6662ac 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -45,13 +45,14 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
          Image image = ListImagesHandlerTest.expected().get(5); // CentOS
 
          DeploymentParams params = DeploymentParams.builder()
+               .name("mydeployment")
                .size(RoleSize.MEDIUM)
                .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
                .username("username").password("testpwd")
                .externalEndpoint(inboundTcpToLocalPort(80, 8080))
                .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
 
-         assertEquals(api.create("mydeployment", params), "request-1");
+         assertEquals(api.create(params), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices/myservice/deployments", "/deploymentparams.xml");
       } finally {
@@ -69,13 +70,14 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
          Image image = ListImagesHandlerTest.expected().get(1); // Windows
 
          DeploymentParams params = DeploymentParams.builder()
+               .name("mydeployment")
                .size(RoleSize.MEDIUM)
                .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
                .username("username").password("testpwd")
                .externalEndpoint(inboundTcpToLocalPort(80, 8080))
                .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
 
-         assertEquals(api.create("mydeployment", params), "request-1");
+         assertEquals(api.create(params), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices/myservice/deployments", "/deploymentparams-windows.xml");
       } finally {


[17/21] Rename Azure HostedService -> CloudService to match documentation.

Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java
deleted file mode 100644
index f40f3c9..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListHostedServicesHandlerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.HostedService;
-import org.jclouds.azurecompute.domain.HostedService.Status;
-import org.jclouds.date.DateService;
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "ListHostedServicesHandlerTest")
-public class ListHostedServicesHandlerTest extends BaseHandlerTest {
-   private static final DateService DATE_SERVICE = new SimpleDateFormatDateService();
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/hostedservices.xml");
-      ListHostedServicesHandler handler = new ListHostedServicesHandler(new HostedServiceHandler(DATE_SERVICE));
-      List<HostedService> result = factory.create(handler).parse(is);
-
-      assertEquals(result, expected());
-   }
-
-   public static List<HostedService> expected() {
-      return ImmutableList.of( //
-            HostedService.create( //
-                  "neotys", // name
-                  "West Europe", // location
-                  null, // affinityGroup
-                  "neotys", // label
-                  "Implicitly created hosted service2012-08-06 14:55", // description
-                  Status.CREATED, // status
-                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T14:55:17Z"), // created
-                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-06T15:50:34Z"), // lastModified
-                  Collections.<String, String>emptyMap() // extendedProperties
-            ), //
-            HostedService.create( //
-                  "neotys3", // name
-                  "West Europe", // location
-                  null, // affinityGroup
-                  "neotys3", // label
-                  null, // description
-                  Status.CREATED, // status
-                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-07T09:00:02Z"), // created
-                  DATE_SERVICE.iso8601SecondsDateParse("2012-08-07T09:00:02Z"), // lastModified
-                  Collections.<String, String>emptyMap() // extendedProperties
-            ));
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/resources/hostedservice.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/hostedservice.xml b/azurecompute/src/test/resources/hostedservice.xml
index bdece1b..f3619b8 100644
--- a/azurecompute/src/test/resources/hostedservice.xml
+++ b/azurecompute/src/test/resources/hostedservice.xml
@@ -2,7 +2,7 @@
     <Url>https://api/services/hostedservices/neotys</Url>
     <ServiceName>neotys</ServiceName>
     <HostedServiceProperties>
-        <Description>Implicitly created hosted service2012-08-06 14:55</Description>
+        <Description>Implicitly created cloud service2012-08-06 14:55</Description>
         <Location>West Europe</Location>
         <Label>bmVvdHlz</Label>
         <Status>Created</Status>

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99633575/azurecompute/src/test/resources/hostedservices.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/hostedservices.xml b/azurecompute/src/test/resources/hostedservices.xml
index 3cee89b..817ab52 100644
--- a/azurecompute/src/test/resources/hostedservices.xml
+++ b/azurecompute/src/test/resources/hostedservices.xml
@@ -4,7 +4,7 @@
         <Url>https://api/services/hostedservices/neotys</Url>
         <ServiceName>neotys</ServiceName>
         <HostedServiceProperties>
-            <Description>Implicitly created hosted service2012-08-06 14:55</Description>
+            <Description>Implicitly created cloud service2012-08-06 14:55</Description>
             <Location>West Europe</Location>
             <Label>bmVvdHlz</Label>
             <Status>Created</Status>


[14/21] git commit: Minimalize code around hosted service creation.

Posted by ad...@apache.org.
Minimalize code around hosted service creation.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/79f6529f
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/79f6529f
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/79f6529f

Branch: refs/heads/1.8.x
Commit: 79f6529fcdaabbbf772d2d0d8faaee716543b7c8
Parents: 2cd19ba
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Oct 21 21:40:44 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 09:04:17 2014 -0700

----------------------------------------------------------------------
 .../BindCreateHostedServiceToXmlPayload.java    |  79 -------------
 .../azurecompute/features/HostedServiceApi.java |  29 ++---
 .../functions/Base64EncodeLabel.java            |  28 +++++
 .../options/CreateHostedServiceOptions.java     | 115 -------------------
 .../features/HostedServiceApiLiveTest.java      |   2 +-
 .../features/HostedServiceApiMockTest.java      |  22 +---
 .../create_hostedservice_location_options.xml   |   1 -
 7 files changed, 38 insertions(+), 238 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java
deleted file mode 100644
index 900c9a7..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.binders;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
-import com.jamesmurty.utils.XMLBuilder;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.inject.Singleton;
-import org.jclouds.azurecompute.options.CreateHostedServiceOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.MapBinder;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.io.BaseEncoding.base64;
-
-@Singleton
-public class BindCreateHostedServiceToXmlPayload implements MapBinder {
-
-   private static final CreateHostedServiceOptions NO_OPTIONS = new CreateHostedServiceOptions();
-
-   @Override
-   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
-      String serviceName = checkNotNull(postParams.get("name"), "name").toString();
-      String label = base64().encode(checkNotNull(postParams.get("label"), "label").toString().getBytes(UTF_8));
-
-      Optional<String> location = Optional.fromNullable((String) postParams.get("location"));
-      Optional<String> affinityGroup = Optional.fromNullable((String) postParams.get("affinityGroup"));
-      CreateHostedServiceOptions options = Optional
-               .fromNullable((CreateHostedServiceOptions) postParams.get("options")).or(NO_OPTIONS);
-      try {
-         XMLBuilder createHostedService = XMLBuilder.create("CreateHostedService")
-                  .a("xmlns", "http://schemas.microsoft.com/windowsazure").e("ServiceName").t(serviceName).up()
-                  .e("Label").t(label).up();
-
-         if (options.getDescription().isPresent())
-            createHostedService.e("Description").t(options.getDescription().get()).up();
-
-         if (location.isPresent())
-            createHostedService.e("Location").t(location.get()).up();
-         else if (affinityGroup.isPresent())
-            createHostedService.e("AffinityGroup").t(affinityGroup.get()).up();
-         else
-            throw new IllegalArgumentException("you must specify either Location or AffinityGroup!");
-
-         if (options.getExtendedProperties().isPresent() && options.getExtendedProperties().get().size() > 0) {
-            XMLBuilder extendedProperties = createHostedService.e("ExtendedProperties");
-            for (Entry<String, String> entry : options.getExtendedProperties().get().entrySet())
-               extendedProperties.e("ExtendedProperty").e("Name").t(entry.getKey()).up().e("Value").t(entry.getValue());
-         }
-         return (R) request.toBuilder().payload(createHostedService.asString()).build();
-      } catch (Exception e) {
-         throw Throwables.propagate(e);
-      }
-
-   }
-
-   @Override
-   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
-      throw new IllegalStateException("BindCreateHostedServiceToXmlPayload is needs parameters");
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
index bdfeda6..f8d1502 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java
@@ -31,16 +31,16 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 
-import org.jclouds.azurecompute.binders.BindCreateHostedServiceToXmlPayload;
 import org.jclouds.azurecompute.domain.HostedService;
+import org.jclouds.azurecompute.functions.Base64EncodeLabel;
 import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
-import org.jclouds.azurecompute.options.CreateHostedServiceOptions;
 import org.jclouds.azurecompute.xml.HostedServiceHandler;
 import org.jclouds.azurecompute.xml.ListHostedServicesHandler;
 import org.jclouds.javax.annotation.Nullable;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.ParamParser;
+import org.jclouds.rest.annotations.Payload;
 import org.jclouds.rest.annotations.PayloadParam;
 import org.jclouds.rest.annotations.QueryParams;
 import org.jclouds.rest.annotations.ResponseParser;
@@ -89,27 +89,12 @@ public interface HostedServiceApi {
     */
    @Named("CreateHostedService")
    @POST
-   @MapBinder(BindCreateHostedServiceToXmlPayload.class)
    @Produces(APPLICATION_XML)
    @ResponseParser(ParseRequestIdHeader.class)
-   String createServiceWithLabelInLocation(@PayloadParam("name") String name,
-         @PayloadParam("label") String label, @PayloadParam("location") String location);
-
-   /**
-    * same as {@link #createServiceWithLabelInLocation(String, String, String)} , except you can
-    * specify optional parameters such as extended properties or a description.
-    *
-    * @param options
-    *           parameters such as extended properties or a description.
-    */
-   @Named("CreateHostedService")
-   @POST
-   @MapBinder(BindCreateHostedServiceToXmlPayload.class)
-   @Produces(APPLICATION_XML)
-   @ResponseParser(ParseRequestIdHeader.class)
-   String createServiceWithLabelInLocation(@PayloadParam("name") String name,
-         @PayloadParam("label") String label, @PayloadParam("location") String location,
-         @PayloadParam("options") CreateHostedServiceOptions options);
+   @Payload("<CreateHostedService xmlns=\"http://schemas.microsoft.com/windowsazure\"><ServiceName>{name}</ServiceName><Label>{label}</Label><Location>{location}</Location></CreateHostedService>")
+   String createWithLabelInLocation(@PayloadParam("name") String name,
+         @PayloadParam("label") @ParamParser(Base64EncodeLabel.class) String label,
+         @PayloadParam("location") String location);
 
    /**
     * The Get Hosted Service Properties operation retrieves system properties for the specified

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java
new file mode 100644
index 0000000..a8d0513
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.functions;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.io.BaseEncoding.base64;
+
+import com.google.common.base.Function;
+
+public final class Base64EncodeLabel implements Function<Object, String> {
+   @Override public String apply(Object label) {
+      return base64().encode(label.toString().getBytes(UTF_8));
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java b/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java
deleted file mode 100644
index 18ab095..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.options;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import java.util.Map;
-
-/**
- * Optional parameters for creating a hosted service
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441304" >docs</a>
- */
-public class CreateHostedServiceOptions implements Cloneable {
-
-   private Optional<String> description = Optional.absent();
-   private Optional<Map<String, String>> extendedProperties = Optional.absent();
-
-   /**
-    * @see CreateHostedServiceOptions#getDescription()
-    */
-   public CreateHostedServiceOptions description(String description) {
-      this.description = Optional.fromNullable(description);
-      return this;
-   }
-
-   /**
-    * @see CreateHostedServiceOptions#getExtendedProperties()
-    */
-   public CreateHostedServiceOptions extendedProperties(Map<String, String> extendedProperties) {
-      this.extendedProperties = Optional.fromNullable(extendedProperties);
-      return this;
-   }
-
-   /**
-    * A description for the hosted service. The description can be up to 1024 characters in length.
-    */
-   public Optional<String> getDescription() {
-      return description;
-   }
-
-   /**
-    * Represents the name of an extended hosted service property. Each extended property must have
-    * both a defined name and value. You can have a maximum of 50 extended property name/value
-    * pairs.
-    *
-    * The maximum length of the Name element is 64 characters, only alphanumeric characters and
-    * underscores are valid in the Name, and the name must start with a letter. Each extended
-    * property value has a maximum length of 255 characters.
-    */
-   public Optional<Map<String, String>> getExtendedProperties() {
-      return extendedProperties;
-   }
-
-   public static class Builder {
-
-      /**
-       * @see CreateHostedServiceOptions#getDescription()
-       */
-      public static CreateHostedServiceOptions description(String description) {
-         return new CreateHostedServiceOptions().description(description);
-      }
-
-      /**
-       * @see CreateHostedServiceOptions#getExtendedProperties()
-       */
-      public static CreateHostedServiceOptions extendedProperties(Map<String, String> extendedProperties) {
-         return new CreateHostedServiceOptions().extendedProperties(extendedProperties);
-      }
-   }
-
-   @Override
-   public CreateHostedServiceOptions clone() {
-      return new CreateHostedServiceOptions().description(description.orNull()).extendedProperties(
-               extendedProperties.orNull());
-   }
-
-   @Override
-   public boolean equals(Object obj) {
-      if (this == obj)
-         return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
-         return false;
-      CreateHostedServiceOptions other = CreateHostedServiceOptions.class.cast(obj);
-      return Objects.equal(this.description, other.description)
-               && Objects.equal(this.extendedProperties, other.extendedProperties);
-   }
-
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(description, extendedProperties);
-   }
-
-   @Override
-   public String toString() {
-      return Objects.toStringHelper("").omitNullValues().add("description", description.orNull())
-               .add("extendedProperties", extendedProperties.orNull()).toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
index 894c0de..08f53b4 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java
@@ -76,7 +76,7 @@ public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest {
 
    public void testCreateHostedService() {
 
-      String requestId = api().createServiceWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location);
+      String requestId = api().createWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location);
       assertTrue(operationSucceeded.apply(requestId), requestId);
       Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
index 1ac320d..9d0cf80 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java
@@ -16,7 +16,6 @@
  */
 package org.jclouds.azurecompute.features;
 
-import static org.jclouds.azurecompute.options.CreateHostedServiceOptions.Builder.description;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
@@ -26,7 +25,6 @@ import org.jclouds.azurecompute.xml.HostedServiceHandlerTest;
 import org.jclouds.azurecompute.xml.ListHostedServicesHandlerTest;
 import org.testng.annotations.Test;
 
-import com.google.common.collect.ImmutableMap;
 import com.squareup.okhttp.mockwebserver.MockResponse;
 import com.squareup.okhttp.mockwebserver.MockWebServer;
 
@@ -93,14 +91,14 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       }
    }
 
-   public void createServiceWithLabelInLocation() throws Exception {
+   public void createWithLabelInLocation() throws Exception {
       MockWebServer server = mockAzureManagementServer();
       server.enqueue(requestIdResponse("request-1"));
 
       try {
          HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
 
-         assertEquals(api.createServiceWithLabelInLocation("myservice", "service mine", "West US"), "request-1");
+         assertEquals(api.createWithLabelInLocation("myservice", "service mine", "West US"), "request-1");
 
          assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location.xml");
       } finally {
@@ -108,22 +106,6 @@ public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest {
       }
    }
 
-   public void createServiceWithLabelInLocationOptions() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi();
-
-         assertEquals(api.createServiceWithLabelInLocation("myservice", "service mine", "West US",
-               description("my description").extendedProperties(ImmutableMap.of("Role", "Production"))), "request-1");
-
-         assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location_options.xml");
-      } finally {
-         server.shutdown();
-      }
-   }
-
    public void deleteWhenFound() throws Exception {
       MockWebServer server = mockAzureManagementServer();
       server.enqueue(requestIdResponse("request-1"));

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/79f6529f/azurecompute/src/test/resources/create_hostedservice_location_options.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/create_hostedservice_location_options.xml b/azurecompute/src/test/resources/create_hostedservice_location_options.xml
deleted file mode 100644
index 9f7f8f0..0000000
--- a/azurecompute/src/test/resources/create_hostedservice_location_options.xml
+++ /dev/null
@@ -1 +0,0 @@
-<CreateHostedService xmlns="http://schemas.microsoft.com/windowsazure"><ServiceName>myservice</ServiceName><Label>c2VydmljZSBtaW5l</Label><Description>my description</Description><Location>West US</Location><ExtendedProperties><ExtendedProperty><Name>Role</Name><Value>Production</Value></ExtendedProperty></ExtendedProperties></CreateHostedService>
\ No newline at end of file


[12/21] git commit: Azure's OSType is reliable so needs no defensive UNRECOGNIZED enum value. Simplify use and couple to Image.

Posted by ad...@apache.org.
Azure's OSType is reliable so needs no defensive UNRECOGNIZED enum value. Simplify use and couple to Image.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/bd8717be
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/bd8717be
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/bd8717be

Branch: refs/heads/1.8.x
Commit: bd8717be197ca845d89218b409af4290532c97cd
Parents: 02b139e
Author: Adrian Cole <ac...@twitter.com>
Authored: Mon Oct 20 14:39:19 2014 -0400
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:59:52 2014 -0700

----------------------------------------------------------------------
 .../BindDeploymentParamsToXmlPayload.java       |  5 ++-
 .../binders/BindOSImageParamsToXmlPayload.java  | 25 ++++++-----
 .../azurecompute/domain/DeploymentParams.java   |  5 ++-
 .../org/jclouds/azurecompute/domain/Disk.java   |  1 +
 .../org/jclouds/azurecompute/domain/Image.java  |  3 ++
 .../azurecompute/domain/ImageParams.java        |  9 ++--
 .../org/jclouds/azurecompute/domain/OSType.java | 45 --------------------
 .../jclouds/azurecompute/xml/DiskHandler.java   | 12 +++---
 .../jclouds/azurecompute/xml/ImageHandler.java  |  7 ++-
 .../features/DeploymentApiMockTest.java         |  2 +-
 .../azurecompute/features/DiskApiLiveTest.java  |  3 --
 .../azurecompute/features/ImageApiLiveTest.java |  2 -
 .../azurecompute/features/ImageApiMockTest.java |  2 +-
 .../azurecompute/xml/ListDisksHandlerTest.java  |  2 +-
 .../azurecompute/xml/ListImagesHandlerTest.java |  5 ++-
 azurecompute/src/test/resources/images.xml      |  1 +
 16 files changed, 48 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
index 22aa011..8b20634 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java
@@ -18,12 +18,13 @@ package org.jclouds.azurecompute.binders;
 
 import static com.google.common.base.CaseFormat.UPPER_CAMEL;
 import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
 
 import javax.inject.Singleton;
 
 import org.jclouds.azurecompute.domain.DeploymentParams;
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.azurecompute.domain.InputEndpoint;
-import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.rest.Binder;
 
@@ -98,7 +99,7 @@ public class BindDeploymentParamsToXmlPayload implements Binder {
             .e("HostCaching").t("ReadWrite").up()
             .e("MediaLink").t(url(params)).up()
             .e("SourceImageName").t(params.getSourceImageName()).up()
-            .e("OS").t("Linux").up()
+            .e("OS").t(params.getOsType() == LINUX ? "Linux" : "Windows").up()
             .up() //OSVirtualHardDisk
             .e("RoleSize").t(UPPER_UNDERSCORE.to(UPPER_CAMEL, params.getSize().name())).up()
             .up() //Role

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
index bbe0459..1c1ec1e 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java
@@ -16,13 +16,17 @@
  */
 package org.jclouds.azurecompute.binders;
 
-import com.google.common.base.Throwables;
-import com.jamesmurty.utils.XMLBuilder;
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
+
 import javax.inject.Singleton;
+
 import org.jclouds.azurecompute.domain.ImageParams;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.rest.Binder;
 
+import com.jamesmurty.utils.XMLBuilder;
+
 @Singleton
 public class BindOSImageParamsToXmlPayload implements Binder {
 
@@ -31,16 +35,15 @@ public class BindOSImageParamsToXmlPayload implements Binder {
    public <R extends HttpRequest> R bindToRequest(R request, Object input) {
       ImageParams params = ImageParams.class.cast(input);
       try {
-         return (R) request.toBuilder().payload(XMLBuilder.create("OSImage").a("xmlns", "http://schemas.microsoft.com/windowsazure")
-                                                          .e("Label").t(params.getLabel()).up()
-                                                          .e("MediaLink").t(params.getMediaLink().toASCIIString()).up()
-                                                          .e("Name").t(params.getName()).up()
-                                                          .e("OS").t(params.getOS().toString()).up()
-                                                          .up().asString()).build();
+         String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
+                                .e("Label").t(params.getLabel()).up()
+                                .e("MediaLink").t(params.getMediaLink().toASCIIString()).up()
+                                .e("Name").t(params.getName()).up()
+                                .e("OS").t(params.getOS() == LINUX ? "Linux" : "Windows").up()
+                                .up().asString();
+         return (R) request.toBuilder().payload(xml).build();
       } catch (Exception e) {
-         throw Throwables.propagate(e);
+         throw propagate(e);
       }
-
    }
-
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index 504cd49..8007750 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -16,10 +16,13 @@
  */
 package org.jclouds.azurecompute.domain;
 
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.Image.OSType;
+
 import com.google.common.base.Objects;
 import com.google.common.base.Objects.ToStringHelper;
 import com.google.common.collect.Lists;
-import java.util.List;
 
 /**
  * To create a new deployment/role

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
index 6590330..26a16b6 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
@@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.net.URI;
 
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.javax.annotation.Nullable;
 
 import com.google.common.base.Objects;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
index 8a1e373..d533c41 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
@@ -33,6 +33,9 @@ import com.google.common.base.Objects;
  * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
  */
 public final class Image {
+   public enum OSType {
+      LINUX, WINDOWS;
+   }
 
    public String name() {
       return name;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
index 2faa6a4..d02110c 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
@@ -16,11 +16,14 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.net.URI;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import org.jclouds.azurecompute.domain.Image.OSType;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
 
 /**
  * The Add OS Image operation adds an OS image that is currently stored in a storage account in your

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
deleted file mode 100644
index c81b590..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.domain;
-
-import static com.google.common.base.CaseFormat.UPPER_CAMEL;
-import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public enum OSType {
-
-   LINUX,
-   WINDOWS,
-   UNRECOGNIZED;
-
-   public String value() {
-      return UPPER_UNDERSCORE.to(UPPER_CAMEL, name());
-   }
-
-   @Override
-   public String toString() {
-      return value();
-   }
-
-   public static OSType fromValue(String type) {
-      try {
-         return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, checkNotNull(type, "type")));
-      } catch (IllegalArgumentException e) {
-         return UNRECOGNIZED;
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
index 0cc62c6..3792527 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
@@ -22,7 +22,7 @@ import java.net.URI;
 
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.http.functions.ParseSax;
 import org.xml.sax.Attributes;
 
@@ -45,8 +45,8 @@ final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Di
    private final StringBuilder currentText = new StringBuilder();
 
    @Override public Disk getResult() {
-      Disk result = Disk.create(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB,
-            attachedTo, sourceImage);
+      Disk result = Disk.create(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB, attachedTo,
+            sourceImage);
       resetState(); // handler is called in a loop.
       return result;
    }
@@ -73,10 +73,8 @@ final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Di
          attachmentHandler.endElement(ignoredUri, ignoredName, qName);
       } else if (qName.equals("OS")) {
          String osText = currentOrNull(currentText);
-         if (osText != null && osText.toUpperCase().equals("NULL")) {
-            os = null;
-         } else {
-            os = OSType.fromValue(currentOrNull(currentText));
+         if (osText != null) {
+            os = OSType.valueOf(currentOrNull(currentText).toUpperCase());
          }
       } else if (qName.equals("Name")) {
          name = currentOrNull(currentText);

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
index c53888d..f13dd5d 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
@@ -23,7 +23,7 @@ import java.net.URI;
 import java.util.List;
 
 import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.http.functions.ParseSax;
 
 import com.google.common.base.Splitter;
@@ -64,7 +64,10 @@ final class ImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<I
 
    @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
       if (qName.equals("OS")) {
-         os = OSType.fromValue(currentOrNull(currentText));
+         String osText = currentOrNull(currentText);
+         if (osText != null) {
+            os = OSType.valueOf(currentOrNull(currentText).toUpperCase());
+         }
       } else if (qName.equals("Name")) {
          name = currentOrNull(currentText);
       } else if (qName.equals("LogicalSizeInGB")) {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index 90f34a9..d31e699 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -20,7 +20,7 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 
 import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.DeploymentHandlerTest;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index 4e8caba..0f54641 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -17,14 +17,12 @@
 package org.jclouds.azurecompute.features;
 
 import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertNotEquals;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.Location;
-import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -64,7 +62,6 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
    private void checkDisk(Disk disk) {
       assertNull(disk.name(), "Name cannot be null for: " + disk);
       assertNull(disk.os(), "OS cannot be null for: " + disk);
-      assertNotEquals(disk.os(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for: " + disk);
 
       if (disk.attachedTo() != null) {
          // TODO: verify you can lookup the role

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
index 71d4deb..c4b36e4 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
@@ -24,7 +24,6 @@ import static org.testng.Assert.assertTrue;
 
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.Location;
-import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -58,7 +57,6 @@ public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
       assertNotNull(image.label(), "Label cannot be null for " + image);
       assertNotNull(image.name(), "Name cannot be null for " + image);
       assertNotNull(image.os(), "OS cannot be null for " + image);
-      assertNotEquals(image.os(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for " + image);
       assertTrue(image.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + image);
 
       if (image.category() != null) {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
index be3d9d7..4e05102 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
@@ -22,8 +22,8 @@ import static org.testng.Assert.assertTrue;
 
 import java.net.URI;
 
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
 import org.testng.annotations.Test;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
index f263567..320c405 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
@@ -24,7 +24,7 @@ import java.util.List;
 
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.http.functions.BaseHandlerTest;
 import org.testng.annotations.Test;
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
index 823a6e2..1d288e4 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
@@ -19,12 +19,13 @@ package org.jclouds.azurecompute.xml;
 import static org.testng.Assert.assertEquals;
 
 import java.io.InputStream;
+import java.net.URI;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
 import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.azurecompute.domain.Image.OSType;
 import org.jclouds.http.functions.BaseHandlerTest;
 import org.testng.annotations.Test;
 
@@ -62,7 +63,7 @@ public class ListImagesHandlerTest extends BaseHandlerTest {
                   "Windows Server 2008 R2 is a multi-purpose server.", //description
                   "Microsoft", // category
                   OSType.WINDOWS, // os
-                  null, // mediaLink
+                  URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"), // mediaLink
                   30, // logicalSizeInGB
                   Collections.<String>emptyList() // eula
             ),

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/bd8717be/azurecompute/src/test/resources/images.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml
index e7b37d6..deaeae5 100644
--- a/azurecompute/src/test/resources/images.xml
+++ b/azurecompute/src/test/resources/images.xml
@@ -14,6 +14,7 @@
         <Label>Windows Server 2008 R2 SP1, June 2012</Label>
         <LogicalSizeInGB>30</LogicalSizeInGB>
         <Name>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</Name>
+        <MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink>
         <OS>Windows</OS>
         <Eula />
         <Description>Windows Server 2008 R2 is a multi-purpose server.</Description>


[05/21] Cleanup output-only HostedService object.

Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/resources/hostedservice.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/hostedservice.xml b/azurecompute/src/test/resources/hostedservice.xml
index 625aeb3..bdece1b 100644
--- a/azurecompute/src/test/resources/hostedservice.xml
+++ b/azurecompute/src/test/resources/hostedservice.xml
@@ -1,10 +1,13 @@
 <HostedService xmlns="http://schemas.microsoft.com/windowsazure">
-    <Url>https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys</Url>
+    <Url>https://api/services/hostedservices/neotys</Url>
     <ServiceName>neotys</ServiceName>
     <HostedServiceProperties>
-        <Description>Implicitly created hosted service2012-08-06 14:55
-        </Description>
+        <Description>Implicitly created hosted service2012-08-06 14:55</Description>
         <Location>West Europe</Location>
         <Label>bmVvdHlz</Label>
+        <Status>Created</Status>
+        <DateCreated>2012-08-06T14:55:17Z</DateCreated>
+        <DateLastModified>2012-08-06T15:50:34Z</DateLastModified>
+        <ExtendedProperties />
     </HostedServiceProperties>
 </HostedService>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/resources/hostedservice_details.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/hostedservice_details.xml b/azurecompute/src/test/resources/hostedservice_details.xml
deleted file mode 100644
index d730cc7..0000000
--- a/azurecompute/src/test/resources/hostedservice_details.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<HostedService xmlns="http://schemas.microsoft.com/windowsazure">
-    <Url>https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys</Url>
-    <ServiceName>neotys</ServiceName>
-    <HostedServiceProperties>
-        <Description>Implicitly created hosted service2012-08-06 14:55</Description>
-        <Location>West Europe</Location>
-        <Label>bmVvdHlz</Label>
-        <Status>Created</Status>
-        <DateCreated>2012-08-06T14:55:17Z</DateCreated>
-        <DateLastModified>2012-08-06T15:50:34Z</DateLastModified>
-        <ExtendedProperties />
-    </HostedServiceProperties>
-</HostedService>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/497c90b1/azurecompute/src/test/resources/hostedservices.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/hostedservices.xml b/azurecompute/src/test/resources/hostedservices.xml
index 66b7589..3cee89b 100644
--- a/azurecompute/src/test/resources/hostedservices.xml
+++ b/azurecompute/src/test/resources/hostedservices.xml
@@ -1,10 +1,10 @@
 <HostedServices xmlns="http://schemas.microsoft.com/windowsazure"
     xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
     <HostedService>
-        <Url>https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys</Url>
+        <Url>https://api/services/hostedservices/neotys</Url>
         <ServiceName>neotys</ServiceName>
         <HostedServiceProperties>
-            <Description>Implicitly created hosted service2012-08-06  14:55</Description>
+            <Description>Implicitly created hosted service2012-08-06 14:55</Description>
             <Location>West Europe</Location>
             <Label>bmVvdHlz</Label>
             <Status>Created</Status>
@@ -14,7 +14,7 @@
         </HostedServiceProperties>
     </HostedService>
     <HostedService>
-        <Url>https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3</Url>
+        <Url>https://api/services/hostedservices/neotys3</Url>
         <ServiceName>neotys3</ServiceName>
         <HostedServiceProperties>
             <Description i:nil="true" />


[03/21] git commit: Fixed README bug.

Posted by ad...@apache.org.
Fixed README bug.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/99bbd4d9
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/99bbd4d9
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/99bbd4d9

Branch: refs/heads/1.8.x
Commit: 99bbd4d967aed7b527b289976ed34d563880a77c
Parents: af8e2c1
Author: Adrian Cole <ac...@twitter.com>
Authored: Sat Oct 18 10:04:48 2014 -0400
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:34:35 2014 -0700

----------------------------------------------------------------------
 azurecompute/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/99bbd4d9/azurecompute/README.md
----------------------------------------------------------------------
diff --git a/azurecompute/README.md b/azurecompute/README.md
index 022abde..b1a9f61 100644
--- a/azurecompute/README.md
+++ b/azurecompute/README.md
@@ -12,7 +12,7 @@ openssl pkcs12 -export -out $HOME/.jclouds/azure.p12 -in $HOME/.jclouds/azure.pe
 # create a cer file which you upload to the management console to authorize this certificate.
 # https://manage.windowsazure.com/@ignasibarreragmail.onmicrosoft.com#Workspaces/AdminTasks/ListManagementCertificates
 # note you need to press command+shift+. to display hidden directories in a open dialog in osx
-openssl x509 -inform pem -in $HOME/.jclouds/azure.p12 -outform der -out $HOME/.jclouds/azure.cer
+openssl x509 -inform pem -in $HOME/.jclouds/azure.pem -outform der -out $HOME/.jclouds/azure.cer
 ```
 
 Once you do this, you will set the following to run the live tests.
@@ -20,4 +20,4 @@ Once you do this, you will set the following to run the live tests.
 mvn -Plive -Dtest.jclouds.azurecompute.subscription-id=12345678-abcd-dcba-abdc-ba0987654321
 -Dtest.azurecompute.credential=P12_EXPORT_PASSWORD
 -Dtest.azurecompute.identity=$HOME/.jclouds/azure.p12
-```
\ No newline at end of file
+```


[08/21] git commit: Cleanup output-only Error object.

Posted by ad...@apache.org.
Cleanup output-only Error object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/7919efab
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/7919efab
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/7919efab

Branch: refs/heads/1.8.x
Commit: 7919efab91ecec6e6278326acd14957e6e2e0dbb
Parents: 34b4fc2
Author: Adrian Cole <ac...@twitter.com>
Authored: Thu Oct 16 19:59:06 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:42:15 2014 -0700

----------------------------------------------------------------------
 .../org/jclouds/azurecompute/domain/Error.java  | 201 +++----------------
 .../jclouds/azurecompute/xml/ErrorHandler.java  |  41 ++--
 .../jclouds/azurecompute/parse/ErrorTest.java   |  50 -----
 .../azurecompute/parse/GetOperationTest.java    |  14 +-
 .../azurecompute/xml/ErrorHandlerTest.java      |  42 ++++
 5 files changed, 96 insertions(+), 252 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7919efab/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
index d25a046..1b529d0 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java
@@ -16,224 +16,77 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Objects;
-
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Objects;
+
 /**
- * additional error information that is defined by the management service. Th
- *
  * @see <a href="http://msdn.microsoft.com/en-us/library/ee460801" >api</a>
  */
-public class Error {
-
+public final class Error {
    public static enum Code {
-
-      /**
-       * Bad Request (400)
-       *
-       * The versioning header is not specified or was specified incorrectly.
-       */
       MISSING_OR_INCORRECT_VERSION_HEADER,
-
-      /**
-       * Bad Request (400)
-       *
-       * The request body’s XML was invalid or not correctly specified.
-       */
       INVALID_XML_REQUEST,
-
-      /**
-       * Bad Request (400)
-       *
-       * A required query parameter was not specified for this request or was specified incorrectly.
-       */
       MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER,
-
-      /**
-       * Bad Request (400)
-       *
-       * The HTTP verb specified was not recognized by the server or isn’t valid for this resource.
-       */
       INVALID_HTTP_VERB,
-
-      /**
-       * Forbidden (403)
-       *
-       * The server failed to authenticate the request. Verify that the certificate is valid and is
-       * associated with this subscription.
-       */
       AUTHENTICATION_FAILED,
-
-      /**
-       * Not Found (404)
-       *
-       * The specified resource does not exist.
-       */
       RESOURCE_NOT_FOUND,
-
-      /**
-       * Internal Server Error (500)
-       *
-       * The server encountered an internal error. Please retry the request.
-       */
       INTERNAL_ERROR,
-
-      /**
-       * Internal Server Error (500)
-       *
-       * The operation could not be completed within the permitted time.
-       */
       OPERATION_TIMED_OUT,
-
-      /**
-       * Service Unavailable (503)
-       *
-       * The server (or an internal component) is currently unavailable to receive requests. Please
-       * retry your request
-       */
       SERVER_BUSY,
-
-      /**
-       * Forbidden (403)
-       *
-       * The subscription is in a disabled state.
-       */
       SUBSCRIPTION_DISABLED,
-
-      /**
-       * Bad Request (400)
-       *
-       * A parameter was incorrect.
-       */
       BAD_REQUEST,
-
-      /**
-       * Conflict (409)
-       *
-       * A conflict occurred to prevent the operation from completing.
-       */
       CONFLICT_ERROR,
-
       UNRECOGNIZED;
-
-      public String value() {
-         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
-      }
-
-      @Override
-      public String toString() {
-         return value();
-      }
-
-      public static Code fromValue(String code) {
-         try {
-            return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(code, "code")));
-         } catch (IllegalArgumentException e) {
-            return UNRECOGNIZED;
-         }
-      }
    }
 
-   public static Builder builder() {
-      return new Builder();
+   /** Error code */
+   public Code getCode() {
+      return code;
    }
 
-   public Builder toBuilder() {
-      return builder().fromError(this);
+   /** User message */
+   public String message() {
+      return message;
    }
 
-   public static class Builder {
-
-      private String rawCode;
-      private Code code;
-      private String message;
-
-      /**
-       * @see Error#getRawCode()
-       */
-      public Builder rawCode(String rawCode) {
-         this.rawCode = rawCode;
-         return this;
-      }
-
-      /**
-       * @see Error#getCode()
-       */
-      public Builder code(Code code) {
-         this.code = code;
-         return this;
-      }
-
-      /**
-       * @see Error#getMessage()
-       */
-      public Builder message(String message) {
-         this.message = message;
-         return this;
-      }
-
-      public Error build() {
-         return new Error(rawCode, code, message);
-      }
-
-      public Builder fromError(Error in) {
-         return this.rawCode(in.rawCode).code(in.code).message(in.message);
-      }
+   public static Error create(Code code, String message) {
+      return new Error(code, message);
    }
 
-   private final String rawCode;
-   private final Code code;
-   private final String message;
-
-   protected Error(String rawCode, Code code, String message) {
-      this.rawCode = checkNotNull(rawCode, "rawCode for %s", message);
-      this.code = checkNotNull(code, "code for %s", message);
+   // TODO: Remove from here down with @AutoValue.
+   private Error(Code code, String message) {
+      this.code = checkNotNull(code, "code");
       this.message = checkNotNull(message, "message");
    }
 
-   /**
-    * Error code
-    */
-   public Code getCode() {
-      return code;
-   }
-
-   /**
-    * Error code, unparsed
-    */
-   public String getRawCode() {
-      return rawCode;
-   }
-
-   /**
-    * User message
-    */
-   public String getMessage() {
-      return message;
-   }
+   private final Code code;
+   private final String message;
 
    @Override
    public int hashCode() {
-      return Objects.hashCode(rawCode, code, message);
+      return Objects.hashCode(code, message);
    }
 
    @Override
    public boolean equals(Object obj) {
-      if (this == obj)
+      if (this == obj) {
          return true;
-      if (obj == null)
+      }
+      if (obj == null) {
          return false;
-      if (getClass() != obj.getClass())
+      }
+      if (getClass() != obj.getClass()) {
          return false;
+      }
       Error other = (Error) obj;
-      return Objects.equal(this.rawCode, other.rawCode) && Objects.equal(this.code, other.code)
-               && Objects.equal(this.message, other.message);
+      return equal(this.code, other.code) && equal(this.message, other.message);
    }
 
    @Override
    public String toString() {
-      return Objects.toStringHelper(this).omitNullValues().add("code", rawCode).add("message", message).toString();
+      return toStringHelper(this).add("code", code).add("message", message).toString();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7919efab/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java
index 04dca23..2d49bbc 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java
@@ -16,43 +16,46 @@
  */
 package org.jclouds.azurecompute.xml;
 
+import static com.google.common.base.CaseFormat.UPPER_CAMEL;
+import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
 import org.jclouds.azurecompute.domain.Error;
 import org.jclouds.azurecompute.domain.Error.Code;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.SAXException;
 
 /**
  * @see <a href="http://msdn.microsoft.com/en-us/library/ee460801" >api</a>
  */
-public class ErrorHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Error> {
+public final class ErrorHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Error> {
+   private Code code;
+   private String message;
 
    private StringBuilder currentText = new StringBuilder();
-   private Error.Builder builder = Error.builder();
 
-   @Override
-   public Error getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = Error.builder();
-      }
+   @Override public Error getResult() {
+      return Error.create(code, message);
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
       if (qName.equals("Code")) {
-         String rawCode = SaxUtils.currentOrNull(currentText);
-         builder.rawCode(rawCode);
-         builder.code(Code.fromValue(rawCode));
+         String codeText = currentOrNull(currentText);
+         code = parseCode(codeText);
       } else if (qName.equals("Message")) {
-         builder.message(SaxUtils.currentOrNull(currentText));
+         message = currentOrNull(currentText);
       }
       currentText = new StringBuilder();
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       currentText.append(ch, start, length);
    }
+
+   private static Code parseCode(String code) {
+      try {
+         return Code.valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, code));
+      } catch (IllegalArgumentException e) {
+         return Code.UNRECOGNIZED;
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7919efab/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java
deleted file mode 100644
index 12d38c6..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import java.io.InputStream;
-import org.jclouds.azurecompute.domain.Error;
-import org.jclouds.azurecompute.domain.Error.Code;
-import org.jclouds.azurecompute.xml.ErrorHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "ErrorTest")
-public class ErrorTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/error.xml");
-
-      Error expected = expected();
-
-      ErrorHandler handler = injector.getInstance(ErrorHandler.class);
-      Error result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-
-   }
-
-   public Error expected() {
-      return Error.builder()
-                  .rawCode("MissingOrInvalidRequiredQueryParameter")
-                  .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER)
-                  .message("A required query parameter was not specified for this request or was specified incorrectly.")
-                  .build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7919efab/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
index ecf7083..8e41f81 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java
@@ -16,17 +16,17 @@
  */
 package org.jclouds.azurecompute.parse;
 
+import static org.testng.Assert.assertEquals;
+
 import java.io.InputStream;
-import org.jclouds.azurecompute.domain.Error;
-import org.jclouds.azurecompute.domain.Error.Code;
+
 import org.jclouds.azurecompute.domain.Operation;
 import org.jclouds.azurecompute.domain.Operation.Status;
+import org.jclouds.azurecompute.xml.ErrorHandlerTest;
 import org.jclouds.azurecompute.xml.OperationHandler;
 import org.jclouds.http.functions.BaseHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.testng.Assert.assertEquals;
-
 @Test(groups = "unit", testName = "GetOperationTest")
 public class GetOperationTest extends BaseHandlerTest {
 
@@ -47,11 +47,7 @@ public class GetOperationTest extends BaseHandlerTest {
                       .rawStatus("Failed")
                       .status(Status.FAILED)
                       .httpStatusCode(400)
-                      .error(Error.builder()
-                                  .rawCode("MissingOrInvalidRequiredQueryParameter")
-                                  .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER)
-                                  .message("A required query parameter was not specified for this request or was specified incorrectly.")
-                                  .build())
+                      .error(ErrorHandlerTest.expected())
                       .build();
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7919efab/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ErrorHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ErrorHandlerTest.java
new file mode 100644
index 0000000..3c9a74b
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ErrorHandlerTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.jclouds.azurecompute.domain.Error;
+import org.jclouds.azurecompute.domain.Error.Code;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "ErrorHandlerTest")
+public class ErrorHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/error.xml");
+      Error result = factory.create(new ErrorHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static Error expected() {
+      return Error.create(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER,
+            "A required query parameter was not specified for this request or was specified incorrectly.");
+   }
+}


[09/21] git commit: Cleanup output-only Disk object.

Posted by ad...@apache.org.
Cleanup output-only Disk object.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/615c745e
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/615c745e
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/615c745e

Branch: refs/heads/1.8.x
Commit: 615c745e5ec054b15564237630eabdd42eaca936
Parents: 7919efa
Author: Adrian Cole <ac...@twitter.com>
Authored: Sun Oct 19 10:34:30 2014 -0400
Committer: Adrian Cole <ad...@apache.org>
Committed: Fri Oct 24 08:48:05 2014 -0700

----------------------------------------------------------------------
 .../org/jclouds/azurecompute/domain/Disk.java   | 445 +++++--------------
 .../azurecompute/xml/AttachmentHandler.java     |  38 +-
 .../jclouds/azurecompute/xml/DiskHandler.java   | 151 ++++---
 .../azurecompute/xml/ListDisksHandler.java      |  35 +-
 .../azurecompute/features/DiskApiLiveTest.java  |  74 ++-
 .../azurecompute/features/DiskApiMockTest.java  |  19 +-
 .../azurecompute/parse/ListDisksTest.java       |  71 ---
 .../azurecompute/xml/ListDisksHandlerTest.java  |  67 +++
 azurecompute/src/test/resources/disks.xml       |   6 +-
 9 files changed, 333 insertions(+), 573 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
index 69a8c40..6590330 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
@@ -16,102 +16,56 @@
  */
 package org.jclouds.azurecompute.domain;
 
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Optional;
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.net.URI;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
 
 /**
- * disk in the image repository
+ * A disk in the image repository.
  *
  * @see <a href="http://msdn.microsoft.com/en-us/library/jj157176" >api</a>
  */
-public class Disk {
-   public static class Attachment {
-
-      public static Builder builder() {
-         return new Builder();
+public final class Disk {
+   public static final class Attachment {
+      /** The deployment in which the disk is being used. */
+      public String deployment() {
+         return deployment;
       }
 
-      public Builder toBuilder() {
-         return builder().fromAttachment(this);
+      /** The hosted service in which the disk is being used. */
+      public String hostedService() {
+         return hostedService;
       }
 
-      public static class Builder {
-
-         private String hostedService;
-         private String deployment;
-         private String role;
-
-         /**
-          * @see Attachment#getHostedService()
-          */
-         public Builder hostedService(String hostedService) {
-            this.hostedService = hostedService;
-            return this;
-         }
-
-         /**
-          * @see Attachment#getDeployment()
-          */
-         public Builder deployment(String deployment) {
-            this.deployment = deployment;
-            return this;
-         }
-
-         /**
-          * @see Attachment#getRole()
-          */
-         public Builder role(String role) {
-            this.role = role;
-            return this;
-         }
-
-         public Attachment build() {
-            return new Attachment(hostedService, deployment, role);
-         }
-
-         public Builder fromAttachment(Attachment in) {
-            return this.hostedService(in.hostedService).deployment(in.deployment).role(in.role);
-         }
+      /** The virtual machine that the disk is attached to. */
+      public String virtualMachine() {
+         return virtualMachine;
       }
 
-      private final String hostedService;
-      private final String deployment;
-      private final String role;
+      public static Attachment create(String hostedService, String deployment, String virtualMachine) {
+         return new Attachment(hostedService, deployment, virtualMachine);
+      }
 
-      private Attachment(String hostedService, String deployment, String role) {
+      // TODO: Remove from here down with @AutoValue.
+      private Attachment(String hostedService, String deployment, String virtualMachine) {
          this.hostedService = checkNotNull(hostedService, "hostedService");
          this.deployment = checkNotNull(deployment, "deployment");
-         this.role = checkNotNull(role, "role");
-      }
-
-      /**
-       * The deployment in which the disk is being used.
-       */
-      public String getDeployment() {
-         return deployment;
-      }
-
-      /**
-       * The hosted service in which the disk is being used.
-       */
-      public String getHostedService() {
-         return hostedService;
+         this.virtualMachine = checkNotNull(virtualMachine, "virtualMachine");
       }
 
-      /**
-       * The virtual machine that the disk is attached to.
-       */
-      public String getRole() {
-         return role;
-      }
+      private final String hostedService;
+      private final String deployment;
+      private final String virtualMachine;
 
       @Override
       public int hashCode() {
-         return Objects.hashCode(hostedService, deployment, role);
+         return Objects.hashCode(hostedService, deployment, virtualMachine);
       }
 
       @Override
@@ -126,316 +80,157 @@ public class Disk {
             return false;
          }
          Attachment other = (Attachment) obj;
-         return Objects.equal(this.hostedService, other.hostedService) && Objects
-               .equal(this.deployment, other.deployment) && Objects.equal(this.role, other.role);
+         return equal(this.hostedService, other.hostedService) &&
+               equal(this.deployment, other.deployment) &&
+               equal(this.virtualMachine, other.virtualMachine);
       }
 
       @Override
       public String toString() {
-         return Objects.toStringHelper(this).omitNullValues().add("deployment", hostedService).add("role", role)
-               .toString();
-      }
-
-   }
-
-   public static Builder builder() {
-      return new Builder();
-   }
-
-   public Builder toBuilder() {
-      return new Builder().fromHostedService(this);
-   }
-
-   public static class Builder {
-
-      private Optional<Attachment> attachedTo = Optional.absent();
-      private OSType os;
-      private String name;
-      private Optional<Integer> logicalSizeInGB = Optional.absent();
-      private Optional<String> description = Optional.absent();
-      private Optional<String> location = Optional.absent();
-      private Optional<String> affinityGroup = Optional.absent();
-      private Optional<URI> mediaLink = Optional.absent();
-      private Optional<String> sourceImage = Optional.absent();
-      private Optional<String> label = Optional.absent();
-      private boolean hasOperatingSystem;
-      private boolean isCorrupted;
-
-      /**
-       * @see Disk#getAttachedTo()
-       */
-      public Builder attachedTo(Attachment attachedTo) {
-         this.attachedTo = Optional.fromNullable(attachedTo);
-         return this;
-      }
-
-      /**
-       * @see Disk#getOS()
-       */
-      public Builder os(OSType os) {
-         this.os = os;
-         return this;
-      }
-
-      /**
-       * @see Disk#getName()
-       */
-      public Builder name(String name) {
-         this.name = name;
-         return this;
-      }
-
-      /**
-       * @see Disk#getDescription()
-       */
-      public Builder description(String description) {
-         this.description = Optional.fromNullable(description);
-         return this;
-      }
-
-      /**
-       * @see Disk#getLogicalSizeInGB()
-       */
-      public Builder logicalSizeInGB(Integer logicalSizeInGB) {
-         this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB);
-         return this;
-      }
-
-      /**
-       * @see Disk#getLocation()
-       */
-      public Builder location(String location) {
-         this.location = Optional.fromNullable(location);
-         return this;
-      }
-
-      /**
-       * @see Disk#getAffinityGroup()
-       */
-      public Builder affinityGroup(String affinityGroup) {
-         this.affinityGroup = Optional.fromNullable(affinityGroup);
-         return this;
-      }
-
-      /**
-       * @see Disk#getMediaLink()
-       */
-      public Builder mediaLink(URI mediaLink) {
-         this.mediaLink = Optional.fromNullable(mediaLink);
-         return this;
-      }
-
-      /**
-       * @see Disk#getSourceImage()
-       */
-      public Builder sourceImage(String sourceImage) {
-         this.sourceImage = Optional.fromNullable(sourceImage);
-         return this;
-      }
-
-      /**
-       * @see Disk#getLabel()
-       */
-      public Builder label(String label) {
-         this.label = Optional.fromNullable(label);
-         return this;
-      }
-
-      /**
-       * @see Disk#hasOperatingSystem()
-       */
-      public Builder hasOperatingSystem(boolean hasOperatingSystem) {
-         this.hasOperatingSystem = hasOperatingSystem;
-         return this;
-      }
-
-      /**
-       * @see Disk#isCorrupted()
-       */
-      public Builder isCorrupted(boolean isCorrupted) {
-         this.isCorrupted = isCorrupted;
-         return this;
-      }
-
-      public Disk build() {
-         return new Disk(attachedTo, os, name, logicalSizeInGB, description, location, affinityGroup, mediaLink,
-               sourceImage, label, hasOperatingSystem, isCorrupted);
-      }
-
-      public Builder fromHostedService(Disk in) {
-         return this.attachedTo(in.attachedTo.orNull()).os(in.getOS()).name(in.getName())
-               .logicalSizeInGB(in.getLogicalSizeInGB().orNull()).description(in.getDescription().orNull())
-               .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull())
-               .mediaLink(in.getMediaLink().orNull()).sourceImage(in.getSourceImage().orNull())
-               .label(in.getLabel().orNull()).hasOperatingSystem(in.hasOperatingSystem).isCorrupted(in.isCorrupted);
+         return Objects.toStringHelper(this)
+               .add("hostedService", hostedService)
+               .add("deployment", deployment)
+               .add("virtualMachine", virtualMachine).toString();
       }
-   }
-
-   private final Optional<Attachment> attachedTo;
-   private final OSType os;
-   private final String name;
-   private final Optional<Integer> logicalSizeInGB;
-   private final Optional<String> description;
-   private final Optional<String> location;
-   private final Optional<String> affinityGroup;
-   private final Optional<URI> mediaLink;
-   private final Optional<String> sourceImage;
-   private final Optional<String> label;
-   private final boolean hasOperatingSystem;
-   private final boolean isCorrupted;
-
-   private Disk(Optional<Attachment> attachedTo, OSType os, String name, Optional<Integer> logicalSizeInGB,
-         Optional<String> description, Optional<String> location, Optional<String> affinityGroup,
-         Optional<URI> mediaLink, Optional<String> sourceImage, Optional<String> label, boolean hasOperatingSystem,
-         boolean isCorrupted) {
-      this.name = checkNotNull(name, "name");
-      this.attachedTo = checkNotNull(attachedTo, "attachedTo for %s", name);
-      this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name);
-      this.description = checkNotNull(description, "description for %s", name);
-      this.os = checkNotNull(os, "os for %s", name);
-      this.location = checkNotNull(location, "location for %s", name);
-      this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name);
-      this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name);
-      this.sourceImage = checkNotNull(sourceImage, "sourceImage for %s", name);
-      this.label = checkNotNull(label, "label for %s", name);
-      this.hasOperatingSystem = hasOperatingSystem;
-      this.isCorrupted = isCorrupted;
-   }
-
-   /**
-    * Contains properties that specify a virtual machine that currently using the disk. A disk
-    * cannot be deleted as long as it is attached to a virtual machine.
-    */
-   public Optional<Attachment> getAttachedTo() {
-      return attachedTo;
-   }
 
-   /**
-    * The operating system type of the OS image.
-    */
-   public OSType getOS() {
-      return os;
    }
 
    /**
     * The name of the disk. This is the name that is used when creating one or more virtual machines
     * using the disk.
     */
-   public String getName() {
+   public String name() {
       return name;
    }
 
    /**
-    * The size, in GB, of the image.
+    * The geo-location of the disk in Windows Azure, if the disk is not
+    * associated with an affinity group. If a location has been specified, the AffinityGroup element
+    * is not returned.
     */
-   public Optional<Integer> getLogicalSizeInGB() {
-      return logicalSizeInGB;
+   @Nullable public String location() {
+      return location;
    }
 
    /**
-    * The description for the image.
+    * The affinity group with which this disk is associated, if any. If the service is
+    * associated with an affinity group, the Location element is not returned.
     */
-   public Optional<String> getDescription() {
-      return description;
+   @Nullable public String affinityGroup() {
+      return affinityGroup;
    }
 
-   /**
-    * The geo-location in which this media is located. The Location value is derived from storage
-    * account that contains the blob in which the media is located. If the storage account belongs
-    * to an affinity group the value is absent.
-    */
-   public Optional<String> getLocation() {
-      return location;
+   @Nullable public String description() {
+      return description;
    }
 
-   /**
-    * The affinity in which the media is located. The AffinityGroup value is derived from storage
-    * account that contains the blob in which the media is located. If the storage account does not
-    * belong to an affinity group the value is absent.
-    */
-   public Optional<String> getAffinityGroup() {
-      return affinityGroup;
+   /** The operating system type of the OS image, or null if a data disk. */
+   @Nullable public OSType os() {
+      return os;
    }
 
    /**
-    * The location of the blob in the blob store in which the media for the disk is located. The
+    * The location of the blob in the blob store in which the media for the image is located. The
     * blob location belongs to a storage account in the subscription specified by the
     * <subscription-id> value in the operation call.
     *
     * Example:
     *
-    * http://example.blob.core.windows.net/disks/mydisk.vhd
+    * http://example.blob.core.windows.net/disks/myimage.vhd
     */
-   public Optional<URI> getMediaLink() {
+   @Nullable public URI mediaLink() {
       return mediaLink;
    }
 
-   /**
-    * The name of the OS Image from which the disk was created. This property is populated
-    * automatically when a disk is created from an OS image by calling the Add Role, Create
-    * Deployment, or Provision Disk operations.
-    */
-   public Optional<String> getSourceImage() {
-      return sourceImage;
+   @Nullable public Integer logicalSizeInGB() {
+      return logicalSizeInGB;
    }
 
    /**
-    * The description of the image.
+    * Contains properties that specify a virtual machine that currently using the disk. A disk
+    * cannot be deleted as long as it is attached to a virtual machine.
     */
-   public Optional<String> getLabel() {
-      return label;
+   @Nullable public Attachment attachedTo() {
+      return attachedTo;
    }
 
    /**
-    * Returns whether this disk contains operation system. Only disks that have an operating system
-    * installed can be mounted as an OS Drive.
+    * The name of the OS Image from which the disk was created. This property is populated
+    * automatically when a disk is created from an OS image by calling the Add Role, Create
+    * Deployment, or Provision Disk operations.
     */
-   public boolean hasOperatingSystem() {
-      return hasOperatingSystem;
+   @Nullable public String sourceImage() {
+      return sourceImage;
    }
 
-   /**
-    * Returns whether there is a consistency failure detected with this disk. If a disk fails the
-    * consistency check, you delete any virtual machines using it, delete the disk, and inspect the
-    * blob media to see if the content is intact. You can then reregister the media in the blob as a
-    * disk.
-    */
-   public boolean isCorrupted() {
-      return isCorrupted;
+   public static Disk create(String name, String location, String affinityGroup, String description,
+         OSType os, URI mediaLink, Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
+      return new Disk(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB, attachedTo,
+            sourceImage);
    }
 
-   @Override
-   public int hashCode() {
-      return Objects.hashCode(name);
+   // TODO: Remove from here down with @AutoValue.
+   private Disk(String name, String location, String affinityGroup, String description, OSType os, URI mediaLink,
+         Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
+      this.name = checkNotNull(name, "name");
+      this.location = location;
+      this.affinityGroup = affinityGroup;
+      this.description = description;
+      this.os = os;
+      this.mediaLink = mediaLink;
+      this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB of %s", name);
+      this.attachedTo = attachedTo;
+      this.sourceImage = sourceImage;
    }
 
+   private final String name;
+   private final String location;
+   private final String affinityGroup;
+   private final String description;
+   private final OSType os;
+   private final URI mediaLink;
+   private final Integer logicalSizeInGB;
+   private final Attachment attachedTo;
+   private final String sourceImage;
+
    @Override
-   public boolean equals(Object obj) {
-      if (this == obj) {
+   public boolean equals(Object object) {
+      if (this == object) {
          return true;
       }
-      if (obj == null) {
+      if (object instanceof Disk) {
+         Disk that = Disk.class.cast(object);
+         return equal(name, that.name) &&
+               equal(location, that.location) &&
+               equal(affinityGroup, that.affinityGroup) &&
+               equal(description, that.description) &&
+               equal(os, that.os) &&
+               equal(mediaLink, that.mediaLink) &&
+               equal(logicalSizeInGB, that.logicalSizeInGB) &&
+               equal(attachedTo, that.attachedTo) &&
+               equal(sourceImage, that.sourceImage);
+      } else {
          return false;
       }
-      if (getClass() != obj.getClass()) {
-         return false;
-      }
-      Disk other = (Disk) obj;
-      return Objects.equal(this.name, other.name);
    }
 
    @Override
-   public String toString() {
-      return string().toString();
+   public int hashCode() {
+      return Objects.hashCode(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB,
+            attachedTo, sourceImage);
    }
 
-   private ToStringHelper string() {
-      return Objects.toStringHelper(this).omitNullValues().add("os", os).add("name", name)
-            .add("attachedTo", attachedTo.orNull()).add("logicalSizeInGB", logicalSizeInGB.orNull())
-            .add("description", description).add("location", location.orNull())
-            .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull())
-            .add("sourceImage", sourceImage.orNull()).add("label", label.orNull())
-            .add("hasOperatingSystem", hasOperatingSystem).add("isCorrupted", isCorrupted);
+   @Override
+   public String toString() {
+      return toStringHelper(this)
+            .add("name", name)
+            .add("location", location)
+            .add("affinityGroup", affinityGroup)
+            .add("description", description)
+            .add("os", os)
+            .add("mediaLink", mediaLink)
+            .add("logicalSizeInGB", logicalSizeInGB)
+            .add("attachedTo", attachedTo)
+            .add("sourceImage", sourceImage).toString();
    }
-
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java
index 5bde45e..ccbe9c8 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java
@@ -16,43 +16,39 @@
  */
 package org.jclouds.azurecompute.xml;
 
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
 import org.jclouds.azurecompute.domain.Disk.Attachment;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.SAXException;
 
 /**
  * @see <a href="http://msdn.microsoft.com/en-us/library/jj157176" >api</a>
  */
-public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Attachment> {
+final class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Attachment> {
+   private String hostedService;
+   private String deployment;
+   private String virtualMachine;
 
-   private StringBuilder currentText = new StringBuilder();
-   private Attachment.Builder builder = Attachment.builder();
+   private final StringBuilder currentText = new StringBuilder();
 
-   @Override
-   public Attachment getResult() {
-      try {
-         return builder.build();
-      } finally {
-         builder = Attachment.builder();
-      }
+   @Override public Attachment getResult() {
+      Attachment result = Attachment.create(hostedService, deployment, virtualMachine);
+      hostedService = deployment = virtualMachine = null; // handler could be called in a loop.
+      return result;
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
       if (qName.equals("HostedServiceName")) {
-         builder.hostedService(SaxUtils.currentOrNull(currentText));
+         hostedService = currentOrNull(currentText);
       } else if (qName.equals("DeploymentName")) {
-         builder.deployment(SaxUtils.currentOrNull(currentText));
+         deployment = currentOrNull(currentText);
       } else if (qName.equals("RoleName")) {
-         builder.role(SaxUtils.currentOrNull(currentText));
+         virtualMachine = currentOrNull(currentText);
       }
-      currentText = new StringBuilder();
+      currentText.setLength(0);
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       currentText.append(ch, start, length);
    }
-
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
index 3d933b2..0cc62c6 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
@@ -16,92 +16,97 @@
  */
 package org.jclouds.azurecompute.xml;
 
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
 import java.net.URI;
-import javax.inject.Inject;
+
 import org.jclouds.azurecompute.domain.Disk;
+import org.jclouds.azurecompute.domain.Disk.Attachment;
 import org.jclouds.azurecompute.domain.OSType;
 import org.jclouds.http.functions.ParseSax;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
 
 /**
  * @see <a href="http://msdn.microsoft.com/en-us/library/jj157176" >api</a>
  */
-public class DiskHandler extends
-		ParseSax.HandlerForGeneratedRequestWithResult<Disk> {
-
-	private final AttachmentHandler attachmentHandler;
-
-	@Inject
-	private DiskHandler(AttachmentHandler attachmentHandler) {
-		this.attachmentHandler = attachmentHandler;
-	}
+final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Disk> {
+   private String name;
+   private String location;
+   private String affinityGroup;
+   private String description;
+   private OSType os;
+   private URI mediaLink;
+   private Integer logicalSizeInGB;
+   private Attachment attachedTo;
+   private String sourceImage;
 
-	private StringBuilder currentText = new StringBuilder();
-	private Disk.Builder builder = Disk.builder();
+   private boolean inAttachment;
+   private final AttachmentHandler attachmentHandler = new AttachmentHandler();
+   private final StringBuilder currentText = new StringBuilder();
 
-	private boolean inAttachment;
+   @Override public Disk getResult() {
+      Disk result = Disk.create(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB,
+            attachedTo, sourceImage);
+      resetState(); // handler is called in a loop.
+      return result;
+   }
 
-	@Override
-	public Disk getResult() {
-		try {
-			return builder.build();
-		} finally {
-			builder = Disk.builder();
-		}
-	}
+   private void resetState() {
+      name = location = affinityGroup = description = sourceImage = null;
+      os = null;
+      mediaLink = null;
+      logicalSizeInGB = null;
+      attachedTo = null;
+   }
 
-	@Override
-	public void startElement(String uri, String localName, String qName,
-			Attributes attributes) throws SAXException {
-		if (equalsOrSuffix(qName, "AttachedTo")) {
-			inAttachment = true;
-		}
-	}
+   @Override public void startElement(String uri, String localName, String qName, Attributes attributes) {
+      if (qName.equals("AttachedTo")) {
+         inAttachment = true;
+      }
+   }
 
-	@Override
-	public void endElement(String uri, String name, String qName)
-			throws SAXException {
-		if (equalsOrSuffix(qName, "AttachedTo")) {
-			builder.attachedTo(attachmentHandler.getResult());
-			inAttachment = false;
-		} else if (inAttachment) {
-			attachmentHandler.endElement(uri, name, qName);
-		} else if (equalsOrSuffix(qName, "OS")) {
-			builder.os(OSType.fromValue(currentOrNull(currentText)));
-		} else if (equalsOrSuffix(qName, "Name")) {
-			builder.name(currentOrNull(currentText));
-		} else if (equalsOrSuffix(qName, "LogicalDiskSizeInGB")) {
-			String gb = currentOrNull(currentText);
-			if (gb != null)
-				builder.logicalSizeInGB(Integer.parseInt(gb));
-		} else if (equalsOrSuffix(qName, "Description")) {
-			builder.description(currentOrNull(currentText));
-		} else if (equalsOrSuffix(qName, "Location")) {
-			builder.location(currentOrNull(currentText));
-		} else if (equalsOrSuffix(qName, "AffinityGroup")) {
-			builder.affinityGroup(currentOrNull(currentText));
-		} else if (equalsOrSuffix(qName, "MediaLink")) {
-			String link = currentOrNull(currentText);
-			if (link != null)
-				builder.mediaLink(URI.create(link));
-		} else if (equalsOrSuffix(qName, "SourceImageName")) {
-			builder.sourceImage(currentOrNull(currentText));
-		} else if (equalsOrSuffix(qName, "Label")) {
-			builder.label(currentOrNull(currentText));
-		}
-		currentText = new StringBuilder();
-	}
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("AttachedTo")) {
+         attachedTo = attachmentHandler.getResult();
+         inAttachment = false;
+      } else if (inAttachment) {
+         attachmentHandler.endElement(ignoredUri, ignoredName, qName);
+      } else if (qName.equals("OS")) {
+         String osText = currentOrNull(currentText);
+         if (osText != null && osText.toUpperCase().equals("NULL")) {
+            os = null;
+         } else {
+            os = OSType.fromValue(currentOrNull(currentText));
+         }
+      } else if (qName.equals("Name")) {
+         name = currentOrNull(currentText);
+      } else if (qName.equals("LogicalDiskSizeInGB")) {
+         String gb = currentOrNull(currentText);
+         if (gb != null) {
+            logicalSizeInGB = Integer.parseInt(gb);
+         }
+      } else if (qName.equals("Description")) {
+         description = currentOrNull(currentText);
+      } else if (qName.equals("Location")) {
+         location = currentOrNull(currentText);
+      } else if (qName.equals("AffinityGroup")) {
+         affinityGroup = currentOrNull(currentText);
+      } else if (qName.equals("MediaLink")) {
+         String link = currentOrNull(currentText);
+         if (link != null) {
+            mediaLink = URI.create(link);
+         }
+      } else if (qName.equals("SourceImageName")) {
+         sourceImage = currentOrNull(currentText);
+      }
+      currentText.setLength(0);
+   }
 
-	@Override
-	public void characters(char ch[], int start, int length) {
-		if (inAttachment) {
-			attachmentHandler.characters(ch, start, length);
-		} else {
-			currentText.append(ch, start, length);
-		}
-	}
+   @Override public void characters(char ch[], int start, int length) {
+      if (inAttachment) {
+         attachmentHandler.characters(ch, start, length);
+      } else {
+         currentText.append(ch, start, length);
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
index fb6ea13..acdc7b5 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java
@@ -16,37 +16,26 @@
  */
 package org.jclouds.azurecompute.xml;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.inject.Inject;
 import java.util.List;
+
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Disk>> {
-
-   private final DiskHandler diskHandler;
 
-   private Builder<Disk> disks = ImmutableList.<Disk> builder();
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
 
+public final class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Disk>> {
    private boolean inDisk;
+   private final DiskHandler diskHandler = new DiskHandler();
+   private final Builder<Disk> disks = ImmutableList.builder();
 
-   @Inject
-   public ListDisksHandler(final DiskHandler diskHandler) {
-      this.diskHandler = diskHandler;
-   }
-
-   @Override
-   public List<Disk> getResult() {
+   @Override public List<Disk> getResult() {
       return disks.build();
    }
 
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
-      if (SaxUtils.equalsOrSuffix(qName, "Disk")) {
+   @Override public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("Disk")) {
          inDisk = true;
       }
       if (inDisk) {
@@ -54,8 +43,7 @@ public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithRes
       }
    }
 
-   @Override
-   public void endElement(String uri, String name, String qName) throws SAXException {
+   @Override public void endElement(String uri, String name, String qName) {
       if (qName.equals("Disk")) {
          inDisk = false;
          disks.add(diskHandler.getResult());
@@ -64,8 +52,7 @@ public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithRes
       }
    }
 
-   @Override
-   public void characters(char ch[], int start, int length) {
+   @Override public void characters(char ch[], int start, int length) {
       if (inDisk) {
          diskHandler.characters(ch, start, length);
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index 478b1b3..53531de 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -16,9 +16,11 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.Location;
@@ -27,10 +29,8 @@ import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertTrue;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
 
 @Test(groups = "live", testName = "DiskApiLiveTest")
 public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
@@ -44,73 +44,51 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
 
       locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(),
                new Function<Location, String>() {
-                  @Override
                   public String apply(Location in) {
                      return in.getName();
                   }
                }));
       images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function<Image, String>() {
-         @Override
          public String apply(Image in) {
             return in.name();
          }
       }));
    }
 
-   @Test
-   protected void testList() {
-      List<Disk> response = api().list();
-
-      for (Disk disk : response) {
+   public void testList() {
+      for (Disk disk : api().list()) {
          checkDisk(disk);
       }
    }
 
    private void checkDisk(Disk disk) {
-      checkNotNull(disk.getName(), "Name cannot be null for Disk %s", disk.getLabel());
-      checkNotNull(disk.getOS(), "OS cannot be null for Disk: %s", disk);
-      assertNotEquals(disk.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for Disk: " + disk);
+      assertNull(disk.name(), "Name cannot be null for: " + disk);
+      assertNull(disk.os(), "OS cannot be null for: " + disk);
+      assertNotEquals(disk.os(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for: " + disk);
 
-      checkNotNull(disk.getAttachedTo(), "While AttachedTo can be null for Disk, its Optional wrapper cannot: %s", disk);
-      if (disk.getAttachedTo().isPresent()) {
+      if (disk.attachedTo() != null) {
          // TODO: verify you can lookup the role
       }
 
-      checkNotNull(disk.getLogicalSizeInGB(),
-               "While LogicalSizeInGB can be null for Disk, its Optional wrapper cannot: %s", disk);
-
-      if (disk.getLogicalSizeInGB().isPresent())
-         assertTrue(disk.getLogicalSizeInGB().get() > 0, "LogicalSizeInGB should be positive, if set" + disk.toString());
-
-      checkNotNull(disk.getMediaLink(), "While MediaLink can be null for Disk, its Optional wrapper cannot: %s", disk);
-
-      if (disk.getMediaLink().isPresent())
-         assertTrue(ImmutableSet.of("http", "https").contains(disk.getMediaLink().get().getScheme()),
-                  "MediaLink should be an http(s) url" + disk.toString());
-
-      checkNotNull(disk.getLabel(), "While Label can be null for Disk, its Optional wrapper cannot: %s",
-               disk);
+      if (disk.logicalSizeInGB() != null) {
+         assertTrue(disk.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + disk);
+      }
 
-      checkNotNull(disk.getDescription(), "While Description can be null for Disk, its Optional wrapper cannot: %s",
-               disk);
+      if (disk.mediaLink() != null) {
+         assertTrue(ImmutableSet.of("http", "https").contains(disk.mediaLink().getScheme()),
+               "MediaLink should be an http(s) url" + disk);
+      }
 
-      checkNotNull(disk.getLocation(), "While Location can be null for Disk, its Optional wrapper cannot: %s", disk);
-      if (disk.getLocation().isPresent()) {
-         assertTrue(locations.contains(disk.getLocation().get()),
-                  "Location not in " + locations + " :" + disk.toString());
+      if (disk.location() != null) {
+         assertTrue(locations.contains(disk.location()), "Location not in " + locations + " :" + disk);
       }
 
-      checkNotNull(disk.getSourceImage(), "While SourceImage can be null for Disk, its Optional wrapper cannot: %s",
-               disk);
-      if (disk.getSourceImage().isPresent()) {
-         assertTrue(images.contains(disk.getSourceImage().get()),
-                  "SourceImage not in " + images + " :" + disk.toString());
+      if (disk.sourceImage() != null) {
+         assertTrue(images.contains(disk.sourceImage()), "SourceImage not in " + images + " :" + disk);
       }
 
-      checkNotNull(disk.getAffinityGroup(),
-               "While AffinityGroup can be null for Disk, its Optional wrapper cannot: %s", disk);
-      if (disk.getAffinityGroup().isPresent()) {
-         // TODO: list getAffinityGroups and check if there
+      if (disk.affinityGroup() != null) {
+         // TODO: list affinityGroups and check if there
       }
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java
index c6fab15..656428c 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java
@@ -16,13 +16,16 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.parse.ListDisksTest;
+import org.jclouds.azurecompute.xml.ListDisksHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "DiskApiMockTest")
 public class DiskApiMockTest extends BaseAzureComputeApiMockTest {
@@ -34,7 +37,7 @@ public class DiskApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DiskApi api = api(server.getUrl("/")).getDiskApi();
 
-         assertThat(api.list()).containsExactlyElementsOf(ListDisksTest.expected());
+         assertEquals(api.list(), ListDisksHandlerTest.expected());
 
          assertSent(server, "GET", "/services/disks");
       } finally {
@@ -49,7 +52,7 @@ public class DiskApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DiskApi api = api(server.getUrl("/")).getDiskApi();
 
-         assertThat(api.list()).isEmpty();
+         assertTrue(api.list().isEmpty());
 
          assertSent(server, "GET", "/services/disks");
       } finally {
@@ -64,7 +67,7 @@ public class DiskApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DiskApi api = api(server.getUrl("/")).getDiskApi();
 
-         assertThat(api.delete("my-disk")).isEqualTo("request-1");
+         assertEquals(api.delete("my-disk"), "request-1");
 
          assertSent(server, "DELETE", "/services/disks/my-disk");
       } finally {
@@ -79,7 +82,7 @@ public class DiskApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DiskApi api = api(server.getUrl("/")).getDiskApi();
 
-         assertThat(api.delete("my-disk")).isNull();
+         assertNull(api.delete("my-disk"));
 
          assertSent(server, "DELETE", "/services/disks/my-disk");
       } finally {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java
deleted file mode 100644
index 390b007..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.azurecompute.parse;
-
-import com.google.common.collect.ImmutableSet;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.List;
-import java.util.Set;
-import org.jclouds.azurecompute.domain.Disk;
-import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.OSType;
-import org.jclouds.azurecompute.xml.ListDisksHandler;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "ListDisksTest")
-public class ListDisksTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/disks.xml");
-
-      Set<Disk> expected = expected();
-
-      ListDisksHandler handler = injector.getInstance(ListDisksHandler.class);
-      List<Disk> result = factory.create(handler).parse(is);
-
-      assertEquals(result.toString(), expected.toString());
-
-   }
-
-   public static Set<Disk> expected() {
-
-      return ImmutableSet.<Disk>builder()
-                         .add(Disk.builder()
-                                     .os(OSType.LINUX)
-                                     .location("West Europe")
-                                     .logicalSizeInGB(30)
-                                     .mediaLink(URI.create("http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd"))
-                                     .name("testimage2-testimage2-0-20120817095145")
-                                     .sourceImage("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd")
-                                     .build())
-                          .add(Disk.builder()
-                                     .attachedTo(Attachment.builder().deployment("neotysss").hostedService("neotysss").role("neotysss").build())
-                                     .os(OSType.WINDOWS)
-                                     .location("West Europe")
-                                     .logicalSizeInGB(30)
-                                     .mediaLink(URI.create("http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"))
-                                     .name("neotysss-neotysss-0-20120824091357")
-                                     .sourceImage("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd")
-                                     .build())
-                        .build();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
new file mode 100644
index 0000000..f263567
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.Disk;
+import org.jclouds.azurecompute.domain.Disk.Attachment;
+import org.jclouds.azurecompute.domain.OSType;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListDisksHandlerTest")
+public class ListDisksHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/disks.xml");
+      List<Disk> result = factory.create(new ListDisksHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<Disk> expected() {
+      return ImmutableList.of( //
+            Disk.create( //
+                  "testimage2-testimage2-0-20120817095145", // name
+                  "West Europe", // location
+                  null, // affinityGroup
+                  null, //description
+                  OSType.LINUX, // os
+                  URI.create("http://blobs/vhds/testimage2-testimage2-2012-08-17.vhd"), // mediaLink
+                  30, // logicalSizeInGB
+                  null, // attachedTo
+                  "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd" // sourceImage
+            ), Disk.create( //
+                  "neotysss-neotysss-0-20120824091357", // name
+                  "West Europe", // location
+                  null, // affinityGroup
+                  null, //description
+                  OSType.WINDOWS, // os
+                  URI.create("http://blobs/disks/neotysss/MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd"), // mediaLink
+                  30, // logicalSizeInGB
+                  Attachment.create("neotysss", "neotysss", "neotysss"), // attachedTo
+                  "MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd" // sourceImage
+            ));
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/615c745e/azurecompute/src/test/resources/disks.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/disks.xml b/azurecompute/src/test/resources/disks.xml
index afae399..2e9b453 100644
--- a/azurecompute/src/test/resources/disks.xml
+++ b/azurecompute/src/test/resources/disks.xml
@@ -3,7 +3,7 @@
         <OS>Linux</OS>
         <Location>West Europe</Location>
         <LogicalDiskSizeInGB>30</LogicalDiskSizeInGB>
-        <MediaLink>http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd</MediaLink>
+        <MediaLink>http://blobs/vhds/testimage2-testimage2-2012-08-17.vhd</MediaLink>
         <Name>testimage2-testimage2-0-20120817095145</Name>
         <SourceImageName>OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd</SourceImageName>
     </Disk>
@@ -16,8 +16,8 @@
         <OS>Windows</OS>
         <Location>West Europe</Location>
         <LogicalDiskSizeInGB>30</LogicalDiskSizeInGB>
-        <MediaLink>http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink>
+        <MediaLink>http://blobs/disks/neotysss/MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd</MediaLink>
         <Name>neotysss-neotysss-0-20120824091357</Name>
-        <SourceImageName>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</SourceImageName>
+        <SourceImageName>MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd</SourceImageName>
     </Disk>
 </Disks>