/**
* 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";
}
}
/**
* 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";
}
}
/**
* 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";
}
}
请发表评论