/** * Describe Key Pairs Action Sample * The DescribeKeyPairs operation returns information about key pairs available to * you. If you specify key pairs, information about those key pairs is returned. * Otherwise, information for all registered key pairs is returned. * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface * @param mixed $request Amazon_EC2_Model_DescribeKeyPairs or array of parameters */ function invokeDescribeKeyPairs(Amazon_EC2_Interface $service, $request) { try { $response = $service->describeKeyPairs($request); echo "Service Response\n"; echo "=============================================================================\n"; echo " DescribeKeyPairsResponse\n"; if ($response->isSetResponseMetadata()) { echo " ResponseMetadata\n"; $responseMetadata = $response->getResponseMetadata(); if ($responseMetadata->isSetRequestId()) { echo " RequestId\n"; echo " " . $responseMetadata->getRequestId() . "\n"; } } if ($response->isSetDescribeKeyPairsResult()) { echo " DescribeKeyPairsResult\n"; $describeKeyPairsResult = $response->getDescribeKeyPairsResult(); $keyPairList = $describeKeyPairsResult->getKeyPair(); foreach ($keyPairList as $keyPair) { echo " KeyPair\n"; 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"; } }