/** * Describe Spot Price History Action Sample * Describes historical pricing for Spot Instances. Spot Instances are instances that automatically launch * when your request price exceeds the Spot Price that Amazon EC2 periodically calculates. * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface * @param mixed $request Amazon_EC2_Model_DescribeSpotPriceHistory or array of parameters */ function invokeDescribeSpotPriceHistory(Amazon_EC2_Interface $service, $request) { try { $response = $service->describeSpotPriceHistory($request); echo "Service Response\n"; echo "=============================================================================\n"; echo " DescribeSpotPriceHistoryResponse\n"; if ($response->isSetResponseMetadata()) { echo " ResponseMetadata\n"; $responseMetadata = $response->getResponseMetadata(); if ($responseMetadata->isSetRequestId()) { echo " RequestId\n"; echo " " . $responseMetadata->getRequestId() . "\n"; } } if ($response->isSetDescribeSpotPriceHistoryResult()) { echo " DescribeSpotPriceHistoryResult\n"; $describeSpotPriceHistoryResult = $response->getDescribeSpotPriceHistoryResult(); $spotPriceHistoryList = $describeSpotPriceHistoryResult->getSpotPriceHistory(); foreach ($spotPriceHistoryList as $spotPriceHistory) { echo " SpotPriceHistory\n"; if ($spotPriceHistory->isSetInstanceType()) { echo " InstanceType\n"; echo " " . $spotPriceHistory->getInstanceType() . "\n"; } if ($spotPriceHistory->isSetProductDescription()) { echo " ProductDescription\n"; echo " " . $spotPriceHistory->getProductDescription() . "\n"; } if ($spotPriceHistory->isSetSpotPrice()) { echo " SpotPrice\n"; echo " " . $spotPriceHistory->getSpotPrice() . "\n"; } if ($spotPriceHistory->isSetTimestamp()) { echo " Timestamp\n"; echo " " . $spotPriceHistory->getTimestamp() . "\n"; } } } } catch (Amazon_EC2_Exception $ex) { echo "Caught Exception: " . $ex->getMessage() . "\n"; echo "Response Status Code: " . $ex->getStatusCode() . "\n"; echo "Error Code: " . $ex->getErrorCode() . "\n"; echo "Error Type: " . $ex->getErrorType() . "\n"; echo "Request ID: " . $ex->getRequestId() . "\n"; echo "XML: " . $ex->getXML() . "\n"; } }