Просмотр исходного кода

ZF-6717: Update to Ec2 Component to be API version 2009-04-04 and unit tests.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16148 44c647ce-9c0f-0410-b52a-842ac1e357ba
sidhighwind 16 лет назад
Родитель
Сommit
dfde7c1ce6

+ 13 - 14
library/Zend/Service/Amazon/Ec2/Abstract.php

@@ -40,27 +40,27 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
     /**
      * The HTTP query server
      */
-    const EC2_ENDPOINT = 'ec2.amazonaws.com';
+    protected $_ec2Endpoint = 'ec2.amazoneaws.com';
 
     /**
      * The API version to use
      */
-    const EC2_API_VERSION = '2008-12-01';
+    protected $_ec2ApiVersion = '2009-04-04';
 
     /**
      * Signature Version
      */
-    const EC2_SIGNATURE_VERSION = '2';
+    protected $_ec2SignatureVersion = '2';
 
     /**
      * Signature Encoding Method
      */
-    const EC2_SIGNATURE_METHOD = 'HmacSHA256';
+    protected $_ec2SignatureMethod = 'HmacSHA256';
 
     /**
      * Period after which HTTP request will timeout in seconds
      */
-    const HTTP_TIMEOUT = 10;
+    protected $_httpTimeout = 10;
 
     /**
      * Sends a HTTP request to the queue service using Zend_Http_Client
@@ -71,17 +71,17 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
      */
     protected function sendRequest(array $params = array())
     {
-        $url = 'https://' . $this->_getRegion() . self::EC2_ENDPOINT . '/';
+        $url = 'https://' . $this->_getRegion() . $this->_ec2Endpoint . '/';
 
         $params = $this->addRequiredParameters($params);
 
         try {
             /* @var $request Zend_Http_Client */
             $request = self::getHttpClient();
-			$request->resetParameters();
+            $request->resetParameters();
 
             $request->setConfig(array(
-                'timeout' => self::HTTP_TIMEOUT
+                'timeout' => $this->_httpTimeout
             ));
 
             $request->setUri($url);
@@ -95,7 +95,6 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
             $message = 'Error in request to AWS service: ' . $zhce->getMessage();
             throw new Zend_Service_Amazon_Ec2_Exception($message, $zhce->getCode());
         }
-
         $response = new Zend_Service_Amazon_Ec2_Response($httpResponse);
         $this->checkForErrors($response);
 
@@ -124,10 +123,10 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
     protected function addRequiredParameters(array $parameters)
     {
         $parameters['AWSAccessKeyId']   = $this->_getAccessKey();
-        $parameters['SignatureVersion'] = self::EC2_SIGNATURE_VERSION;
+        $parameters['SignatureVersion'] = $this->_ec2SignatureVersion;
         $parameters['Expires']          = gmdate('c');
-        $parameters['Version']          = self::EC2_API_VERSION;
-        $parameters['SignatureMethod']  = self::EC2_SIGNATURE_METHOD;
+        $parameters['Version']          = $this->_ec2ApiVersion;
+        $parameters['SignatureMethod']  = $this->_ec2SignatureMethod;
         $parameters['Signature']        = $this->signParameters($parameters);
 
         return $parameters;
@@ -156,7 +155,7 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
     protected function signParameters(array $paramaters)
     {
         $data = "POST\n";
-        $data .= $this->_getRegion() . self::EC2_ENDPOINT . "\n";
+        $data .= $this->_getRegion() . $this->_ec2Endpoint . "\n";
         $data .= "/\n";
 
         uksort($paramaters, 'strcmp');
@@ -198,4 +197,4 @@ abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abst
         }
 
     }
-}
+}

+ 351 - 0
library/Zend/Service/Amazon/Ec2/CloudWatch.php

@@ -0,0 +1,351 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Amazon
+ * @subpackage Ec2
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
+
+/**
+ * An Amazon EC2 interface that allows yout to run, terminate, reboot and describe Amazon
+ * Ec2 Instances.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Amazon
+ * @subpackage Ec2
+ * @copyright  Copyright (c) 22005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Service_Amazon_Ec2_CloudWatch extends Zend_Service_Amazon_Ec2_Abstract
+{
+    /**
+     * The HTTP query server
+     */
+    protected $_ec2Endpoint = 'monitoring.amazonaws.com';
+
+    /**
+     * The API version to use
+     */
+    protected $_ec2ApiVersion = '2009-05-15';
+
+    /**
+     * XML Namespace for the CloudWatch Stuff
+     */
+    protected $_xmlNamespace = 'http://monitoring.amazonaws.com/doc/2009-05-15/';
+
+    /**
+     * The following metrics are available from each EC2 instance.
+     *
+     * CPUUtilization: The percentage of allocated EC2 compute units that are
+     *  currently in use on the instance. This metric identifies the processing
+     *  power required to run an application upon a selected instance.
+     *
+     * NetworkIn: The number of bytes received on all network interfaces by
+     *  the instance. This metric identifies the volume of incoming network
+     *  traffic to an application on a single instance.
+     *
+     * NetworkOut: The number of bytes sent out on all network interfaces
+     *  by the instance. This metric identifies the volume of outgoing network
+     *  traffic to an application on a single instance.
+     *
+     * DiskWriteOps: Completed write operations to all hard disks available to
+     *  the instance. This metric identifies the rate at which an application
+     *  writes to a hard disk. This can be used to determine the speed in which
+     *  an application saves data to a hard disk.
+     *
+     * DiskReadBytes: Bytes read from all disks available to the instance. This
+     *  metric is used to determine the volume of the data the application reads
+     *  from the hard disk of the instance. This can be used to determine the
+     *  speed of the application for the customer.
+     *
+     * DiskReadOps: Completed read operations from all disks available to the
+     *  instances. This metric identifies the rate at which an application reads
+     *  a disk. This can be used to determine the speed in which an application
+     *  reads data from a hard disk.
+     *
+     * DiskWriteBytes: Bytes written to all disks available to the instance. This
+     *  metric is used to determine the volume of the data the application writes
+     *  onto the hard disk of the instance. This can be used to determine the speed
+     *  of the application for the customer.
+     *
+     * Latency: Time taken between a request and the corresponding response as seen
+     *  by the load balancer.
+     *
+     * RequestCount: The number of requests processed by the LoadBalancer.
+     *
+     * HealthyHostCount: The number of healthy instances. Both Load Balancing dimensions,
+     *  LoadBalancerName and AvailabilityZone, should be specified when retreiving
+     *  HealthyHostCount.
+     *
+     * UnHealthyHostCount: The number of unhealthy instances. Both Load Balancing dimensions,
+     *  LoadBalancerName and AvailabilityZone, should be specified when retreiving
+     *  UnHealthyHostCount.
+     *
+     * Amazon CloudWatch data for a new EC2 instance becomes available typically
+     * within one minute of the end of the first aggregation period for the new
+     * instance. You can use the currently available dimensions for EC2 instances
+     * along with these metrics in order to refine the slice of data you want returned,
+     * such as metric CPUUtilization and dimension ImageId to get all CPUUtilization
+     * data for instances using the specified AMI.
+     *
+     * @var array
+     */
+    protected $_validMetrics = array('CPUUtilization', 'NetworkIn', 'NetworkOut',
+                                    'DiskWriteOps', 'DiskReadBytes', 'DiskReadOps',
+                                    'DiskWriteBytes', 'Latency', 'RequestCount',
+                                    'HealthyHostCount', 'UnHealthyHostCount');
+
+    /**
+     * Amazon CloudWatch not only aggregates the raw data coming in, it also computes
+     * several statistics on the data. The following table lists the statistics that you can request:
+     *
+     * Minimum: The lowest value observed during the specified period. This can be used to
+     *  determine low volumes of activity for your application.
+     *
+     * Maximum: The highest value observed during the specified period. You can use this to
+     *  determine high volumes of activity for your application.
+     *
+     * Sum: The sum of all values received (if appropriate, for example a rate would not be
+     *  summed, but a number of items would be). This statistic is useful for determining
+     *  the total volume of a metric.
+     *
+     * Average: The Average of all values received during the specified period. By comparing
+     *  this statistic with the minimum and maximum statistics, you can determine the full
+     *  scope of a metric and how close the average use is to the minimum and the maximum.
+     *  This will allow you to increase or decrease your resources as needed.
+     *
+     * Samples: The count (number) of measures used. This statistic is always returned to
+     *  show the user the size of the dataset collected. This will allow the user to properly
+     *  weight the data.
+     *
+     * Statistics are computed within a period you specify, such as all CPUUtilization within a
+     * five minute period. At a minimum, all data is aggregated into one minute intervals. This
+     * is the minimum resolution of the data. It is this data that can be aggregated into larger
+     * periods of time that you request.
+     *
+     * Aggregate data is generally available from the service within one minute from the end of the
+     * aggregation period. Delays in data propagation might cause late or partially late data in
+     * some cases. If your data is delayed, you should check the service’s Health Dashboard for
+     * any current operational issues with either Amazon CloudWatch or the services collecting
+     * the data, such as EC2 or Elastic Load Balancing.
+     *
+     * @var array
+     */
+    protected $_validStatistics = array('Average', 'Maximum', 'Minimum', 'Samples', 'Sum');
+
+    /**
+     * Valid Dimention Keys for getMetricStatistics
+     *
+     * ImageId: This dimension filters the data you request for all instances running
+     *  this EC2 Amazon Machine Image (AMI).
+     *
+     * AvailabilityZone: This dimension filters the data you request for all instances
+     *  running in that EC2 Availability Zone.
+     *
+     * AutoScalingGroupName: This dimension filters the data you request for all instances
+     *  in a specified capacity group. An AutoScalingGroup is a collection of instances
+     *  defined by customers of the Auto Scaling service. This dimension is only available
+     *  for EC2 metrics when the instances are in such an AutoScalingGroup.
+     *
+     * InstanceId: This dimension filters the data you request for only the identified
+     *  instance. This allows a user to pinpoint an exact instance from which to monitor data.
+     *
+     * InstanceType: This dimension filters the data you request for all instances running
+     *  with this specified instance type. This allows a user to catagorize his data by the
+     *  type of instance running. For example, a user might compare data from an m1.small instance
+     *  and an m1.large instance to determine which has the better business value for his application.
+     *
+     * LoadBalancerName: This dimension filters the data you request for the specified LoadBalancer
+     *  name. A LoadBalancer is represented by a DNS name and provides the single destination to
+     *  which all requests intended for your application should be directed. This metric allows
+     *  you to examine data from all instances connected to a single LoadBalancer.
+     *
+     * @var array
+     */
+    protected $_validDimensionsKeys = array('ImageId', 'AvailabilityZone', 'AutoScalingGroupName',
+                                            'InstanceId', 'InstanceType', 'LoadBalancerName');
+
+    /**
+     * Returns data for one or more statistics of given a metric
+     *
+     * Note:
+     * The maximum number of datapoints that the Amazon CloudWatch service will
+     * return in a single GetMetricStatistics request is 1,440. If a request is
+     * made that would generate more datapoints than this amount, Amazon CloudWatch
+     * will return an error. You can alter your request by narrowing the time range
+     * (StartTime, EndTime) or increasing the Period in your single request. You may
+     * also get all of the data at the granularity you originally asked for by making
+     * multiple requests with adjacent time ranges.
+     *
+     * @param array $options            The options you want to get statistics for:
+     *                                  ** Required **
+     *                                  MeasureName: The measure name that corresponds to
+     *                                      the measure for the gathered metric. Valid EC2 Values are
+     *                                      CPUUtilization, NetworkIn, NetworkOut, DiskWriteOps
+     *                                      DiskReadBytes, DiskReadOps, DiskWriteBytes. Valid Elastic
+     *                                      Load Balancing Metrics are Latency, RequestCount, HealthyHostCount
+     *                                      UnHealthyHostCount
+     *                                  Statistics: The statistics to be returned for the given metric. Valid
+     *                                      values are Average, Maximum, Minimum, Samples, Sum.  You can specify
+     *                                      this as a string or as an array of values.  If you don't specify one
+     *                                      it will default to Average instead of failing out.  If you specify an incorrect
+     *                                      option it will just skip it.
+     *                                  ** Optional **
+     *                                  Dimensions: Amazon CloudWatch allows you to specify one Dimension to further filter
+     *                                      metric data on. If you don't specify a dimension, the service returns the aggregate
+     *                                      of all the measures with the given measure name and time range.
+     *                                  Unit: The standard unit of Measurement for a given Measure. Valid Values: Seconds,
+     *                                      Percent, Bytes, Bits, Count, Bytes/Second, Bits/Second, Count/Second, and None
+     *                                      Constraints: When using count/second as the unit, you should use Sum as the statistic
+     *                                      instead of Average. Otherwise, the sample returns as equal to the number of requests
+     *                                      instead of the number of 60-second intervals. This will cause the Average to
+     *                                      always equals one when the unit is count/second.
+     *                                  StartTime: The timestamp of the first datapoint to return, inclusive. For example,
+     *                                      2008-02-26T19:00:00+00:00. We round your value down to the nearest minute.
+     *                                      You can set your start time for more than two weeks in the past. However,
+     *                                      you will only get data for the past two weeks. (in ISO 8601 format)
+     *                                      Constraints: Must be before EndTime
+     *                                  EndTime: The timestamp to use for determining the last datapoint to return. This is
+     *                                      the last datapoint to fetch, exclusive. For example, 2008-02-26T20:00:00+00:00.
+     *                                      (in ISO 8601 format)
+     */
+    public function getMetricStatistics(array $options)
+    {
+        $_usedStatistics = array();
+
+        $params = array();
+        $params['Action'] = 'GetMetricStatistics';
+
+        if (!isset($options['Period'])) {
+            $options['Period'] = 60;
+        }
+        if (!isset($options['Namespace'])) {
+            $options['Namespace'] = 'AWS/EC2';
+        }
+
+        if (!isset($options['MeasureName']) || !in_array($options['MeasureName'], $this->_validMetrics, true)) {
+            throw new Zend_Service_Amazon_Ec2_Exception('Invalid Metric Type: ' . $options['MeasureName']);
+        }
+
+        if(!isset($options['Statistics'])) {
+            $options['Statistics'][] = 'Average';
+        } elseif(!is_array($options['Statistics'])) {
+            $options['Statistics'][] = $options['Statistics'];
+        }
+
+        foreach($options['Statistics'] as $k=>$s) {
+            if(!in_array($s, $this->_validStatistics, true)) continue;
+            $options['Statistics.member.' . ($k+1)] = $s;
+            $_usedStatistics[] = $s;
+        }
+        unset($options['Statistics']);
+
+        if(isset($options['StartTime'])) {
+            if(!is_numeric($options['StartTime'])) $options['StartTime'] = strtotime($options['StartTime']);
+            $options['StartTime'] = gmdate('c', $options['StartTime']);
+        } else {
+            $options['StartTime'] = gmdate('c', strtotime('-1 hour'));
+        }
+
+        if(isset($options['EndTime'])) {
+            if(!is_numeric($options['EndTime'])) $options['EndTime'] = strtotime($options['EndTime']);
+            $options['EndTime'] = gmdate('c', $options['EndTime']);
+        } else {
+            $options['EndTime'] = gmdate('c');
+        }
+
+        if(isset($options['Dimensions'])) {
+            $x = 1;
+            foreach($options['Dimensions'] as $dimKey=>$dimVal) {
+                if(!in_array($dimKey, $this->_validDimensionsKeys, true)) continue;
+                $options[$dimKey . '.member.' . $x++] = $dimVal;
+            }
+        }
+
+        $params = array_merge($params, $options);
+
+        $response = $this->sendRequest($params);
+        $response->setNamespace($this->_xmlNamespace);
+
+        $xpath = $response->getXPath();
+        $nodes = $xpath->query('//ec2:GetMetricStatisticsResult/ec2:Datapoints/ec2:member');
+
+        $return = array();
+        $return['label'] = $xpath->evaluate('string(//ec2:GetMetricStatisticsResult/ec2:Label/text())');
+        foreach ( $nodes as $node ) {
+            $item = array();
+
+            $item['Timestamp'] = $xpath->evaluate('string(ec2:Timestamp/text())', $node);
+            $item['Unit'] = $xpath->evaluate('string(ec2:Unit/text())', $node);
+            $item['Samples'] = $xpath->evaluate('string(ec2:Samples/text())', $node);
+            foreach($_usedStatistics as $us) {
+                $item[$us] = $xpath->evaluate('string(ec2:' . $us . '/text())', $node);
+            }
+
+            $return['datapoints'][] = $item;
+            unset($item, $node);
+        }
+
+        return $return;
+
+    }
+
+    /**
+     * Return the Metrics that are aviable for your current monitored servers
+     *
+     * @param string $nextToken     This call returns a list of up to 500 valid metrics
+     *                              for which there is recorded data available to a you and
+     *                              a NextToken string that can be used to query for the next
+     *                              set of results
+     * @return array
+     */
+    public function listMetrics($nextToken = null)
+    {
+        $params = array();
+        $params['Action'] = 'ListMetrics';
+        if (!empty($nextToken)) {
+            $params['NextToken'] = $nextToken;
+        }
+
+        $response = $this->sendRequest($params);
+        $response->setNamespace($this->_xmlNamespace);
+
+        $xpath = $response->getXPath();
+        $nodes = $xpath->query('//ec2:ListMetricsResult/ec2:Metrics/ec2:member');
+
+        $return = array();
+        foreach ( $nodes as $node ) {
+            $item = array();
+
+            $item['MeasureName'] = $xpath->evaluate('string(ec2:MeasureName/text())', $node);
+            $item['Namespace'] = $xpath->evaluate('string(ec2:Namespace/text())', $node);
+            $item['Deminsions']['name'] = $xpath->evaluate('string(ec2:Dimensions/ec2:member/ec2:Name/text())', $node);
+            $item['Deminsions']['value'] = $xpath->evaluate('string(ec2:Dimensions/ec2:member/ec2:Value/text())', $node);
+
+            if (empty($item['Deminsions']['name'])) {
+                $item['Deminsions'] = array();
+            }
+
+            $return[] = $item;
+            unset($item, $node);
+        }
+
+        return $return;
+    }
+}

+ 93 - 11
library/Zend/Service/Amazon/Ec2/Instance.php

@@ -99,6 +99,7 @@ class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
      *                                                ramdiskId string      The ID of the RAM disk with which to launch the instance.
      *                                                blockDeviceVirtualName string     Specifies the virtual name to map to the corresponding device name. For example: instancestore0
      *                                                blockDeviceName string            Specifies the device to which you are mapping a virtual name. For example: sdb
+     *                                                monitor boolean               Turn on CloudWatch Monitoring for an instance.
      * @return array
      */
     public function run(array $options)
@@ -161,6 +162,10 @@ class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
             $params['BlockDeviceMapping.n.DeviceName'] = $options['blockDeviceName'];
         }
 
+        if(isset($options['monitor']) && $options['monitor'] === true) {
+            $params['Monitoring.Enabled'] = true;
+        }
+
         $response = $this->sendRequest($params);
         $xpath = $response->getXPath();
 
@@ -232,29 +237,31 @@ class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
         }
 
         $response = $this->sendRequest($params);
+
         $xpath = $response->getXPath();
 
         $nodes = $xpath->query('//ec2:reservationSet/ec2:item');
 
         $return = array();
+        $return['instances'] = array();
 
         foreach($nodes as $node) {
-            $return['reservationId'] = $xpath->evaluate('string(ec2:reservationId/text())', $node);
-            $return['ownerId'] = $xpath->evaluate('string(ec2:ownerId/text())', $node);
+            if($xpath->evaluate('string(ec2:instancesSet/ec2:item/ec2:instanceState/ec2:code/text())', $node) == 48 && $ignoreTerminated) continue;
+            $item = array();
+
+            $item['reservationId'] = $xpath->evaluate('string(ec2:reservationId/text())', $node);
+            $item['ownerId'] = $xpath->evaluate('string(ec2:ownerId/text())', $node);
 
             $gs = $xpath->query('ec2:groupSet/ec2:item', $node);
             foreach($gs as $gs_node) {
-                $return['groupSet'][] = $xpath->evaluate('string(ec2:groupId/text())', $gs_node);
+                $item['groupSet'][] = $xpath->evaluate('string(ec2:groupId/text())', $gs_node);
                 unset($gs_node);
             }
             unset($gs);
 
             $is = $xpath->query('ec2:instancesSet/ec2:item', $node);
-            $return['instances'] = array();
-            foreach($is as $is_node) {
-                if($xpath->evaluate('string(ec2:instanceState/ec2:code/text())', $is_node) == 48 && $ignoreTerminated) continue;
 
-                $item = array();
+            foreach($is as $is_node) {
 
                 $item['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $is_node);
                 $item['imageId'] = $xpath->evaluate('string(ec2:imageId/text())', $is_node);
@@ -269,11 +276,13 @@ class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
                 $item['availabilityZone'] = $xpath->evaluate('string(ec2:placement/ec2:availabilityZone/text())', $is_node);
                 $item['kernelId'] = $xpath->evaluate('string(ec2:kernelId/text())', $is_node);
                 $item['ramediskId'] = $xpath->evaluate('string(ec2:ramediskId/text())', $is_node);
+                $item['amiLaunchIndex'] = $xpath->evaluate('string(ec2:amiLaunchIndex/text())', $is_node);
+                $item['monitoringState'] = $xpath->evaluate('string(ec2:monitoring/ec2:state/text())', $is_node);
 
-                $return['instances'][] = $item;
-                unset($item);
                 unset($is_node);
             }
+            $return['instances'][] = $item;
+            unset($item);
             unset($is);
         }
 
@@ -297,9 +306,8 @@ class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
 
         $return = array();
 
-        foreach($arrInstances['instances'] as $k => $instance) {
+        foreach($arrInstances['instances'] as $instance) {
             if($instance['imageId'] !== $imageId) continue;
-            $instance['groupSet'] = $arrInstances['groupSet'][$k];
             $return[] = $instance;
         }
 
@@ -441,4 +449,78 @@ class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
         return false;
     }
 
+    /**
+    * Turn on Amazon CloudWatch Monitoring for an instance or a list of instances
+    *
+    * @param array|string $instanceId           The instance or list of instances you want to enable monitoring for
+    * @return array
+    */
+    public function monitor($instanceId)
+    {
+        $params = array();
+        $params['Action'] = 'MonitorInstances';
+
+        if(is_array($instanceId) && !empty($instanceId)) {
+            foreach($instanceId as $k=>$name) {
+                $params['InstanceId.' . ($k+1)] = $name;
+            }
+        } elseif($instanceId) {
+            $params['InstanceId.1'] = $instanceId;
+        }
+
+        $response = $this->sendRequest($params);
+        $xpath = $response->getXPath();
+
+
+        $items = $xpath->query('//ec2:instancesSet/ec2:item');
+
+        $arrReturn = array();
+        foreach($items as $item) {
+            $i = array();
+            $i['instanceid'] = $xpath->evaluate('string(//ec2:instanceId/text())', $item);
+            $i['monitorstate'] = $xpath->evaluate('string(//ec2:monitoring/ec2:state/text())');
+            $arrReturn[] = $i;
+            unset($i);
+        }
+
+        return $arrReturn;
+    }
+    /**
+    * Turn off Amazon CloudWatch Monitoring for an instance or a list of instances
+    *
+    * @param array|string $instanceId           The instance or list of instances you want to disable monitoring for
+    * @return array
+    */
+    public function unmonitor($instanceId)
+    {
+        $params = array();
+        $params['Action'] = 'UnmonitorInstances';
+
+        if(is_array($instanceId) && !empty($instanceId)) {
+            foreach($instanceId as $k=>$name) {
+                $params['InstanceId.' . ($k+1)] = $name;
+            }
+        } elseif($instanceId) {
+            $params['InstanceId.1'] = $instanceId;
+        }
+
+        $response = $this->sendRequest($params);
+        $xpath = $response->getXPath();
+
+
+        $items = $xpath->query('//ec2:instancesSet/ec2:item');
+
+        $arrReturn = array();
+        foreach($items as $item) {
+            $i = array();
+            $i['instanceid'] = $xpath->evaluate('string(//ec2:instanceId/text())', $item);
+            $i['monitorstate'] = $xpath->evaluate('string(//ec2:monitoring/ec2:state/text())');
+            $arrReturn[] = $i;
+            unset($i);
+        }
+
+        return $arrReturn;
+    }
+
 }
+

+ 140 - 0
library/Zend/Service/Amazon/Ec2/Instance/Reserved.php

@@ -0,0 +1,140 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Amazon
+ * @subpackage Ec2
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
+
+/**
+ * Allows you to interface with the reserved instances on Amazon Ec2
+ *
+ * @category   Zend
+ * @package    Zend_Service_Amazon
+ * @subpackage Ec2
+ * @copyright  Copyright (c) 22005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Service_Amazon_Ec2_Instance_Reserved extends Zend_Service_Amazon_Ec2_Abstract
+{
+    /**
+     * Describes Reserved Instances that you purchased.
+     *
+     * @param string|array $instanceId        IDs of the Reserved Instance to describe.
+     * @return array
+     */
+    public function describeInstances($instanceId)
+    {
+        $params = array();
+        $params['Action'] = 'DescribeReservedInstances';
+
+        if(is_array($instanceId) && !empty($instanceId)) {
+            foreach($instanceId as $k=>$name) {
+                $params['ReservedInstancesId.' . ($k+1)] = $name;
+            }
+        } elseif($instanceId) {
+            $params['ReservedInstancesId.1'] = $instanceId;
+        }
+
+        $response = $this->sendRequest($params);
+
+        $xpath = $response->getXPath();
+        $items = $xpath->query('//ec2:reservedInstancesSet/ec2:item');
+
+        $return = array();
+        foreach($items as $item) {
+            $i = array();
+            $i['reservedInstancesId'] = $xpath->evaluate('string(ec2:reservedInstancesId/text())', $item);
+            $i['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $item);
+            $i['availabilityZone'] = $xpath->evaluate('string(ec2:availabilityZone/text())', $item);
+            $i['duration'] = $xpath->evaluate('string(ec2:duration/text())', $item);
+            $i['fixedPrice'] = $xpath->evaluate('string(ec2:fixedPrice/text())', $item);
+            $i['usagePrice'] = $xpath->evaluate('string(ec2:usagePrice/text())', $item);
+            $i['productDescription'] = $xpath->evaluate('string(ec2:productDescription/text())', $item);
+            $i['instanceCount'] = $xpath->evaluate('string(ec2:instanceCount/text())', $item);
+            $i['state'] = $xpath->evaluate('string(ec2:state/text())', $item);
+
+            $return[] = $i;
+            unset($i);
+        }
+
+        return $return;
+    }
+
+    /**
+     * Describes Reserved Instance offerings that are available for purchase.
+     * With Amazon EC2 Reserved Instances, you purchase the right to launch Amazon
+     * EC2 instances for a period of time (without getting insufficient capacity
+     * errors) and pay a lower usage rate for the actual time used.
+     *
+     * @return array
+     */
+    public function describeOfferings()
+    {
+        $params = array();
+        $params['Action'] = 'DescribeReservedInstancesOfferings';
+
+        $response = $this->sendRequest($params);
+
+        $xpath = $response->getXPath();
+        $items = $xpath->query('//ec2:reservedInstancesOfferingsSet/ec2:item');
+
+        $return = array();
+        foreach($items as $item) {
+            $i = array();
+            $i['reservedInstancesOfferingId'] = $xpath->evaluate('string(ec2:reservedInstancesOfferingId/text())', $item);
+            $i['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $item);
+            $i['availabilityZone'] = $xpath->evaluate('string(ec2:availabilityZone/text())', $item);
+            $i['duration'] = $xpath->evaluate('string(ec2:duration/text())', $item);
+            $i['fixedPrice'] = $xpath->evaluate('string(ec2:fixedPrice/text())', $item);
+            $i['usagePrice'] = $xpath->evaluate('string(ec2:usagePrice/text())', $item);
+            $i['productDescription'] = $xpath->evaluate('string(ec2:productDescription/text())', $item);
+
+            $return[] = $i;
+            unset($i);
+        }
+
+        return $return;
+    }
+
+    /**
+     * Purchases a Reserved Instance for use with your account. With Amazon EC2
+     * Reserved Instances, you purchase the right to launch Amazon EC2 instances
+     * for a period of time (without getting insufficient capacity errors) and
+     * pay a lower usage rate for the actual time used.
+     *
+     * @param string $offeringId            The offering ID of the Reserved Instance to purchase
+     * @param integer $intanceCount         The number of Reserved Instances to purchase.
+     * @return string                       The ID of the purchased Reserved Instances.
+     */
+    public function purchaseOffering($offeringId, $intanceCount = 1)
+    {
+        $params = array();
+        $params['Action'] = 'PurchaseReservedInstancesOffering';
+        $params['OfferingId.1'] = $offeringId;
+        $params['instanceCount.1'] = intval($intanceCount);
+
+        $response = $this->sendRequest($params);
+
+        $xpath = $response->getXPath();
+        $reservedInstancesId = $xpath->evaluate('string(//ec2:reservedInstancesId/text())');
+
+        return $reservedInstancesId;
+    }
+}

+ 192 - 0
library/Zend/Service/Amazon/Ec2/Instance/Windows.php

@@ -0,0 +1,192 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Amazon
+ * @subpackage Ec2
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
+
+/**
+ * Zend_Crypt_Hmac
+ */
+require_once 'Zend/Crypt/Hmac.php';
+
+/**
+ * Zend_Json
+ */
+require_once 'Zend/Json.php';
+
+/**
+ * An Amazon EC2 interface that allows yout to run, terminate, reboot and describe Amazon
+ * Ec2 Instances.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Amazon
+ * @subpackage Ec2
+ * @copyright  Copyright (c) 22005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Service_Amazon_Ec2_Instance_Windows extends Zend_Service_Amazon_Ec2_Abstract
+{
+    /**
+     * Bundles an Amazon EC2 instance running Windows
+     *
+     * @param string $instanceId        The instance you want to bundle
+     * @param string $s3Bucket          Where you want the ami to live on S3
+     * @param string $s3Prefix          The prefix you want to assign to the AMI on S3
+     * @param integer $uploadExpiration The expiration of the upload policy.  Amazon recommends 12 hours or longer.
+     *                                  This is based in nubmer of minutes. Default is 1440 minutes (24 hours)
+     * @return array                    containing the information on the new bundle operation
+     */
+    public function bundle($instanceId, $s3Bucket, $s3Prefix, $uploadExpiration = 1440)
+    {
+        $params = array();
+        $params['Action'] = 'BundleInstance';
+        $params['InstanceId'] = $instanceId;
+        $params['Storage.S3.AWSAccessKeyId'] = $this->_getAccessKey();
+        $params['Storage.S3.Bucket'] = $s3Bucket;
+        $params['Storage.S3.Prefix'] = $s3Prefix;
+        $uploadPolicy = $this->_getS3UploadPolicy($s3Bucket, $s3Prefix, $uploadExpiration);
+        $params['Storage.S3.UploadPolicy'] = $uploadPolicy;
+        $params['Storage.S3.UploadPolicySignature'] = $this->_signS3UploadPolicy($uploadPolicy);
+
+        $response = $this->sendRequest($params);
+
+        $xpath = $response->getXPath();
+
+        $return = array();
+        $return['instanceId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:instanceId/text())');
+        $return['bundleId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:bundleId/text())');
+        $return['state'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:state/text())');
+        $return['startTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:startTime/text())');
+        $return['updateTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:updateTime/text())');
+        $return['progress'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:progress/text())');
+        $return['storage']['s3']['bucket'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:bucket/text())');
+        $return['storage']['s3']['prefix'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:prefix/text())');
+
+        return $return;
+    }
+
+    /**
+     * Cancels an Amazon EC2 bundling operation
+     *
+     * @param string $bundleId          The ID of the bundle task to cancel
+     * @return array                    Information on the bundle task
+     */
+    public function cancelBundle($bundleId)
+    {
+        $params = array();
+        $params['Action'] = 'CancelBundleTask';
+        $params['BundleId'] = $bundleId;
+
+        $response = $this->sendRequest($params);
+
+        $xpath = $response->getXPath();
+
+        $return = array();
+        $return['instanceId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:instanceId/text())');
+        $return['bundleId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:bundleId/text())');
+        $return['state'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:state/text())');
+        $return['startTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:startTime/text())');
+        $return['updateTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:updateTime/text())');
+        $return['progress'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:progress/text())');
+        $return['storage']['s3']['bucket'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:bucket/text())');
+        $return['storage']['s3']['prefix'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:prefix/text())');
+
+        return $return;
+    }
+
+    /**
+     * Describes current bundling tasks
+     *
+     * @param string|array $bundleId            A single or a list of bundle tasks that you want
+     *                                          to find information for.
+     * @return array                            Information for the task that you requested
+     */
+    public function describeBundle($bundleId)
+    {
+        $params = array();
+        $params['Action'] = 'DescribeBundleTasks';
+
+        if(is_array($bundleId) && !empty($bundleId)) {
+            foreach($bundleId as $k=>$name) {
+                $params['bundleId.' . ($k+1)] = $name;
+            }
+        } elseif($bundleId) {
+            $params['bundleId.1'] = $bundleId;
+        }
+
+        $response = $this->sendRequest($params);
+
+        $xpath = $response->getXPath();
+
+        $items = $xpath->evaluate('//ec2:bundleInstanceTasksSet/ec2:item');
+        $return = array();
+
+        foreach($items as $item) {
+            $i = array();
+            $i['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $item);
+            $i['bundleId'] = $xpath->evaluate('string(ec2:bundleId/text())', $item);
+            $i['state'] = $xpath->evaluate('string(ec2:state/text())', $item);
+            $i['startTime'] = $xpath->evaluate('string(ec2:startTime/text())', $item);
+            $i['updateTime'] = $xpath->evaluate('string(ec2:updateTime/text())', $item);
+            $i['progress'] = $xpath->evaluate('string(ec2:progress/text())', $item);
+            $i['storage']['s3']['bucket'] = $xpath->evaluate('string(ec2:storage/ec2:S3/ec2:bucket/text())', $item);
+            $i['storage']['s3']['prefix'] = $xpath->evaluate('string(ec2:storage/ec2:S3/ec2:prefix/text())', $item);
+
+            $return[] = $i;
+            unset($i);
+        }
+
+
+        return $return;
+    }
+
+    /**
+     * Generates the S3 Upload Policy Information
+     *
+     * @param string $bucketName        Which bucket you want the ami to live in on S3
+     * @param string $prefix            The prefix you want to assign to the AMI on S3
+     * @param integer $expireInMinutes  The expiration of the upload policy.  Amazon recommends 12 hours or longer.
+     *                                  This is based in nubmer of minutes. Default is 1440 minutes (24 hours)
+     * @return string                   Base64 encoded string that is the upload policy
+     */
+    protected function _getS3UploadPolicy($bucketName, $prefix, $expireInMinutes = 1440)
+    {
+        $arrParams = array();
+        $arrParams['expiration'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", (time() + ($expireInMinutes * 60)));
+        $arrParams['conditions'][] = array('bucket' => $bucketName);
+        $arrParams['conditions'][] = array('acl' => 'ec2-bundle-read');
+        $arrParams['conditions'][] = array('starts-with', '$key', $prefix);
+
+        return base64_encode(Zend_Json::encode($arrParams));
+    }
+
+    /**
+     * Signed S3 Upload Policy
+     *
+     * @param string $policy            Base64 Encoded string that is the upload policy
+     * @return string                   SHA1 encoded S3 Upload Policy
+     */
+    protected function _signS3UploadPolicy($policy)
+    {
+        $hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA1', $policy, Zend_Crypt_Hmac::BINARY);
+        return $hmac;
+    }
+}

+ 24 - 3
library/Zend/Service/Amazon/Ec2/Response.php

@@ -33,7 +33,7 @@ class Zend_Service_Amazon_Ec2_Response {
     /**
      * XML namespace used for EC2 responses.
      */
-    const XML_NAMESPACE = 'http://ec2.amazonaws.com/doc/2008-12-01/';
+    protected $_xmlNamespace = 'http://ec2.amazonaws.com/doc/2009-04-04/';
 
     /**
      * The original HTTP response
@@ -96,7 +96,7 @@ class Zend_Service_Amazon_Ec2_Response {
             } else {
                 $this->_xpath = new DOMXPath($document);
                 $this->_xpath->registerNamespace('ec2',
-                    self::XML_NAMESPACE);
+                    $this->getNamespace());
             }
         }
 
@@ -136,4 +136,25 @@ class Zend_Service_Amazon_Ec2_Response {
 
         return $this->_document;
     }
-}
+
+    /**
+     * Return the current set XML Namespace.
+     *
+     * @return string
+     */
+    public function getNamespace()
+    {
+        return $this->_xmlNamespace;
+    }
+
+    /**
+     * Set a new XML Namespace
+     *
+     * @param string $namespace
+     */
+    public function setNamespace($namespace)
+    {
+        $this->_xmlNamespace = $namespace;
+    }
+
+}

+ 2 - 2
tests/Zend/Service/Amazon/Ec2/AvailabilityzonesTest.php

@@ -57,7 +57,7 @@ class Zend_Service_Amazon_Ec2_AvailabilityzonesTest extends PHPUnit_Framework_Te
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <availabilityZoneInfo>\r\n"
                     . "    <item>\r\n"
                     . "      <zoneName>us-east-1a</zoneName>\r\n"
@@ -84,7 +84,7 @@ class Zend_Service_Amazon_Ec2_AvailabilityzonesTest extends PHPUnit_Framework_Te
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <availabilityZoneInfo>\r\n"
                     . "    <item>\r\n"
                     . "      <zoneName>us-east-1a</zoneName>\r\n"

+ 182 - 0
tests/Zend/Service/Amazon/Ec2/CloudWatchTest.php

@@ -0,0 +1,182 @@
+<?php
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once 'Zend/Service/Amazon/Ec2/CloudWatch.php';
+require_once 'Zend/Http/Client.php';
+require_once 'Zend/Http/Client/Adapter/Test.php';
+
+/**
+ * Zend_Service_Amazon_Ec2_CloudWatch test case.
+ */
+class Zend_Service_Amazon_Ec2_CloudWatchTest extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * @var Zend_Service_Amazon_Ec2_CloudWatch
+     */
+    private $Zend_Service_Amazon_Ec2_CloudWatch;
+
+    /**
+     * Prepares the environment before running a test.
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->Zend_Service_Amazon_Ec2_CloudWatch = new Zend_Service_Amazon_Ec2_CloudWatch('access_key', 'secret_access_key');
+        $adapter = new Zend_Http_Client_Adapter_Test();
+        $client = new Zend_Http_Client(null, array(
+            'adapter' => $adapter
+        ));
+        $this->adapter = $adapter;
+        Zend_Service_Amazon_Ec2_CloudWatch::setHttpClient($client);
+    }
+
+    /**
+     * Cleans up the environment after running a test.
+     */
+    protected function tearDown()
+    {
+        unset($this->adapter);
+        $this->Zend_Service_Amazon_Ec2_CloudWatch = null;
+
+        parent::tearDown();
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_CloudWatch->getMetricStatistics()
+     */
+    public function testGetMetricStatistics()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<GetMetricStatisticsResponse xmlns=\"http://monitoring.amazonaws.com/doc/2009-05-15/\">\r\n"
+                    ."  <GetMetricStatisticsResult>\r\n"
+                    ."    <Datapoints>\r\n"
+                    ."      <member>\r\n"
+                    ."        <Timestamp>2009-06-16T23:57:00Z</Timestamp>\r\n"
+                    ."        <Unit>Bytes</Unit>\r\n"
+                    ."        <Samples>1.0</Samples>\r\n"
+                    ."        <Average>14838.0</Average>\r\n"
+                    ."      </member>\r\n"
+                    ."      <member>\r\n"
+                    ."        <Timestamp>2009-06-17T00:16:00Z</Timestamp>\r\n"
+                    ."        <Unit>Bytes</Unit>\r\n"
+                    ."        <Samples>1.0</Samples>\r\n"
+                    ."        <Average>18251.0</Average>\r\n"
+                    ."      </member>\r\n"
+                    ."    </Datapoints>\r\n"
+                    ."    <Label>NetworkIn</Label>"
+                    ."  </GetMetricStatisticsResult>\r\n"
+                    ."</GetMetricStatisticsResponse>\r\n";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_CloudWatch->getMetricStatistics(array('MeasureName' => 'NetworkIn', 'Statistics' => array('Average')));
+
+        $arrReturn = array(
+            'label'         => 'NetworkIn',
+            'datapoints'    => array(
+                array(
+                    'Timestamp'     => '2009-06-16T23:57:00Z',
+                    'Unit'          => 'Bytes',
+                    'Samples'       => '1.0',
+                    'Average'       => '14838.0',
+                ),
+                array(
+                    'Timestamp'     => '2009-06-17T00:16:00Z',
+                    'Unit'          => 'Bytes',
+                    'Samples'       => '1.0',
+                    'Average'       => '18251.0',
+                )
+            )
+        );
+
+        $this->assertSame($arrReturn, $return);
+
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_CloudWatch->listMetrics()
+     */
+    public function testListMetrics()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<ListMetricsResponse xmlns=\"http://monitoring.amazonaws.com/doc/2009-05-15/\">\r\n"
+                    ."  <ListMetricsResult>\r\n"
+                    ."    <Metrics>\r\n"
+                    ."      <member>\r\n"
+                    ."        <Dimensions>\r\n"
+                    ."          <member>\r\n"
+                    ."            <Name>InstanceId</Name>\r\n"
+                    ."            <Value>i-bec576d7</Value>\r\n"
+                    ."          </member>\r\n"
+                    ."        </Dimensions>\r\n"
+                    ."        <MeasureName>NetworkIn</MeasureName>\r\n"
+                    ."        <Namespace>AWS/EC2</Namespace>\r\n"
+                    ."      </member>\r\n"
+                    ."      <member>\r\n"
+                    ."        <Dimensions>\r\n"
+                    ."          <member>\r\n"
+                    ."            <Name>InstanceId</Name>\r\n"
+                    ."            <Value>i-bec576d7</Value>\r\n"
+                    ."          </member>\r\n"
+                    ."        </Dimensions>\r\n"
+                    ."        <MeasureName>CPUUtilization</MeasureName>\r\n"
+                    ."        <Namespace>AWS/EC2</Namespace>\r\n"
+                    ."      </member>\r\n"
+                    ."      <member>\r\n"
+                    ."        <Dimensions/>\r\n"
+                    ."        <MeasureName>NetworkIn</MeasureName>\r\n"
+                    ."        <Namespace>AWS/EC2</Namespace>\r\n"
+                    ."      </member>\r\n"
+                    ."    </Metrics>\r\n"
+                    ."  </ListMetricsResult>\r\n"
+                    ."</ListMetricsResponse>\r\n";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_CloudWatch->listMetrics();
+
+        $arrReturn = array(
+            array(
+                'MeasureName'   => 'NetworkIn',
+                'Namespace'     => 'AWS/EC2',
+                'Deminsions'    => array(
+                    'name'      => 'InstanceId',
+                    'value'     => 'i-bec576d7'
+                )
+            ),
+            array(
+                'MeasureName'   => 'CPUUtilization',
+                'Namespace'     => 'AWS/EC2',
+                'Deminsions'    => array(
+                    'name'      => 'InstanceId',
+                    'value'     => 'i-bec576d7'
+                )
+            ),
+            array(
+                'MeasureName'   => 'NetworkIn',
+                'Namespace'     => 'AWS/EC2',
+                'Deminsions'    => array()
+            )
+        );
+
+        $this->assertSame($arrReturn, $return);
+
+
+    }
+
+}
+

+ 12 - 12
tests/Zend/Service/Amazon/Ec2/EbsTest.php

@@ -54,7 +54,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<AttachVolumeResponse  xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<AttachVolumeResponse  xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <volumeId>vol-4d826724</volumeId>\r\n"
                     . "  <instanceId>i-6058a509</instanceId>\r\n"
                     . "  <device>/dev/sdh</device>\r\n"
@@ -88,7 +88,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<CreateSnapshotResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<CreateSnapshotResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <snapshotId>snap-78a54011</snapshotId>\r\n"
                     . "  <volumeId>vol-4d826724</volumeId>\r\n"
                     . "  <status>pending</status>\r\n"
@@ -122,7 +122,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<CreateVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<CreateVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <volumeId>vol-4d826724</volumeId>\r\n"
                     . "  <size>400</size>\r\n"
                     . "  <status>creating</status>\r\n"
@@ -157,7 +157,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<CreateVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<CreateVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <volumeId>vol-4d826724</volumeId>\r\n"
                     . "  <size>400</size>\r\n"
                     . "  <status>creating</status>\r\n"
@@ -194,7 +194,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DeleteSnapshotResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DeleteSnapshotResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</DeleteSnapshotResponse>";
         $this->adapter->setResponse($rawHttpResponse);
@@ -216,7 +216,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DeleteVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DeleteVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</DeleteVolumeResponse>";
         $this->adapter->setResponse($rawHttpResponse);
@@ -240,7 +240,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeSnapshotsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeSnapshotsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <snapshotSet>\r\n"
                     . "    <item>\r\n"
                     . "      <snapshotId>snap-78a54011</snapshotId>\r\n"
@@ -279,7 +279,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeSnapshotsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeSnapshotsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <snapshotSet>\r\n"
                     . "    <item>\r\n"
                     . "      <snapshotId>snap-78a54011</snapshotId>\r\n"
@@ -337,7 +337,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "<volumeSet>\r\n"
                     . "  <item>\r\n"
                     . "    <volumeId>vol-4282672b</volumeId>\r\n"
@@ -394,7 +394,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "<volumeSet>\r\n"
                     . "  <item>\r\n"
                     . "    <volumeId>vol-4282672b</volumeId>\r\n"
@@ -462,7 +462,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "<volumeSet>\r\n"
                     . "  <item>\r\n"
                     . "    <volumeId>vol-4282672b</volumeId>\r\n"
@@ -526,7 +526,7 @@ class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DetachVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DetachVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <volumeId>vol-4d826724</volumeId>\r\n"
                     . "  <instanceId>i-6058a509</instanceId>\r\n"
                     . "  <device>/dev/sdh</device>\r\n"

+ 6 - 6
tests/Zend/Service/Amazon/Ec2/ElasticipTest.php

@@ -57,7 +57,7 @@ class Zend_Service_Amazon_Ec2_ElasticipTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<AllocateAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<AllocateAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <publicIp>67.202.55.255</publicIp>\r\n"
                     . "</AllocateAddressResponse>";
         $this->adapter->setResponse($rawHttpResponse);
@@ -77,7 +77,7 @@ class Zend_Service_Amazon_Ec2_ElasticipTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<AssociateAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<AssociateAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</AssociateAddressResponse>";
         $this->adapter->setResponse($rawHttpResponse);
@@ -102,7 +102,7 @@ class Zend_Service_Amazon_Ec2_ElasticipTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeAddressesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeAddressesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <addressSet>\r\n"
                     . "    <item>\r\n"
                     . "      <publicIp>67.202.55.255</publicIp>\r\n"
@@ -133,7 +133,7 @@ class Zend_Service_Amazon_Ec2_ElasticipTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeAddressesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeAddressesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <addressSet>\r\n"
                     . "    <item>\r\n"
                     . "      <publicIp>67.202.55.255</publicIp>\r\n"
@@ -179,7 +179,7 @@ class Zend_Service_Amazon_Ec2_ElasticipTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DisassociateAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DisassociateAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</DisassociateAddressResponse>";
         $this->adapter->setResponse($rawHttpResponse);
@@ -204,7 +204,7 @@ class Zend_Service_Amazon_Ec2_ElasticipTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ReleaseAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ReleaseAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</ReleaseAddressResponse>";
         $this->adapter->setResponse($rawHttpResponse);

+ 14 - 14
tests/Zend/Service/Amazon/Ec2/ImageTest.php

@@ -52,7 +52,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DeregisterImageResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DeregisterImageResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</DeregisterImageResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -74,7 +74,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imagesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <imageId>ami-be3adfd7</imageId>\r\n"
@@ -145,7 +145,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imagesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <imageId>ami-be3adfd7</imageId>\r\n"
@@ -193,7 +193,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imagesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <imageId>ami-be3adfd7</imageId>\r\n"
@@ -264,7 +264,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imagesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <imageId>ami-be3adfd7</imageId>\r\n"
@@ -312,7 +312,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imagesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <imageId>ami-be3adfd7</imageId>\r\n"
@@ -383,7 +383,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImagesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imagesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <imageId>ami-be3adfd7</imageId>\r\n"
@@ -431,7 +431,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imageId>ami-61a54008</imageId>\r\n"
                     . "  <launchPermission>\r\n"
                     . "    <item>\r\n"
@@ -458,7 +458,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imageId>ami-61a54008</imageId>\r\n"
                     . "  <productCodes>\r\n"
                     . "    <item>\r\n"
@@ -485,7 +485,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ModifyImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ModifyImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</ModifyImageAttributeResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -505,7 +505,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ModifyImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ModifyImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</ModifyImageAttributeResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -533,7 +533,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ModifyImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ModifyImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</ModifyImageAttributeResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -555,7 +555,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<RegisterImageResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RegisterImageResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <imageId>ami-61a54008</imageId>\r\n"
                     . "</RegisterImageResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -577,7 +577,7 @@ class Zend_Service_Amazon_Ec2_ImageTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ResetImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ResetImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</ResetImageAttributeResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);

+ 170 - 0
tests/Zend/Service/Amazon/Ec2/InstanceReservedTest.php

@@ -0,0 +1,170 @@
+<?php
+
+require_once 'Zend/Service/Amazon/Ec2/Instance/Reserved.php';
+require_once 'Zend/Http/Client.php';
+require_once 'Zend/Http/Client/Adapter/Test.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * Zend_Service_Amazon_Ec2_Instance_Reserved test case.
+ */
+class InstanceReservedTest extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * @var Zend_Service_Amazon_Ec2_Instance_Reserved
+     */
+    private $Zend_Service_Amazon_Ec2_Instance_Reserved;
+
+    /**
+     * Prepares the environment before running a test.
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->Zend_Service_Amazon_Ec2_Instance_Reserved = new Zend_Service_Amazon_Ec2_Instance_Reserved('access_key', 'secret_access_key');
+
+        $adapter = new Zend_Http_Client_Adapter_Test();
+        $client = new Zend_Http_Client(null, array(
+            'adapter' => $adapter
+        ));
+        $this->adapter = $adapter;
+        Zend_Service_Amazon_Ec2_Instance_Reserved::setHttpClient($client);
+
+    }
+
+    /**
+     * Cleans up the environment after running a test.
+     */
+    protected function tearDown()
+    {
+        unset($this->adapter);
+        $this->Zend_Service_Amazon_Ec2_Instance_Reserved = null;
+        parent::tearDown();
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_Instance_Reserved->describeInstances()
+     */
+    public function testDescribeInstances()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<DescribeReservedInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    ."  <reservedInstancesSet>\r\n"
+                    ."    <item>\r\n"
+                    ."      <reservedInstancesId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesId>\r\n"
+                    ."      <instanceType>m1.small</instanceType>\r\n"
+                    ."      <availabilityZone>us-east-1a</availabilityZone>\r\n"
+                    ."      <duration>12</duration>\r\n"
+                    ."      <usagePrice>0.00</usagePrice>\r\n"
+                    ."      <fixedPrice>0.00</fixedPrice>\r\n"
+                    ."      <instanceCount>19</instanceCount>\r\n"
+                    ."      <productDescription>m1.small offering in us-east-1a</productDescription>\r\n"
+                    ."      <state>Active</state>\r\n"
+                    ."    </item>\r\n"
+                    ."  </reservedInstancesSet>\r\n"
+                    ."</DescribeReservedInstancesResponse>";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance_Reserved->describeInstances('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8');
+
+        $arrReturn = array(
+            array(
+            "reservedInstancesId" => "4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8",
+            "instanceType" => "m1.small",
+            "availabilityZone" => "us-east-1a",
+            "duration" => "12",
+            "fixedPrice" => "0.00",
+            "usagePrice" => "0.00",
+            "productDescription" => "m1.small offering in us-east-1a",
+            "instanceCount" => "19",
+            "state" => "Active"
+            )
+        );
+
+        $this->assertSame($arrReturn, $return);
+
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_Instance_Reserved->describeOfferings()
+     */
+    public function testDescribeOfferings()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<DescribeReservedInstancesOfferingsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    ."  <reservedInstancesOfferingsSet>\r\n"
+                    ."    <item>\r\n"
+                    ."      <reservedInstancesOfferingId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesOfferingId>\r\n"
+                    ."      <instanceType>m1.small</instanceType>\r\n"
+                    ."      <availabilityZone>us-east-1a</availabilityZone>\r\n"
+                    ."      <duration>12</duration>\r\n"
+                    ."      <usagePrice>0.00</usagePrice>\r\n"
+                    ."      <fixedPrice>0.00</fixedPrice>\r\n"
+                    ."      <productDescription>m1.small offering in us-east-1a</productDescription>\r\n"
+                    ."    </item>\r\n"
+                    ."  </reservedInstancesOfferingsSet>\r\n"
+                    ."</DescribeReservedInstancesOfferingsResponse>";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance_Reserved->describeOfferings();
+
+        $arrReturn = array(
+            array(
+            "reservedInstancesOfferingId" => "4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8",
+            "instanceType" => "m1.small",
+            "availabilityZone" => "us-east-1a",
+            "duration" => "12",
+            "fixedPrice" => "0.00",
+            "usagePrice" => "0.00",
+            "productDescription" => "m1.small offering in us-east-1a",
+            )
+        );
+
+        $this->assertSame($arrReturn, $return);
+
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_Instance_Reserved->purchaseOffering()
+     */
+    public function testPurchaseOffering()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<PurchaseReservedInstancesOfferingResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    ."  <reservedInstancesId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesId>\r\n"
+                    ."</PurchaseReservedInstancesOfferingResponse>";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance_Reserved->purchaseOffering('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8');
+
+        $this->assertSame('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8', $return);
+
+    }
+
+}
+

+ 72 - 14
tests/Zend/Service/Amazon/Ec2/InstanceTest.php

@@ -70,7 +70,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ConfirmProductInstanceResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ConfirmProductInstanceResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <result>true</result>\r\n"
                     . "  <ownerId>254933287430</ownerId>\r\n"
                     . "</ConfirmProductInstanceResponse>\r\n";
@@ -92,7 +92,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<ConfirmProductInstanceResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<ConfirmProductInstanceResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <result>false</result>\r\n"
                     . "</ConfirmProductInstanceResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -116,7 +116,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <reservationSet>\r\n"
                     . "    <item>\r\n"
                     . "      <reservationId>r-44a5402d</reservationId>\r\n"
@@ -156,8 +156,8 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
 
         $return = $this->Zend_Service_Amazon_Ec2_Instance->describe('i-28a64341');
 
-        $this->assertEquals('r-44a5402d', $return['reservationId']);
-        $this->assertEquals('default', $return['groupSet'][0]);
+        $this->assertEquals('r-44a5402d', $return['instances'][0]['reservationId']);
+        $this->assertEquals('default', $return['instances'][0]['groupSet'][0]);
         $this->assertEquals('i-28a64341', $return['instances'][0]['instanceId']);
         $this->assertEquals('ami-6ea54007', $return['instances'][0]['imageId']);
         $this->assertEquals('m1.small', $return['instances'][0]['instanceType']);
@@ -175,7 +175,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <reservationSet>\r\n"
                     . "    <item>\r\n"
                     . "      <reservationId>r-44a5402d</reservationId>\r\n"
@@ -229,7 +229,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <reservationSet>\r\n"
                     . "    <item>\r\n"
                     . "      <reservationId>r-44a5402d</reservationId>\r\n"
@@ -308,7 +308,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<RunInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RunInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <reservationId>r-47a5402e</reservationId>\r\n"
                     . "  <ownerId>495219933132</ownerId>\r\n"
                     . "  <groupSet>\r\n"
@@ -411,7 +411,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<RunInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RunInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <reservationId>r-47a5402e</reservationId>\r\n"
                     . "  <ownerId>495219933132</ownerId>\r\n"
                     . "  <groupSet>\r\n"
@@ -474,7 +474,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<TerminateInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<TerminateInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <instancesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <instanceId>i-28a64341</instanceId>\r\n"
@@ -511,7 +511,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<TerminateInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<TerminateInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <instancesSet>\r\n"
                     . "    <item>\r\n"
                     . "      <instanceId>i-28a64341</instanceId>\r\n"
@@ -561,7 +561,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<RebootInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RebootInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</RebootInstancesResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -583,7 +583,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<RebootInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RebootInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</RebootInstancesResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -604,7 +604,7 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<GetConsoleOutputResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<GetConsoleOutputResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <instanceId>i-28a64341</instanceId>\r\n"
                     . "  <timestamp>2007-01-03 15:00:00</timestamp>\r\n"
                     . "  <output>TGludXggdmVyc2lvbiAyLjYuMTYteGVuVSAoYnVpbGRlckBwYXRjaGJhdC5hbWF6b25zYSkgKGdj\r\n"
@@ -637,5 +637,63 @@ class Zend_Service_Amazon_Ec2_InstanceTest extends PHPUnit_Framework_TestCase
         $this->assertSame($arrOutput, $return);
     }
 
+    public function testMonitorInstance()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    . "<MonitorInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    . "  <instancesSet>"
+                    . "    <item>"
+                    . "      <instanceId>i-43a4412a</instanceId>"
+                    . "      <monitoring>"
+                    . "        <state>monitoring</state>"
+                    . "      </monitoring>"
+                    . "    </item>"
+                    . "  </instancesSet>"
+                    . "</MonitorInstancesResponse>\r\n";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance->monitor('i-43a4412a');
+
+        $arrReturn = array(array('instanceid' => 'i-43a4412a', 'monitorstate' => 'monitoring'));
+        $this->assertSame($arrReturn, $return);
+    }
+
+    public function testUnmonitorInstance()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    . "<UnmonitorInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    . "  <instancesSet>"
+                    . "    <item>"
+                    . "      <instanceId>i-43a4412a</instanceId>"
+                    . "      <monitoring>"
+                    . "        <state>pending</state>"
+                    . "      </monitoring>"
+                    . "    </item>"
+                    . "  </instancesSet>"
+                    . "</UnmonitorInstancesResponse>\r\n";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance->unmonitor('i-43a4412a');
+
+        $arrReturn = array(array('instanceid' => 'i-43a4412a', 'monitorstate' => 'pending'));
+        $this->assertSame($arrReturn, $return);
+    }
+
 }
 

+ 217 - 0
tests/Zend/Service/Amazon/Ec2/InstanceWindowsTest.php

@@ -0,0 +1,217 @@
+<?php
+
+require_once 'Zend/Service/Amazon/Ec2/Instance/Windows.php';
+require_once 'Zend/Http/Client.php';
+require_once 'Zend/Http/Client/Adapter/Test.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * Zend_Service_Amazon_Ec2_Instance_Windows test case.
+ */
+class InstanceWindowsTest extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * @var Zend_Service_Amazon_Ec2_Instance_Windows
+     */
+    private $Zend_Service_Amazon_Ec2_Instance_Windows;
+
+    /**
+     * Prepares the environment before running a test.
+     */
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->Zend_Service_Amazon_Ec2_Instance_Windows = new Zend_Service_Amazon_Ec2_Instance_Windows('access_key', 'secret_access_key');
+
+        $adapter = new Zend_Http_Client_Adapter_Test();
+        $client = new Zend_Http_Client(null, array(
+            'adapter' => $adapter
+        ));
+        $this->adapter = $adapter;
+        Zend_Service_Amazon_Ec2_Instance_Windows::setHttpClient($client);
+    }
+
+    /**
+     * Cleans up the environment after running a test.
+     */
+    protected function tearDown()
+    {
+        unset($this->adapter);
+        $this->Zend_Service_Amazon_Ec2_Instance_Windows = null;
+
+        parent::tearDown();
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_Instance_Windows->bundle()
+     */
+    public function testBundle()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<BundleInstanceResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    ."  <requestId>bun-c1a540a8</requestId>\r\n"
+                    ."  <bundleInstanceTask>\r\n"
+                    ."      <instanceId>i-12345678</instanceId>\r\n"
+                    ."      <bundleId>bun-cla322b9</bundleId>\r\n"
+                    ."      <state>bundling</state>\r\n"
+                    ."      <startTime>2008-10-07T11:41:50.000Z</startTime>\r\n"
+                    ."      <updateTime>2008-10-07T11:51:50.000Z</updateTime>\r\n"
+                    ."      <progress>20%</progress>\r\n"
+                    ."      <storage>\r\n"
+                    ."        <S3>\r\n"
+                    ."          <bucket>my-bucket</bucket>\r\n"
+                    ."          <prefix>my-new-image</prefix>\r\n"
+                    ."        </S3>\r\n"
+                    ."      </storage>\r\n"
+                    ."  </bundleInstanceTask>\r\n"
+                    ."</BundleInstanceResponse>";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance_Windows->bundle('i-12345678', 'my-bucket', 'my-new-image');
+
+        print_r($return);
+
+        $arrReturn = array(
+                "instanceId" => "i-12345678",
+                "bundleId" => "bun-cla322b9",
+                "state" => "bundling",
+                "startTime" => "2008-10-07T11:41:50.000Z",
+                "updateTime" => "2008-10-07T11:51:50.000Z",
+                "progress" => "20%",
+                "storage" => array(
+                        "s3" => array
+                            (
+                                "bucket" => "my-bucket",
+                                "prefix" => "my-new-image"
+                            )
+                    )
+                );
+
+        $this->assertSame($arrReturn, $return);
+
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_Instance_Windows->cancelBundle()
+     */
+    public function testCancelBundle()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<CancelBundleTaskResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    ."  <bundleInstanceTask>\r\n"
+                    ."      <instanceId>i-12345678</instanceId>\r\n"
+                    ."      <bundleId>bun-cla322b9</bundleId>\r\n"
+                    ."      <state>canceling</state>\r\n"
+                    ."      <startTime>2008-10-07T11:41:50.000Z</startTime>\r\n"
+                    ."      <updateTime>2008-10-07T11:51:50.000Z</updateTime>\r\n"
+                    ."      <progress>20%</progress>\r\n"
+                    ."      <storage>\r\n"
+                    ."        <S3>\r\n"
+                    ."          <bucket>my-bucket</bucket>\r\n"
+                    ."          <prefix>my-new-image</prefix>\r\n"
+                    ."        </S3>\r\n"
+                    ."      </storage>\r\n"
+                    ."  </bundleInstanceTask>\r\n"
+                    ."</CancelBundleTaskResponse>";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance_Windows->cancelBundle('bun-cla322b9');
+
+        $arrReturn = array(    "instanceId" => "i-12345678",
+                "bundleId" => "bun-cla322b9",
+                "state" => "canceling",
+                "startTime" => "2008-10-07T11:41:50.000Z",
+                "updateTime" => "2008-10-07T11:51:50.000Z",
+                "progress" => "20%",
+                "storage" => array(
+                        "s3" => array
+                            (
+                                "bucket" => "my-bucket",
+                                "prefix" => "my-new-image"
+                            )
+                    )
+                );
+
+        $this->assertSame($arrReturn, $return);
+
+
+
+    }
+
+    /**
+     * Tests Zend_Service_Amazon_Ec2_Instance_Windows->describeBundle()
+     */
+    public function testDescribeBundle()
+    {
+        $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
+                    . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Server: hi\r\n"
+                    . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
+                    . "Status: 200 OK\r\n"
+                    . "Content-type: application/xml; charset=utf-8\r\n"
+                    . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
+                    . "Connection: close\r\n"
+                    . "\r\n"
+                    ."<DescribeBundleTasksResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
+                    ."  <bundleInstanceTasksSet>\r\n"
+                    ."    <item>\r\n"
+                    ."      <instanceId>i-12345678</instanceId>\r\n"
+                    ."      <bundleId>bun-cla322b9</bundleId>\r\n"
+                    ."      <state>bundling</state>\r\n"
+                    ."      <startTime>2008-10-07T11:41:50.000Z</startTime>\r\n"
+                    ."      <updateTime>2008-10-07T11:51:50.000Z</updateTime>\r\n"
+                    ."      <progress>20%</progress>\r\n"
+                    ."      <storage>\r\n"
+                    ."        <S3>\r\n"
+                    ."          <bucket>my-bucket</bucket>\r\n"
+                    ."          <prefix>my-new-image</prefix>\r\n"
+                    ."        </S3>\r\n"
+                    ."      </storage>\r\n"
+                    ."    </item>\r\n"
+                    ."  </bundleInstanceTasksSet>\r\n"
+                    ."</DescribeBundleTasksResponse>";
+        $this->adapter->setResponse($rawHttpResponse);
+
+        $return = $this->Zend_Service_Amazon_Ec2_Instance_Windows->describeBundle('bun-cla322b9');
+
+        $arrReturn = array(
+            array(
+                "instanceId" => "i-12345678",
+                "bundleId" => "bun-cla322b9",
+                "state" => "bundling",
+                "startTime" => "2008-10-07T11:41:50.000Z",
+                "updateTime" => "2008-10-07T11:51:50.000Z",
+                "progress" => "20%",
+                "storage" => array(
+                        "s3" => array
+                            (
+                                "bucket" => "my-bucket",
+                                "prefix" => "my-new-image"
+                            )
+                    )
+                )
+            );
+
+        $this->assertSame($arrReturn, $return);
+
+    }
+
+}
+

+ 5 - 5
tests/Zend/Service/Amazon/Ec2/KeypairTest.php

@@ -71,7 +71,7 @@ class Zend_Service_Amazon_Ec2_KeypairTest extends PHPUnit_Framework_TestCase
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<CreateKeyPairResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<CreateKeyPairResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "    <keyName>example-key-name</keyName>\r\n"
                     . "    <keyFingerprint>1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f</keyFingerprint>\r\n"
                     . "    <keyMaterial>-----BEGIN RSA PRIVATE KEY-----\r\n"
@@ -120,7 +120,7 @@ class Zend_Service_Amazon_Ec2_KeypairTest extends PHPUnit_Framework_TestCase
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<DescribeKeyPairsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeKeyPairsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <keySet>\r\n"
                     . "    <item>\r\n"
                     . "      <keyName>example-key-name</keyName>\r\n"
@@ -146,7 +146,7 @@ class Zend_Service_Amazon_Ec2_KeypairTest extends PHPUnit_Framework_TestCase
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<DescribeKeyPairsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeKeyPairsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <keySet>\r\n"
                     . "    <item>\r\n"
                     . "      <keyName>example-key-name</keyName>\r\n"
@@ -199,7 +199,7 @@ class Zend_Service_Amazon_Ec2_KeypairTest extends PHPUnit_Framework_TestCase
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<DeleteKeyPair xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DeleteKeyPair xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>false</return>\r\n"
                     . "</DeleteKeyPair>";
         $this->adapter->setResponse($rawHttpResponse);
@@ -221,7 +221,7 @@ class Zend_Service_Amazon_Ec2_KeypairTest extends PHPUnit_Framework_TestCase
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<DeleteKeyPair xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DeleteKeyPair xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</DeleteKeyPair>";
         $this->adapter->setResponse($rawHttpResponse);

+ 2 - 2
tests/Zend/Service/Amazon/Ec2/RegionTest.php

@@ -57,7 +57,7 @@ class Zend_Service_Amazon_Ec2_RegionTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <regionInfo>\r\n"
                     . "    <item>\r\n"
                     . "      <regionName>us-east-1</regionName>\r\n"
@@ -90,7 +90,7 @@ class Zend_Service_Amazon_Ec2_RegionTest extends PHPUnit_Framework_TestCase
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <regionInfo>\r\n"
                     . "    <item>\r\n"
                     . "      <regionName>us-east-1</regionName>\r\n"

+ 10 - 10
tests/Zend/Service/Amazon/Ec2/SecuritygroupsTest.php

@@ -61,7 +61,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<AuthorizeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<AuthorizeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</AuthorizeSecurityGroupIngressResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -83,7 +83,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<AuthorizeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<AuthorizeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</AuthorizeSecurityGroupIngressResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -105,7 +105,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<AuthorizeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<AuthorizeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</AuthorizeSecurityGroupIngressResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -131,7 +131,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<CreateSecurityGroupResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<CreateSecurityGroupResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</CreateSecurityGroupResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -157,7 +157,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<DeleteSecurityGroupResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DeleteSecurityGroupResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</DeleteSecurityGroupResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -182,7 +182,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeSecurityGroupsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeSecurityGroupsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <securityGroupInfo>\r\n"
                     . "    <item>\r\n"
                     . "      <ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>\r\n"
@@ -268,7 +268,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
                     . "Connection: close\r\n"
                     . "\r\n"
-                    . "<DescribeSecurityGroupsResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<DescribeSecurityGroupsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <securityGroupInfo>\r\n"
                     . "    <item>\r\n"
                     . "      <ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>\r\n"
@@ -329,7 +329,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</RevokeSecurityGroupIngressResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -351,7 +351,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</RevokeSecurityGroupIngressResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);
@@ -374,7 +374,7 @@ class Zend_Service_Amazon_Ec2_SecuritygroupsTest extends PHPUnit_Framework_TestC
                     . "Connection: close\r\n"
                     . "\r\n"
                     . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
-                    . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2008-12-01/\">\r\n"
+                    . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
                     . "  <return>true</return>\r\n"
                     . "</RevokeSecurityGroupIngressResponse>\r\n";
         $this->adapter->setResponse($rawHttpResponse);