/**
 * Purchase Reserved Instances Offering Action Sample
 * The PurchaseReservedInstancesOffering operation 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 Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_PurchaseReservedInstancesOffering or array of parameters
 */
function invokePurchaseReservedInstancesOffering(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->purchaseReservedInstancesOffering($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        PurchaseReservedInstancesOfferingResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetPurchaseReservedInstancesOfferingResult()) {
            echo "            PurchaseReservedInstancesOfferingResult\n";
            $purchaseReservedInstancesOfferingResult = $response->getPurchaseReservedInstancesOfferingResult();
            if ($purchaseReservedInstancesOfferingResult->isSetReservedInstancesId()) {
                echo "                ReservedInstancesId\n";
                echo "                    " . $purchaseReservedInstancesOfferingResult->getReservedInstancesId() . "\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";
    }
}