/// <summary> /// The DeleteKeyPair operation deletes a key pair. /// /// </summary> /// <param name="service">Instance of AmazonEC2 service</param> /// <param name="request">DeleteKeyPairRequest request</param> public static void InvokeDeleteKeyPair(AmazonEC2 service, DeleteKeyPairRequest request) { try { DeleteKeyPairResponse response = service.DeleteKeyPair(request); Console.WriteLine ("Service Response"); Console.WriteLine ("============================================================================="); Console.WriteLine (); Console.WriteLine(" DeleteKeyPairResponse"); if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { Console.WriteLine(" RequestId"); Console.WriteLine(" {0}", responseMetadata.RequestId); } } } catch (AmazonEC2Exception ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); } }