Amazon.EC2.AmazonEC2Client.DescribeKeyPairs C# (CSharp) Method

DescribeKeyPairs() private method

private DescribeKeyPairs ( ) : DescribeKeyPairsResponse
return DescribeKeyPairsResponse
        internal DescribeKeyPairsResponse DescribeKeyPairs()
        {
            return DescribeKeyPairs(new DescribeKeyPairsRequest());
        }
        internal DescribeKeyPairsResponse DescribeKeyPairs(DescribeKeyPairsRequest request)

Same methods

AmazonEC2Client::DescribeKeyPairs ( DescribeKeyPairsRequest request ) : DescribeKeyPairsResponse

Usage Example

 /// <summary>
 /// Load key pairs to view model with AWS data based on region selected and EC2 classic/vpc
 /// </summary>
 private void LoadKeyPairs(AmazonEC2Client ec2Client)
 {
     try
     {
         DescribeKeyPairsRequest keyreq = new DescribeKeyPairsRequest();
         DescribeKeyPairsResponse keyresp = ec2Client.DescribeKeyPairs(keyreq);
         Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
         {
             vm.KeyPairs.Clear();
         }));
         foreach (KeyPair kp in keyresp.DescribeKeyPairsResult.KeyPair)
         {
             Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
             {
                 vm.KeyPairs.Add(kp.KeyName);
             }));
         }
     }
     catch (Exception ex)
     {
         LogManager.LogEntry(ex.Message);
         LogManager.LogEntry(ex.StackTrace);
         throw new DataLoadingException("Error occurred loading key pairs for region and environment type");
     }
 }
AmazonEC2Client