/**
 * Start Instances Action Sample
 * Starts an instance that uses an Amazon EBS volume as its root device.
 * Instances that use Amazon EBS volumes as their root devices can be quickly stopped and started.
 * When an instance is stopped, the compute resources are released and you are not billed for hourly
 * instance usage. However, your root partition Amazon EBS volume remains, continues to persist your
 * data, and you are charged for Amazon EBS volume usage. You can restart your instance at any time.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_StartInstances or array of parameters
 */
function invokeStartInstances(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->startInstances($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        StartInstancesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetStartInstancesResult()) {
            echo "            StartInstancesResult\n";
            $startInstancesResult = $response->getStartInstancesResult();
            $startingInstancesList = $startInstancesResult->getStartingInstances();
            foreach ($startingInstancesList as $startingInstances) {
                echo "                StartingInstances\n";
                if ($startingInstances->isSetInstanceId()) {
                    echo "                    InstanceId\n";
                    echo "                        " . $startingInstances->getInstanceId() . "\n";
                }
                if ($startingInstances->isSetCurrentState()) {
                    echo "                    CurrentState\n";
                    $currentState = $startingInstances->getCurrentState();
                    if ($currentState->isSetCode()) {
                        echo "                        Code\n";
                        echo "                            " . $currentState->getCode() . "\n";
                    }
                    if ($currentState->isSetName()) {
                        echo "                        Name\n";
                        echo "                            " . $currentState->getName() . "\n";
                    }
                }
                if ($startingInstances->isSetPreviousState()) {
                    echo "                    PreviousState\n";
                    $previousState = $startingInstances->getPreviousState();
                    if ($previousState->isSetCode()) {
                        echo "                        Code\n";
                        echo "                            " . $previousState->getCode() . "\n";
                    }
                    if ($previousState->isSetName()) {
                        echo "                        Name\n";
                        echo "                            " . $previousState->getName() . "\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";
    }
}
/**
 * Describe Reserved Instances Offerings Action Sample
 * The DescribeReservedInstancesOfferings operation 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.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeReservedInstancesOfferings or array of parameters
 */
function invokeDescribeReservedInstancesOfferings(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeReservedInstancesOfferings($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeReservedInstancesOfferingsResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeReservedInstancesOfferingsResult()) {
            echo "            DescribeReservedInstancesOfferingsResult\n";
            $describeReservedInstancesOfferingsResult = $response->getDescribeReservedInstancesOfferingsResult();
            $reservedInstancesOfferingList = $describeReservedInstancesOfferingsResult->getReservedInstancesOffering();
            foreach ($reservedInstancesOfferingList as $reservedInstancesOffering) {
                echo "                ReservedInstancesOffering\n";
                if ($reservedInstancesOffering->isSetReservedInstancesOfferingId()) {
                    echo "                    ReservedInstancesOfferingId\n";
                    echo "                        " . $reservedInstancesOffering->getReservedInstancesOfferingId() . "\n";
                }
                if ($reservedInstancesOffering->isSetInstanceType()) {
                    echo "                    InstanceType\n";
                    echo "                        " . $reservedInstancesOffering->getInstanceType() . "\n";
                }
                if ($reservedInstancesOffering->isSetAvailabilityZone()) {
                    echo "                    AvailabilityZone\n";
                    echo "                        " . $reservedInstancesOffering->getAvailabilityZone() . "\n";
                }
                if ($reservedInstancesOffering->isSetDuration()) {
                    echo "                    Duration\n";
                    echo "                        " . $reservedInstancesOffering->getDuration() . "\n";
                }
                if ($reservedInstancesOffering->isSetUsagePrice()) {
                    echo "                    UsagePrice\n";
                    echo "                        " . $reservedInstancesOffering->getUsagePrice() . "\n";
                }
                if ($reservedInstancesOffering->isSetFixedPrice()) {
                    echo "                    FixedPrice\n";
                    echo "                        " . $reservedInstancesOffering->getFixedPrice() . "\n";
                }
                if ($reservedInstancesOffering->isSetProductDescription()) {
                    echo "                    ProductDescription\n";
                    echo "                        " . $reservedInstancesOffering->getProductDescription() . "\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";
    }
}
/**
 * Allocate Address Action Sample
 * The AllocateAddress operation acquires an elastic IP address for use with your
 * account.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_AllocateAddress or array of parameters
 */
function invokeAllocateAddress(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->allocateAddress($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        AllocateAddressResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetAllocateAddressResult()) {
            echo "            AllocateAddressResult\n";
            $allocateAddressResult = $response->getAllocateAddressResult();
            if ($allocateAddressResult->isSetPublicIp()) {
                echo "                PublicIp\n";
                echo "                    " . $allocateAddressResult->getPublicIp() . "\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";
    }
}
/**
 * Create Spot Datafeed Subscription Action Sample
 * Creates the data feed for spot instances, enabling you to view Spot Instance usage logs. You can
 * create one data feed per account.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateSpotDatafeedSubscription or array of parameters
 */
function invokeCreateSpotDatafeedSubscription(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createSpotDatafeedSubscription($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateSpotDatafeedSubscriptionResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCreateSpotDatafeedSubscriptionResult()) {
            echo "            CreateSpotDatafeedSubscriptionResult\n";
            $createSpotDatafeedSubscriptionResult = $response->getCreateSpotDatafeedSubscriptionResult();
            if ($createSpotDatafeedSubscriptionResult->isSetSpotDatafeedSubscription()) {
                echo "                SpotDatafeedSubscription\n";
                $spotDatafeedSubscription = $createSpotDatafeedSubscriptionResult->getSpotDatafeedSubscription();
                if ($spotDatafeedSubscription->isSetOwnerId()) {
                    echo "                    OwnerId\n";
                    echo "                        " . $spotDatafeedSubscription->getOwnerId() . "\n";
                }
                if ($spotDatafeedSubscription->isSetBucket()) {
                    echo "                    Bucket\n";
                    echo "                        " . $spotDatafeedSubscription->getBucket() . "\n";
                }
                if ($spotDatafeedSubscription->isSetPrefix()) {
                    echo "                    Prefix\n";
                    echo "                        " . $spotDatafeedSubscription->getPrefix() . "\n";
                }
                if ($spotDatafeedSubscription->isSetState()) {
                    echo "                    State\n";
                    echo "                        " . $spotDatafeedSubscription->getState() . "\n";
                }
                if ($spotDatafeedSubscription->isSetFault()) {
                    echo "                    Fault\n";
                    $fault = $spotDatafeedSubscription->getFault();
                    if ($fault->isSetCode()) {
                        echo "                        Code\n";
                        echo "                            " . $fault->getCode() . "\n";
                    }
                    if ($fault->isSetMessage()) {
                        echo "                        Message\n";
                        echo "                            " . $fault->getMessage() . "\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";
    }
}
/**
 * Register Image Action Sample
 * The RegisterImage operation registers an AMI with Amazon EC2. Images must be
 * registered before they can be launched. For more information, see RunInstances.
 * Each AMI is associated with an unique ID which is provided by the Amazon EC2
 * service through the RegisterImage operation. During registration, Amazon EC2
 * retrieves the specified image manifest from Amazon S3 and verifies that the
 * image is owned by the user registering the image.
 * The image manifest is retrieved once and stored within the Amazon EC2. Any
 * modifications to an image in Amazon S3 invalidates this registration. If you
 * make changes to an image, deregister the previous image and register the new
 * image. For more information, see DeregisterImage.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_RegisterImage or array of parameters
 */
function invokeRegisterImage(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->registerImage($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        RegisterImageResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetRegisterImageResult()) {
            echo "            RegisterImageResult\n";
            $registerImageResult = $response->getRegisterImageResult();
            if ($registerImageResult->isSetImageId()) {
                echo "                ImageId\n";
                echo "                    " . $registerImageResult->getImageId() . "\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";
    }
}
/**
 * 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";
    }
}
/**
 * Describe Vpn Gateways Action Sample
 * Gives you information about your VPN gateways. You can filter the results to return
 * information only about VPN gateways that match criteria you specify. For example,
 * you could ask to get information about a particular VPN gateway (or all) only if the
 * gateway's state is pending or available. You can specify multiple filters (e.g., the
 * VPN gateway is in a particular Availability Zone and the gateway's state is pending or
 * available). The result includes information for a particular VPN gateway only if the
 * gateway matches all your filters. If there's no match, no special message is returned;
 * the response is simply empty.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeVpnGateways or array of parameters
 */
function invokeDescribeVpnGateways(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeVpnGateways($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeVpnGatewaysResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeVpnGatewaysResult()) {
            echo "            DescribeVpnGatewaysResult\n";
            $describeVpnGatewaysResult = $response->getDescribeVpnGatewaysResult();
            $vpnGatewayList = $describeVpnGatewaysResult->getVpnGateway();
            foreach ($vpnGatewayList as $vpnGateway) {
                echo "                VpnGateway\n";
                if ($vpnGateway->isSetVpnGatewayId()) {
                    echo "                    VpnGatewayId\n";
                    echo "                        " . $vpnGateway->getVpnGatewayId() . "\n";
                }
                if ($vpnGateway->isSetVpnGatewayState()) {
                    echo "                    VpnGatewayState\n";
                    echo "                        " . $vpnGateway->getVpnGatewayState() . "\n";
                }
                if ($vpnGateway->isSetType()) {
                    echo "                    Type\n";
                    echo "                        " . $vpnGateway->getType() . "\n";
                }
                if ($vpnGateway->isSetAvailabilityZone()) {
                    echo "                    AvailabilityZone\n";
                    echo "                        " . $vpnGateway->getAvailabilityZone() . "\n";
                }
                $vpcAttachmentList = $vpnGateway->getVpcAttachment();
                foreach ($vpcAttachmentList as $vpcAttachment) {
                    echo "                    VpcAttachment\n";
                    if ($vpcAttachment->isSetVpcId()) {
                        echo "                        VpcId\n";
                        echo "                            " . $vpcAttachment->getVpcId() . "\n";
                    }
                    if ($vpcAttachment->isSetVpcAttachmentState()) {
                        echo "                        VpcAttachmentState\n";
                        echo "                            " . $vpcAttachment->getVpcAttachmentState() . "\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";
    }
}
/**
 * Detach Volume Action Sample
 * Detach a previously attached volume from a running instance.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DetachVolume or array of parameters
 */
function invokeDetachVolume(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->detachVolume($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DetachVolumeResponse\n";
        if ($response->isSetDetachVolumeResult()) {
            echo "            DetachVolumeResult\n";
            $detachVolumeResult = $response->getDetachVolumeResult();
            if ($detachVolumeResult->isSetAttachment()) {
                echo "                Attachment\n";
                $attachment = $detachVolumeResult->getAttachment();
                if ($attachment->isSetVolumeId()) {
                    echo "                    VolumeId\n";
                    echo "                        " . $attachment->getVolumeId() . "\n";
                }
                if ($attachment->isSetInstanceId()) {
                    echo "                    InstanceId\n";
                    echo "                        " . $attachment->getInstanceId() . "\n";
                }
                if ($attachment->isSetDevice()) {
                    echo "                    Device\n";
                    echo "                        " . $attachment->getDevice() . "\n";
                }
                if ($attachment->isSetStatus()) {
                    echo "                    Status\n";
                    echo "                        " . $attachment->getStatus() . "\n";
                }
                if ($attachment->isSetAttachTime()) {
                    echo "                    AttachTime\n";
                    echo "                        " . $attachment->getAttachTime() . "\n";
                }
                if ($attachment->isSetDeleteOnTermination()) {
                    echo "                    DeleteOnTermination\n";
                    echo "                        " . $attachment->getDeleteOnTermination() . "\n";
                }
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\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";
    }
}
/**
 * Create Vpn Connection Action Sample
 * Creates a new VPN connection between an existing VPN gateway and customer
 * gateway. The only supported connection type is ipsec.1.
 * The response includes information that you need to configure your customer gateway,
 * in XML format. We recommend you use the command line version of this operation
 * (ec2-create-vpn-connection), which lets you get the configuration information
 * formatted in a friendlier way. For information about the command, go to
 * ec2-create-vpn-connection in the Amazon Virtual Private Cloud Command Line Reference.
 * Important
 * We strongly recommend you use HTTPS when calling this operation because
 * the response contains sensitive cryptographic information for configuring
 * your customer gateway.
 * If you decide to shut down your VPN connection for any reason and then create a new
 * one, you must re-configure your customer gateway with the new information
 * returned from this call.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateVpnConnection or array of parameters
 */
function invokeCreateVpnConnection(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createVpnConnection($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateVpnConnectionResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCreateVpnConnectionResult()) {
            echo "            CreateVpnConnectionResult\n";
            $createVpnConnectionResult = $response->getCreateVpnConnectionResult();
            if ($createVpnConnectionResult->isSetVpnConnection()) {
                echo "                VpnConnection\n";
                $vpnConnection = $createVpnConnectionResult->getVpnConnection();
                if ($vpnConnection->isSetVpnConnectionId()) {
                    echo "                    VpnConnectionId\n";
                    echo "                        " . $vpnConnection->getVpnConnectionId() . "\n";
                }
                if ($vpnConnection->isSetVpnConnectionState()) {
                    echo "                    VpnConnectionState\n";
                    echo "                        " . $vpnConnection->getVpnConnectionState() . "\n";
                }
                if ($vpnConnection->isSetCustomerGatewayConfiguration()) {
                    echo "                    CustomerGatewayConfiguration\n";
                    echo "                        " . $vpnConnection->getCustomerGatewayConfiguration() . "\n";
                }
                if ($vpnConnection->isSetType()) {
                    echo "                    Type\n";
                    echo "                        " . $vpnConnection->getType() . "\n";
                }
                if ($vpnConnection->isSetCustomerGatewayId()) {
                    echo "                    CustomerGatewayId\n";
                    echo "                        " . $vpnConnection->getCustomerGatewayId() . "\n";
                }
                if ($vpnConnection->isSetVpnGatewayId()) {
                    echo "                    VpnGatewayId\n";
                    echo "                        " . $vpnConnection->getVpnGatewayId() . "\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";
    }
}
/**
 * Create Subnet Action Sample
 * Creates a subnet in an existing VPC. You can create up to 20 subnets in a VPC.
 * If you add more than one subnet to a VPC, they're set up in a star topology with
 * a logical router in the middle. If you feel you need more than 20 subnets, you can
 * request more by going to http://aws.amazon.com/contact-us/vpc-request/.
 * When you create each subnet, you provide the VPC ID and the CIDR block you
 * want for the subnet. Once you create a subnet, you can't change its CIDR block.
 * The subnet's CIDR block can be the same as the VPC's CIDR block (assuming you
 * want only a single subnet in the VPC), or a subset of the VPC's CIDR block.
 * If you create more than one subnet in a VPC, the subnets' CIDR blocks must not overlap.
 * The smallest subnet (and VPC) you can create uses a /28 netmask (16 IP addresses),
 * and the largest uses a /18 netmask (16,384 IP addresses).
 * Important
 * AWS reserves both the first four and the last IP address in each subnet's CIDR block.
 * They're not available for use.
 * AWS might delete any subnet you create with this operation if you leave it inactive
 * for an extended period of time (inactive means that there are no running Amazon EC2
 * instances in the subnet).  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateSubnet or array of parameters
 */
function invokeCreateSubnet(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createSubnet($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateSubnetResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCreateSubnetResult()) {
            echo "            CreateSubnetResult\n";
            $createSubnetResult = $response->getCreateSubnetResult();
            if ($createSubnetResult->isSetSubnet()) {
                echo "                Subnet\n";
                $subnet = $createSubnetResult->getSubnet();
                if ($subnet->isSetSubnetId()) {
                    echo "                    SubnetId\n";
                    echo "                        " . $subnet->getSubnetId() . "\n";
                }
                if ($subnet->isSetSubnetState()) {
                    echo "                    SubnetState\n";
                    echo "                        " . $subnet->getSubnetState() . "\n";
                }
                if ($subnet->isSetVpcId()) {
                    echo "                    VpcId\n";
                    echo "                        " . $subnet->getVpcId() . "\n";
                }
                if ($subnet->isSetCidrBlock()) {
                    echo "                    CidrBlock\n";
                    echo "                        " . $subnet->getCidrBlock() . "\n";
                }
                if ($subnet->isSetAvailableIpAddressCount()) {
                    echo "                    AvailableIpAddressCount\n";
                    echo "                        " . $subnet->getAvailableIpAddressCount() . "\n";
                }
                if ($subnet->isSetAvailabilityZone()) {
                    echo "                    AvailabilityZone\n";
                    echo "                        " . $subnet->getAvailabilityZone() . "\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";
    }
}
/**
 * Describe Customer Gateways Action Sample
 * Gives you information about your customer gateways. You can filter the results to return
 * information only about customer gateways that match criteria you specify. For example,
 * you could ask to get information about a particular customer gateway (or all) only if
 * the gateway's state is pending or available. You can specify multiple filters (e.g.,
 * the customer gateway has a particular IP address for the Internet-routable external
 * interface, and the gateway's state is pending or available). The result includes
 * information for a particular customer gateway only if the gateway matches all  your
 * filters. If there's no match, no special message is returned; the response is simply empty.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeCustomerGateways or array of parameters
 */
function invokeDescribeCustomerGateways(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeCustomerGateways($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeCustomerGatewaysResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeCustomerGatewaysResult()) {
            echo "            DescribeCustomerGatewaysResult\n";
            $describeCustomerGatewaysResult = $response->getDescribeCustomerGatewaysResult();
            $customerGatewayList = $describeCustomerGatewaysResult->getCustomerGateway();
            foreach ($customerGatewayList as $customerGateway) {
                echo "                CustomerGateway\n";
                if ($customerGateway->isSetCustomerGatewayId()) {
                    echo "                    CustomerGatewayId\n";
                    echo "                        " . $customerGateway->getCustomerGatewayId() . "\n";
                }
                if ($customerGateway->isSetCustomerGatewayState()) {
                    echo "                    CustomerGatewayState\n";
                    echo "                        " . $customerGateway->getCustomerGatewayState() . "\n";
                }
                if ($customerGateway->isSetType()) {
                    echo "                    Type\n";
                    echo "                        " . $customerGateway->getType() . "\n";
                }
                if ($customerGateway->isSetIpAddress()) {
                    echo "                    IpAddress\n";
                    echo "                        " . $customerGateway->getIpAddress() . "\n";
                }
                if ($customerGateway->isSetBgpAsn()) {
                    echo "                    BgpAsn\n";
                    echo "                        " . $customerGateway->getBgpAsn() . "\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";
    }
}
/**
 * Create Snapshot Action Sample
 * Create a snapshot of the volume identified by volume ID. A volume does not have to be detached
 * at the time the snapshot is taken.
 * Important Note:
 * Snapshot creation requires that the system is in a consistent state.
 * For instance, this means that if taking a snapshot of a database, the tables must
 * be read-only locked to ensure that the snapshot will not contain a corrupted
 * version of the database.  Therefore, be careful when using this API to ensure that
 * the system remains in the consistent state until the create snapshot status
 * has returned.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateSnapshot or array of parameters
 */
function invokeCreateSnapshot(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createSnapshot($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateSnapshotResponse\n";
        if ($response->isSetCreateSnapshotResult()) {
            echo "            CreateSnapshotResult\n";
            $createSnapshotResult = $response->getCreateSnapshotResult();
            if ($createSnapshotResult->isSetSnapshot()) {
                echo "                Snapshot\n";
                $snapshot = $createSnapshotResult->getSnapshot();
                if ($snapshot->isSetSnapshotId()) {
                    echo "                    SnapshotId\n";
                    echo "                        " . $snapshot->getSnapshotId() . "\n";
                }
                if ($snapshot->isSetVolumeId()) {
                    echo "                    VolumeId\n";
                    echo "                        " . $snapshot->getVolumeId() . "\n";
                }
                if ($snapshot->isSetStatus()) {
                    echo "                    Status\n";
                    echo "                        " . $snapshot->getStatus() . "\n";
                }
                if ($snapshot->isSetStartTime()) {
                    echo "                    StartTime\n";
                    echo "                        " . $snapshot->getStartTime() . "\n";
                }
                if ($snapshot->isSetProgress()) {
                    echo "                    Progress\n";
                    echo "                        " . $snapshot->getProgress() . "\n";
                }
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\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";
    }
}
/**
 * Describe Availability Zones Action Sample
 * The DescribeAvailabilityZones operation describes availability zones that are
 * currently available to the account and their states.
 * Availability zones are not the same across accounts. The availability zone
 * us-east-1a for account A is not necessarily the same as us-east-1a for account
 * B. Zone assignments are mapped independently for each account.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeAvailabilityZones or array of parameters
 */
function invokeDescribeAvailabilityZones(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeAvailabilityZones($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeAvailabilityZonesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeAvailabilityZonesResult()) {
            echo "            DescribeAvailabilityZonesResult\n";
            $describeAvailabilityZonesResult = $response->getDescribeAvailabilityZonesResult();
            $availabilityZoneList = $describeAvailabilityZonesResult->getAvailabilityZone();
            foreach ($availabilityZoneList as $availabilityZone) {
                echo "                AvailabilityZone\n";
                if ($availabilityZone->isSetZoneName()) {
                    echo "                    ZoneName\n";
                    echo "                        " . $availabilityZone->getZoneName() . "\n";
                }
                if ($availabilityZone->isSetZoneState()) {
                    echo "                    ZoneState\n";
                    echo "                        " . $availabilityZone->getZoneState() . "\n";
                }
                if ($availabilityZone->isSetRegionName()) {
                    echo "                    RegionName\n";
                    echo "                        " . $availabilityZone->getRegionName() . "\n";
                }
                $messageList = $availabilityZone->getMessage();
                foreach ($messageList as $message) {
                    echo "                    Message\n";
                    echo "                        " . $message;
                }
            }
        }
    } 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";
    }
}
/**
 * Create Dhcp Options Action Sample
 * Creates a set of DHCP options that you can then associate with one or more VPCs,
 * causing all existing and new instances that you launch in those VPCs to use the
 * set of DHCP options. The following table lists the individual DHCP options you can
 * specify. For more information about the options, go to RFC 2132 - http://www.ietf.org/rfc/rfc2132.txt  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateDhcpOptions or array of parameters
 */
function invokeCreateDhcpOptions(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createDhcpOptions($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateDhcpOptionsResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCreateDhcpOptionsResult()) {
            echo "            CreateDhcpOptionsResult\n";
            $createDhcpOptionsResult = $response->getCreateDhcpOptionsResult();
            if ($createDhcpOptionsResult->isSetDhcpOptions()) {
                echo "                DhcpOptions\n";
                $dhcpOptions = $createDhcpOptionsResult->getDhcpOptions();
                if ($dhcpOptions->isSetDhcpOptionsId()) {
                    echo "                    DhcpOptionsId\n";
                    echo "                        " . $dhcpOptions->getDhcpOptionsId() . "\n";
                }
                $configurationList = $dhcpOptions->getConfiguration();
                foreach ($configurationList as $configuration) {
                    echo "                    Configuration\n";
                    if ($configuration->isSetKey()) {
                        echo "                        Key\n";
                        echo "                            " . $configuration->getKey() . "\n";
                    }
                    $valueList = $configuration->getValue();
                    foreach ($valueList as $value) {
                        echo "                        Value\n";
                        echo "                            " . $value;
                    }
                }
            }
        }
    } 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";
    }
}
/**
 * Describe Snapshot Attribute Action Sample
 * Returns information about an attribute of a snapshot.
 * Only one attribute can be specified per call.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeSnapshotAttribute or array of parameters
 */
function invokeDescribeSnapshotAttribute(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeSnapshotAttribute($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeSnapshotAttributeResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeSnapshotAttributeResult()) {
            echo "            DescribeSnapshotAttributeResult\n";
            $describeSnapshotAttributeResult = $response->getDescribeSnapshotAttributeResult();
            if ($describeSnapshotAttributeResult->isSetSnapshotAttribute()) {
                echo "                SnapshotAttribute\n";
                $snapshotAttribute = $describeSnapshotAttributeResult->getSnapshotAttribute();
                if ($snapshotAttribute->isSetSnapshotId()) {
                    echo "                    SnapshotId\n";
                    echo "                        " . $snapshotAttribute->getSnapshotId() . "\n";
                }
                $createVolumePermissionList = $snapshotAttribute->getCreateVolumePermission();
                foreach ($createVolumePermissionList as $createVolumePermission) {
                    echo "                    CreateVolumePermission\n";
                    if ($createVolumePermission->isSetUserId()) {
                        echo "                        UserId\n";
                        echo "                            " . $createVolumePermission->getUserId() . "\n";
                    }
                    if ($createVolumePermission->isSetGroupName()) {
                        echo "                        GroupName\n";
                        echo "                            " . $createVolumePermission->getGroupName() . "\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";
    }
}
/**
 * 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";
    }
}
/**
 * Create Vpc Action Sample
 * Creates a VPC with the CIDR block you specify. The smallest VPC you can create
 * uses a /28 netmask (16 IP addresses), and the largest uses a /18 netmask
 * (16,384 IP addresses). To help you decide how big to make your VPC, go
 * to the topic about creating VPCs  in the Amazon Virtual Private Cloud
 * Developer Guide.
 * By default, each instance you launch in the VPC has the default DHCP options
 * (the standard EC2 host name, no domain name, no DNS server, no NTP server, and
 * no NetBIOS server or node type).
 * AWS might delete any VPC that you create with this operation if you leave it inactive
 * for an extended period of time (inactive means that there are no running Amazon EC2
 * instances in the VPC).  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateVpc or array of parameters
 */
function invokeCreateVpc(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createVpc($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateVpcResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCreateVpcResult()) {
            echo "            CreateVpcResult\n";
            $createVpcResult = $response->getCreateVpcResult();
            if ($createVpcResult->isSetVpc()) {
                echo "                Vpc\n";
                $vpc = $createVpcResult->getVpc();
                if ($vpc->isSetVpcId()) {
                    echo "                    VpcId\n";
                    echo "                        " . $vpc->getVpcId() . "\n";
                }
                if ($vpc->isSetVpcState()) {
                    echo "                    VpcState\n";
                    echo "                        " . $vpc->getVpcState() . "\n";
                }
                if ($vpc->isSetCidrBlock()) {
                    echo "                    CidrBlock\n";
                    echo "                        " . $vpc->getCidrBlock() . "\n";
                }
                if ($vpc->isSetDhcpOptionsId()) {
                    echo "                    DhcpOptionsId\n";
                    echo "                        " . $vpc->getDhcpOptionsId() . "\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";
    }
}
/**
 * Create Key Pair Action Sample
 * The CreateKeyPair operation creates a new 2048 bit RSA key pair and returns a
 * unique ID that can be used to reference this key pair when launching new
 * instances. For more information, see RunInstances.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_CreateKeyPair or array of parameters
 */
function invokeCreateKeyPair(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->createKeyPair($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CreateKeyPairResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCreateKeyPairResult()) {
            echo "            CreateKeyPairResult\n";
            $createKeyPairResult = $response->getCreateKeyPairResult();
            if ($createKeyPairResult->isSetKeyPair()) {
                echo "                KeyPair\n";
                $keyPair = $createKeyPairResult->getKeyPair();
                if ($keyPair->isSetKeyName()) {
                    echo "                    KeyName\n";
                    echo "                        " . $keyPair->getKeyName() . "\n";
                }
                if ($keyPair->isSetKeyFingerprint()) {
                    echo "                    KeyFingerprint\n";
                    echo "                        " . $keyPair->getKeyFingerprint() . "\n";
                }
                if ($keyPair->isSetKeyMaterial()) {
                    echo "                    KeyMaterial\n";
                    echo "                        " . $keyPair->getKeyMaterial() . "\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";
    }
}
/**
 * Get Password Data Action Sample
 * Retrieves the encrypted administrator password for the instances running Windows.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_GetPasswordData or array of parameters
 */
function invokeGetPasswordData(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->getPasswordData($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        GetPasswordDataResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetGetPasswordDataResult()) {
            echo "            GetPasswordDataResult\n";
            $getPasswordDataResult = $response->getGetPasswordDataResult();
            if ($getPasswordDataResult->isSetPasswordData()) {
                echo "                PasswordData\n";
                $passwordData = $getPasswordDataResult->getPasswordData();
                if ($passwordData->isSetInstanceId()) {
                    echo "                    InstanceId\n";
                    echo "                        " . $passwordData->getInstanceId() . "\n";
                }
                if ($passwordData->isSetTimestamp()) {
                    echo "                    Timestamp\n";
                    echo "                        " . $passwordData->getTimestamp() . "\n";
                }
                if ($passwordData->isSetData()) {
                    echo "                    Data\n";
                    echo "                        " . $passwordData->getData() . "\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";
    }
}
/**
 * Monitor Instances Action Sample
 * Enables monitoring for a running instance.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_MonitorInstances or array of parameters
 */
function invokeMonitorInstances(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->monitorInstances($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        MonitorInstancesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetMonitorInstancesResult()) {
            echo "            MonitorInstancesResult\n";
            $monitorInstancesResult = $response->getMonitorInstancesResult();
            $instanceMonitoringList = $monitorInstancesResult->getInstanceMonitoring();
            foreach ($instanceMonitoringList as $instanceMonitoring) {
                echo "                InstanceMonitoring\n";
                if ($instanceMonitoring->isSetInstanceId()) {
                    echo "                    InstanceId\n";
                    echo "                        " . $instanceMonitoring->getInstanceId() . "\n";
                }
                if ($instanceMonitoring->isSetMonitoring()) {
                    echo "                    Monitoring\n";
                    $monitoring = $instanceMonitoring->getMonitoring();
                    if ($monitoring->isSetMonitoringState()) {
                        echo "                        MonitoringState\n";
                        echo "                            " . $monitoring->getMonitoringState() . "\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";
    }
}
/**
 * Attach Vpn Gateway Action Sample
 * Attaches a VPN gateway to a VPC. This is the last step required to get your
 * VPC fully connected to your data center before launching instances in it.
 * For more information, go to Process for Using Amazon VPC in the Amazon Virtual
 * Private Cloud Developer Guide.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_AttachVpnGateway or array of parameters
 */
function invokeAttachVpnGateway(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->attachVpnGateway($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        AttachVpnGatewayResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetAttachVpnGatewayResult()) {
            echo "            AttachVpnGatewayResult\n";
            $attachVpnGatewayResult = $response->getAttachVpnGatewayResult();
            if ($attachVpnGatewayResult->isSetVpcAttachment()) {
                echo "                VpcAttachment\n";
                $vpcAttachment = $attachVpnGatewayResult->getVpcAttachment();
                if ($vpcAttachment->isSetVpcId()) {
                    echo "                    VpcId\n";
                    echo "                        " . $vpcAttachment->getVpcId() . "\n";
                }
                if ($vpcAttachment->isSetVpcAttachmentState()) {
                    echo "                    VpcAttachmentState\n";
                    echo "                        " . $vpcAttachment->getVpcAttachmentState() . "\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";
    }
}
/**
 * Describe Regions Action Sample
 * The DescribeRegions operation describes regions zones that are currently available to the account.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeRegions or array of parameters
 */
function invokeDescribeRegions(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeRegions($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeRegionsResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeRegionsResult()) {
            echo "            DescribeRegionsResult\n";
            $describeRegionsResult = $response->getDescribeRegionsResult();
            $regionList = $describeRegionsResult->getRegion();
            foreach ($regionList as $region) {
                echo "                Region\n";
                if ($region->isSetRegionName()) {
                    echo "                    RegionName\n";
                    echo "                        " . $region->getRegionName() . "\n";
                }
                if ($region->isSetEndpoint()) {
                    echo "                    Endpoint\n";
                    echo "                        " . $region->getEndpoint() . "\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";
    }
}
/**
 * Describe Addresses Action Sample
 * The DescribeAddresses operation lists elastic IP addresses assigned to your
 * account.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeAddresses or array of parameters
 */
function invokeDescribeAddresses(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeAddresses($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeAddressesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeAddressesResult()) {
            echo "            DescribeAddressesResult\n";
            $describeAddressesResult = $response->getDescribeAddressesResult();
            $addressList = $describeAddressesResult->getAddress();
            foreach ($addressList as $address) {
                echo "                Address\n";
                if ($address->isSetInstanceId()) {
                    echo "                    InstanceId\n";
                    echo "                        " . $address->getInstanceId() . "\n";
                }
                if ($address->isSetPublicIp()) {
                    echo "                    PublicIp\n";
                    echo "                        " . $address->getPublicIp() . "\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";
    }
}
/**
 * Cancel Spot Instance Requests Action Sample
 * Cancels Spot Instance requests. 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_CancelSpotInstanceRequests or array of parameters
 */
function invokeCancelSpotInstanceRequests(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->cancelSpotInstanceRequests($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        CancelSpotInstanceRequestsResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetCancelSpotInstanceRequestsResult()) {
            echo "            CancelSpotInstanceRequestsResult\n";
            $cancelSpotInstanceRequestsResult = $response->getCancelSpotInstanceRequestsResult();
            $cancelledSpotInstanceRequestList = $cancelSpotInstanceRequestsResult->getCancelledSpotInstanceRequest();
            foreach ($cancelledSpotInstanceRequestList as $cancelledSpotInstanceRequest) {
                echo "                CancelledSpotInstanceRequest\n";
                if ($cancelledSpotInstanceRequest->isSetSpotInstanceRequestId()) {
                    echo "                    SpotInstanceRequestId\n";
                    echo "                        " . $cancelledSpotInstanceRequest->getSpotInstanceRequestId() . "\n";
                }
                if ($cancelledSpotInstanceRequest->isSetState()) {
                    echo "                    State\n";
                    echo "                        " . $cancelledSpotInstanceRequest->getState() . "\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";
    }
}
/**
 * Delete Security Group Action Sample
 * The DeleteSecurityGroup operation deletes a security group.
 * Note:
 * If you attempt to delete a security group that contains instances, a fault is
 * returned.
 * If you attempt to delete a security group that is referenced by another
 * security group, a fault is returned. For example, if security group B has a
 * rule that allows access from security group A, security group A cannot be
 * deleted until the allow rule is removed.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DeleteSecurityGroup or array of parameters
 */
function invokeDeleteSecurityGroup(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->deleteSecurityGroup($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DeleteSecurityGroupResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\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";
    }
}
/**
 * Modify Instance Attribute Action Sample
 * Modifies an attribute of an instance.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_ModifyInstanceAttribute or array of parameters
 */
function invokeModifyInstanceAttribute(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->modifyInstanceAttribute($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ModifyInstanceAttributeResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\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";
    }
}
/**
 * Describe Bundle Tasks Action Sample
 * The DescribeBundleTasks operation describes in-progress
 * and recent bundle tasks. Complete and failed tasks are
 * removed from the list a short time after completion.
 * If no bundle ids are given, all bundle tasks are returned.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeBundleTasks or array of parameters
 */
function invokeDescribeBundleTasks(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeBundleTasks($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeBundleTasksResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeBundleTasksResult()) {
            echo "            DescribeBundleTasksResult\n";
            $describeBundleTasksResult = $response->getDescribeBundleTasksResult();
            $bundleTaskList = $describeBundleTasksResult->getBundleTask();
            foreach ($bundleTaskList as $bundleTask) {
                echo "                BundleTask\n";
                if ($bundleTask->isSetInstanceId()) {
                    echo "                    InstanceId\n";
                    echo "                        " . $bundleTask->getInstanceId() . "\n";
                }
                if ($bundleTask->isSetBundleId()) {
                    echo "                    BundleId\n";
                    echo "                        " . $bundleTask->getBundleId() . "\n";
                }
                if ($bundleTask->isSetBundleState()) {
                    echo "                    BundleState\n";
                    echo "                        " . $bundleTask->getBundleState() . "\n";
                }
                if ($bundleTask->isSetStartTime()) {
                    echo "                    StartTime\n";
                    echo "                        " . $bundleTask->getStartTime() . "\n";
                }
                if ($bundleTask->isSetUpdateTime()) {
                    echo "                    UpdateTime\n";
                    echo "                        " . $bundleTask->getUpdateTime() . "\n";
                }
                if ($bundleTask->isSetStorage()) {
                    echo "                    Storage\n";
                    $storage = $bundleTask->getStorage();
                    if ($storage->isSetS3()) {
                        echo "                        S3\n";
                        $s3 = $storage->getS3();
                        if ($s3->isSetBucket()) {
                            echo "                            Bucket\n";
                            echo "                                " . $s3->getBucket() . "\n";
                        }
                        if ($s3->isSetPrefix()) {
                            echo "                            Prefix\n";
                            echo "                                " . $s3->getPrefix() . "\n";
                        }
                        if ($s3->isSetAWSAccessKeyId()) {
                            echo "                            AWSAccessKeyId\n";
                            echo "                                " . $s3->getAWSAccessKeyId() . "\n";
                        }
                        if ($s3->isSetUploadPolicy()) {
                            echo "                            UploadPolicy\n";
                            echo "                                " . $s3->getUploadPolicy() . "\n";
                        }
                        if ($s3->isSetUploadPolicySignature()) {
                            echo "                            UploadPolicySignature\n";
                            echo "                                " . $s3->getUploadPolicySignature() . "\n";
                        }
                    }
                }
                if ($bundleTask->isSetProgress()) {
                    echo "                    Progress\n";
                    echo "                        " . $bundleTask->getProgress() . "\n";
                }
                if ($bundleTask->isSetBundleTaskError()) {
                    echo "                    BundleTaskError\n";
                    $bundleTaskError = $bundleTask->getBundleTaskError();
                    if ($bundleTaskError->isSetCode()) {
                        echo "                        Code\n";
                        echo "                            " . $bundleTaskError->getCode() . "\n";
                    }
                    if ($bundleTaskError->isSetMessage()) {
                        echo "                        Message\n";
                        echo "                            " . $bundleTaskError->getMessage() . "\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";
    }
}
/**
 * Describe Images Action Sample
 * The DescribeImages operation returns information about AMIs, AKIs, and ARIs
 * available to the user. Information returned includes image type, product codes,
 * architecture, and kernel and RAM disk IDs. Images available to the user include
 * public images available for any user to launch, private images owned by the
 * user making the request, and private images owned by other users for which the
 * user has explicit launch permissions.
 * Launch permissions fall into three categories:
 * Public:
 * The owner of the AMI granted launch permissions for the AMI to the all group.
 * All users have launch permissions for these AMIs.
 * Explicit:
 * The owner of the AMI granted launch permissions to a specific user.
 * Implicit:
 * A user has implicit launch permissions for all AMIs he or she owns.
 * The list of AMIs returned can be modified by specifying AMI IDs, AMI owners, or
 * users with launch permissions. If no options are specified, Amazon EC2 returns
 * all AMIs for which the user has launch permissions.
 * If you specify one or more AMI IDs, only AMIs that have the specified IDs are
 * returned. If you specify an invalid AMI ID, a fault is returned. If you specify
 * an AMI ID for which you do not have access, it will not be included in the
 * returned results.
 * If you specify one or more AMI owners, only AMIs from the specified owners and
 * for which you have access are returned. The results can include the account IDs
 * of the specified owners, amazon for AMIs owned by Amazon or self for AMIs that
 * you own.
 * If you specify a list of executable users, only users that have launch
 * permissions for the AMIs are returned. You can specify account IDs (if you own
 * the AMI(s)), self for AMIs for which you own or have explicit permissions, or
 * all for public AMIs.
 * Note:
 * Deregistered images are included in the returned results for an unspecified
 * interval after deregistration.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeImages or array of parameters
 */
function invokeDescribeImages(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeImages($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeImagesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeImagesResult()) {
            echo "            DescribeImagesResult\n";
            $describeImagesResult = $response->getDescribeImagesResult();
            $imageList = $describeImagesResult->getImage();
            foreach ($imageList as $image) {
                echo "                Image\n";
                if ($image->isSetImageId()) {
                    echo "                    ImageId\n";
                    echo "                        " . $image->getImageId() . "\n";
                }
                if ($image->isSetImageLocation()) {
                    echo "                    ImageLocation\n";
                    echo "                        " . $image->getImageLocation() . "\n";
                }
                if ($image->isSetImageState()) {
                    echo "                    ImageState\n";
                    echo "                        " . $image->getImageState() . "\n";
                }
                if ($image->isSetOwnerId()) {
                    echo "                    OwnerId\n";
                    echo "                        " . $image->getOwnerId() . "\n";
                }
                if ($image->isSetVisibility()) {
                    echo "                    Visibility\n";
                    echo "                        " . $image->getVisibility() . "\n";
                }
                $productCodeList = $image->getProductCode();
                foreach ($productCodeList as $productCode) {
                    echo "                    ProductCode\n";
                    echo "                        " . $productCode;
                }
                if ($image->isSetArchitecture()) {
                    echo "                    Architecture\n";
                    echo "                        " . $image->getArchitecture() . "\n";
                }
                if ($image->isSetImageType()) {
                    echo "                    ImageType\n";
                    echo "                        " . $image->getImageType() . "\n";
                }
                if ($image->isSetKernelId()) {
                    echo "                    KernelId\n";
                    echo "                        " . $image->getKernelId() . "\n";
                }
                if ($image->isSetRamdiskId()) {
                    echo "                    RamdiskId\n";
                    echo "                        " . $image->getRamdiskId() . "\n";
                }
                if ($image->isSetPlatform()) {
                    echo "                    Platform\n";
                    echo "                        " . $image->getPlatform() . "\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";
    }
}
/**
 * Describe Instances Action Sample
 * The DescribeInstances operation returns information about instances that you
 * own.
 * If you specify one or more instance IDs, Amazon EC2 returns information for
 * those instances. If you do not specify instance IDs, Amazon EC2 returns
 * information for all relevant instances. If you specify an invalid instance ID,
 * a fault is returned. If you specify an instance that you do not own, it will
 * not be included in the returned results.
 * Recently terminated instances might appear in the returned results. This
 * interval is usually less than one hour.
 *   
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_DescribeInstances or array of parameters
 */
function invokeDescribeInstances(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->describeInstances($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        DescribeInstancesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetDescribeInstancesResult()) {
            echo "            DescribeInstancesResult\n";
            $describeInstancesResult = $response->getDescribeInstancesResult();
            $reservationList = $describeInstancesResult->getReservation();
            foreach ($reservationList as $reservation) {
                echo "                Reservation\n";
                if ($reservation->isSetReservationId()) {
                    echo "                    ReservationId\n";
                    echo "                        " . $reservation->getReservationId() . "\n";
                }
                if ($reservation->isSetOwnerId()) {
                    echo "                    OwnerId\n";
                    echo "                        " . $reservation->getOwnerId() . "\n";
                }
                if ($reservation->isSetRequesterId()) {
                    echo "                    RequesterId\n";
                    echo "                        " . $reservation->getRequesterId() . "\n";
                }
                $groupNameList = $reservation->getGroupName();
                foreach ($groupNameList as $groupName) {
                    echo "                    GroupName\n";
                    echo "                        " . $groupName;
                }
                $runningInstanceList = $reservation->getRunningInstance();
                foreach ($runningInstanceList as $runningInstance) {
                    echo "                    RunningInstance\n";
                    if ($runningInstance->isSetInstanceId()) {
                        echo "                        InstanceId\n";
                        echo "                            " . $runningInstance->getInstanceId() . "\n";
                    }
                    if ($runningInstance->isSetImageId()) {
                        echo "                        ImageId\n";
                        echo "                            " . $runningInstance->getImageId() . "\n";
                    }
                    if ($runningInstance->isSetInstanceState()) {
                        echo "                        InstanceState\n";
                        $instanceState = $runningInstance->getInstanceState();
                        if ($instanceState->isSetCode()) {
                            echo "                            Code\n";
                            echo "                                " . $instanceState->getCode() . "\n";
                        }
                        if ($instanceState->isSetName()) {
                            echo "                            Name\n";
                            echo "                                " . $instanceState->getName() . "\n";
                        }
                    }
                    if ($runningInstance->isSetPrivateDnsName()) {
                        echo "                        PrivateDnsName\n";
                        echo "                            " . $runningInstance->getPrivateDnsName() . "\n";
                    }
                    if ($runningInstance->isSetPublicDnsName()) {
                        echo "                        PublicDnsName\n";
                        echo "                            " . $runningInstance->getPublicDnsName() . "\n";
                    }
                    if ($runningInstance->isSetStateTransitionReason()) {
                        echo "                        StateTransitionReason\n";
                        echo "                            " . $runningInstance->getStateTransitionReason() . "\n";
                    }
                    if ($runningInstance->isSetKeyName()) {
                        echo "                        KeyName\n";
                        echo "                            " . $runningInstance->getKeyName() . "\n";
                    }
                    if ($runningInstance->isSetAmiLaunchIndex()) {
                        echo "                        AmiLaunchIndex\n";
                        echo "                            " . $runningInstance->getAmiLaunchIndex() . "\n";
                    }
                    $productCodeList = $runningInstance->getProductCode();
                    foreach ($productCodeList as $productCode) {
                        echo "                        ProductCode\n";
                        echo "                            " . $productCode;
                    }
                    if ($runningInstance->isSetInstanceType()) {
                        echo "                        InstanceType\n";
                        echo "                            " . $runningInstance->getInstanceType() . "\n";
                    }
                    if ($runningInstance->isSetLaunchTime()) {
                        echo "                        LaunchTime\n";
                        echo "                            " . $runningInstance->getLaunchTime() . "\n";
                    }
                    if ($runningInstance->isSetPlacement()) {
                        echo "                        Placement\n";
                        $placement = $runningInstance->getPlacement();
                        if ($placement->isSetAvailabilityZone()) {
                            echo "                            AvailabilityZone\n";
                            echo "                                " . $placement->getAvailabilityZone() . "\n";
                        }
                    }
                    if ($runningInstance->isSetKernelId()) {
                        echo "                        KernelId\n";
                        echo "                            " . $runningInstance->getKernelId() . "\n";
                    }
                    if ($runningInstance->isSetRamdiskId()) {
                        echo "                        RamdiskId\n";
                        echo "                            " . $runningInstance->getRamdiskId() . "\n";
                    }
                    if ($runningInstance->isSetPlatform()) {
                        echo "                        Platform\n";
                        echo "                            " . $runningInstance->getPlatform() . "\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";
    }
}
/**
 * Run Instances Action Sample
 * The RunInstances operation launches a specified number of instances.
 * If Amazon EC2 cannot launch the minimum number AMIs you request, no instances
 * launch. If there is insufficient capacity to launch the maximum number of AMIs
 * you request, Amazon EC2 launches as many as possible to satisfy the requested
 * maximum values.
 * Every instance is launched in a security group. If you do not specify a
 * security group at launch, the instances start in your default security group.
 * For more information on creating security groups, see CreateSecurityGroup.
 * An optional instance type can be specified. For information about instance
 * types, see Instance Types.
 * You can provide an optional key pair ID for each image in the launch request
 * (for more information, see CreateKeyPair). All instances that are created from
 * images that use this key pair will have access to the associated public key at
 * boot. You can use this key to provide secure access to an instance of an image
 * on a per-instance basis. Amazon EC2 public images use this feature to provide
 * secure access without passwords.
 * Important:
 * Launching public images without a key pair ID will leave them inaccessible.
 * The public key material is made available to the instance at boot time by
 * placing it in the openssh_id.pub file on a logical device that is exposed to
 * the instance as /dev/sda2 (the ephemeral store). The format of this file is
 * suitable for use as an entry within ~/.ssh/authorized_keys (the OpenSSH
 * format). This can be done at boot (e.g., as part of rc.local) allowing for
 * secure access without passwords.
 * Optional user data can be provided in the launch request. All instances that
 * collectively comprise the launch request have access to this data For more
 * information, see Instance Metadata.
 * Note:
 * If any of the AMIs have a product code attached for which the user has not
 * subscribed, the RunInstances call will fail.
 * Important:
 * We strongly recommend using the 2.6.18 Xen stock kernel with the c1.medium and
 * c1.xlarge instances. Although the default Amazon EC2 kernels will work, the new
 * kernels provide greater stability and performance for these instance types. For
 * more information about kernels, see Kernels, RAM Disks, and Block Device
 * Mappings.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_RunInstances or array of parameters
 */
function invokeRunInstances(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->runInstances($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        RunInstancesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetRunInstancesResult()) {
            echo "            RunInstancesResult\n";
            $runInstancesResult = $response->getRunInstancesResult();
            if ($runInstancesResult->isSetReservation()) {
                echo "                Reservation\n";
                $reservation = $runInstancesResult->getReservation();
                if ($reservation->isSetReservationId()) {
                    echo "                    ReservationId\n";
                    echo "                        " . $reservation->getReservationId() . "\n";
                }
                if ($reservation->isSetOwnerId()) {
                    echo "                    OwnerId\n";
                    echo "                        " . $reservation->getOwnerId() . "\n";
                }
                if ($reservation->isSetRequesterId()) {
                    echo "                    RequesterId\n";
                    echo "                        " . $reservation->getRequesterId() . "\n";
                }
                $groupNameList = $reservation->getGroupName();
                foreach ($groupNameList as $groupName) {
                    echo "                    GroupName\n";
                    echo "                        " . $groupName;
                }
                $runningInstanceList = $reservation->getRunningInstance();
                foreach ($runningInstanceList as $runningInstance) {
                    echo "                    RunningInstance\n";
                    if ($runningInstance->isSetInstanceId()) {
                        echo "                        InstanceId\n";
                        echo "                            " . $runningInstance->getInstanceId() . "\n";
                    }
                    if ($runningInstance->isSetImageId()) {
                        echo "                        ImageId\n";
                        echo "                            " . $runningInstance->getImageId() . "\n";
                    }
                    if ($runningInstance->isSetInstanceState()) {
                        echo "                        InstanceState\n";
                        $instanceState = $runningInstance->getInstanceState();
                        if ($instanceState->isSetCode()) {
                            echo "                            Code\n";
                            echo "                                " . $instanceState->getCode() . "\n";
                        }
                        if ($instanceState->isSetName()) {
                            echo "                            Name\n";
                            echo "                                " . $instanceState->getName() . "\n";
                        }
                    }
                    if ($runningInstance->isSetPrivateDnsName()) {
                        echo "                        PrivateDnsName\n";
                        echo "                            " . $runningInstance->getPrivateDnsName() . "\n";
                    }
                    if ($runningInstance->isSetPublicDnsName()) {
                        echo "                        PublicDnsName\n";
                        echo "                            " . $runningInstance->getPublicDnsName() . "\n";
                    }
                    if ($runningInstance->isSetStateTransitionReason()) {
                        echo "                        StateTransitionReason\n";
                        echo "                            " . $runningInstance->getStateTransitionReason() . "\n";
                    }
                    if ($runningInstance->isSetKeyName()) {
                        echo "                        KeyName\n";
                        echo "                            " . $runningInstance->getKeyName() . "\n";
                    }
                    if ($runningInstance->isSetAmiLaunchIndex()) {
                        echo "                        AmiLaunchIndex\n";
                        echo "                            " . $runningInstance->getAmiLaunchIndex() . "\n";
                    }
                    $productCodeList = $runningInstance->getProductCode();
                    foreach ($productCodeList as $productCode) {
                        echo "                        ProductCode\n";
                        echo "                            " . $productCode;
                    }
                    if ($runningInstance->isSetInstanceType()) {
                        echo "                        InstanceType\n";
                        echo "                            " . $runningInstance->getInstanceType() . "\n";
                    }
                    if ($runningInstance->isSetLaunchTime()) {
                        echo "                        LaunchTime\n";
                        echo "                            " . $runningInstance->getLaunchTime() . "\n";
                    }
                    if ($runningInstance->isSetPlacement()) {
                        echo "                        Placement\n";
                        $placement = $runningInstance->getPlacement();
                        if ($placement->isSetAvailabilityZone()) {
                            echo "                            AvailabilityZone\n";
                            echo "                                " . $placement->getAvailabilityZone() . "\n";
                        }
                    }
                    if ($runningInstance->isSetKernelId()) {
                        echo "                        KernelId\n";
                        echo "                            " . $runningInstance->getKernelId() . "\n";
                    }
                    if ($runningInstance->isSetRamdiskId()) {
                        echo "                        RamdiskId\n";
                        echo "                            " . $runningInstance->getRamdiskId() . "\n";
                    }
                    if ($runningInstance->isSetPlatform()) {
                        echo "                        Platform\n";
                        echo "                            " . $runningInstance->getPlatform() . "\n";
                    }
                    if ($runningInstance->isSetMonitoring()) {
                        echo "                        Monitoring\n";
                        $monitoring = $runningInstance->getMonitoring();
                        if ($monitoring->isSetMonitoringState()) {
                            echo "                            MonitoringState\n";
                            echo "                                " . $monitoring->getMonitoringState() . "\n";
                        }
                    }
                    if ($runningInstance->isSetSubnetId()) {
                        echo "                        SubnetId\n";
                        echo "                            " . $runningInstance->getSubnetId() . "\n";
                    }
                    if ($runningInstance->isSetVpcId()) {
                        echo "                        VpcId\n";
                        echo "                            " . $runningInstance->getVpcId() . "\n";
                    }
                    if ($runningInstance->isSetPrivateIpAddress()) {
                        echo "                        PrivateIpAddress\n";
                        echo "                            " . $runningInstance->getPrivateIpAddress() . "\n";
                    }
                    if ($runningInstance->isSetIpAddress()) {
                        echo "                        IpAddress\n";
                        echo "                            " . $runningInstance->getIpAddress() . "\n";
                    }
                    if ($runningInstance->isSetStateReason()) {
                        echo "                        StateReason\n";
                        $stateReason = $runningInstance->getStateReason();
                        if ($stateReason->isSetCode()) {
                            echo "                            Code\n";
                            echo "                                " . $stateReason->getCode() . "\n";
                        }
                        if ($stateReason->isSetMessage()) {
                            echo "                            Message\n";
                            echo "                                " . $stateReason->getMessage() . "\n";
                        }
                    }
                    if ($runningInstance->isSetArchitecture()) {
                        echo "                        Architecture\n";
                        echo "                            " . $runningInstance->getArchitecture() . "\n";
                    }
                    if ($runningInstance->isSetRootDeviceType()) {
                        echo "                        RootDeviceType\n";
                        echo "                            " . $runningInstance->getRootDeviceType() . "\n";
                    }
                    if ($runningInstance->isSetRootDeviceName()) {
                        echo "                        RootDeviceName\n";
                        echo "                            " . $runningInstance->getRootDeviceName() . "\n";
                    }
                    $blockDeviceMappingList = $runningInstance->getBlockDeviceMapping();
                    foreach ($blockDeviceMappingList as $blockDeviceMapping) {
                        echo "                        BlockDeviceMapping\n";
                        if ($blockDeviceMapping->isSetDeviceName()) {
                            echo "                            DeviceName\n";
                            echo "                                " . $blockDeviceMapping->getDeviceName() . "\n";
                        }
                        if ($blockDeviceMapping->isSetEbs()) {
                            echo "                            Ebs\n";
                            $ebs = $blockDeviceMapping->getEbs();
                            if ($ebs->isSetVolumeId()) {
                                echo "                                VolumeId\n";
                                echo "                                    " . $ebs->getVolumeId() . "\n";
                            }
                            if ($ebs->isSetStatus()) {
                                echo "                                Status\n";
                                echo "                                    " . $ebs->getStatus() . "\n";
                            }
                            if ($ebs->isSetAttachTime()) {
                                echo "                                AttachTime\n";
                                echo "                                    " . $ebs->getAttachTime() . "\n";
                            }
                            if ($ebs->isSetDeleteOnTermination()) {
                                echo "                                DeleteOnTermination\n";
                                echo "                                    " . $ebs->getDeleteOnTermination() . "\n";
                            }
                        }
                    }
                    if ($runningInstance->isSetInstanceLifecycle()) {
                        echo "                        InstanceLifecycle\n";
                        echo "                            " . $runningInstance->getInstanceLifecycle() . "\n";
                    }
                    if ($runningInstance->isSetSpotInstanceRequestId()) {
                        echo "                        SpotInstanceRequestId\n";
                        echo "                            " . $runningInstance->getSpotInstanceRequestId() . "\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";
    }
}