/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the ec2-instance-connect-2018-04-02.normal.json service model.
*/
using System;
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Net;
using Amazon.EC2InstanceConnect.Model;
using Amazon.EC2InstanceConnect.Model.Internal.MarshallTransformations;
using Amazon.EC2InstanceConnect.Internal;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Auth;
using Amazon.Runtime.Internal.Transform;
namespace Amazon.EC2InstanceConnect
{
///
/// Implementation for accessing EC2InstanceConnect
///
/// Amazon EC2 Instance Connect enables system administrators to publish one-time use
/// SSH public keys to EC2, providing users a simple and secure way to connect to their
/// instances.
///
public partial class AmazonEC2InstanceConnectClient : AmazonServiceClient, IAmazonEC2InstanceConnect
{
private static IServiceMetadata serviceMetadata = new AmazonEC2InstanceConnectMetadata();
#region Constructors
///
/// Constructs AmazonEC2InstanceConnectClient with the credentials loaded from the application's
/// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
///
/// Example App.config with credentials set.
///
/// <?xml version="1.0" encoding="utf-8" ?>
/// <configuration>
/// <appSettings>
/// <add key="AWSProfileName" value="AWS Default"/>
/// </appSettings>
/// </configuration>
///
///
///
public AmazonEC2InstanceConnectClient()
: base(FallbackCredentialsFactory.GetCredentials(), new AmazonEC2InstanceConnectConfig()) { }
///
/// Constructs AmazonEC2InstanceConnectClient with the credentials loaded from the application's
/// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
///
/// Example App.config with credentials set.
///
/// <?xml version="1.0" encoding="utf-8" ?>
/// <configuration>
/// <appSettings>
/// <add key="AWSProfileName" value="AWS Default"/>
/// </appSettings>
/// </configuration>
///
///
///
/// The region to connect.
public AmazonEC2InstanceConnectClient(RegionEndpoint region)
: base(FallbackCredentialsFactory.GetCredentials(), new AmazonEC2InstanceConnectConfig{RegionEndpoint = region}) { }
///
/// Constructs AmazonEC2InstanceConnectClient with the credentials loaded from the application's
/// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
///
/// Example App.config with credentials set.
///
/// <?xml version="1.0" encoding="utf-8" ?>
/// <configuration>
/// <appSettings>
/// <add key="AWSProfileName" value="AWS Default"/>
/// </appSettings>
/// </configuration>
///
///
///
/// The AmazonEC2InstanceConnectClient Configuration Object
public AmazonEC2InstanceConnectClient(AmazonEC2InstanceConnectConfig config)
: base(FallbackCredentialsFactory.GetCredentials(config), config){}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Credentials
///
/// AWS Credentials
public AmazonEC2InstanceConnectClient(AWSCredentials credentials)
: this(credentials, new AmazonEC2InstanceConnectConfig())
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Credentials
///
/// AWS Credentials
/// The region to connect.
public AmazonEC2InstanceConnectClient(AWSCredentials credentials, RegionEndpoint region)
: this(credentials, new AmazonEC2InstanceConnectConfig{RegionEndpoint = region})
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Credentials and an
/// AmazonEC2InstanceConnectClient Configuration object.
///
/// AWS Credentials
/// The AmazonEC2InstanceConnectClient Configuration Object
public AmazonEC2InstanceConnectClient(AWSCredentials credentials, AmazonEC2InstanceConnectConfig clientConfig)
: base(credentials, clientConfig)
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Access Key ID and AWS Secret Key
///
/// AWS Access Key ID
/// AWS Secret Access Key
public AmazonEC2InstanceConnectClient(string awsAccessKeyId, string awsSecretAccessKey)
: this(awsAccessKeyId, awsSecretAccessKey, new AmazonEC2InstanceConnectConfig())
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Access Key ID and AWS Secret Key
///
/// AWS Access Key ID
/// AWS Secret Access Key
/// The region to connect.
public AmazonEC2InstanceConnectClient(string awsAccessKeyId, string awsSecretAccessKey, RegionEndpoint region)
: this(awsAccessKeyId, awsSecretAccessKey, new AmazonEC2InstanceConnectConfig() {RegionEndpoint=region})
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Access Key ID, AWS Secret Key and an
/// AmazonEC2InstanceConnectClient Configuration object.
///
/// AWS Access Key ID
/// AWS Secret Access Key
/// The AmazonEC2InstanceConnectClient Configuration Object
public AmazonEC2InstanceConnectClient(string awsAccessKeyId, string awsSecretAccessKey, AmazonEC2InstanceConnectConfig clientConfig)
: base(awsAccessKeyId, awsSecretAccessKey, clientConfig)
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Access Key ID and AWS Secret Key
///
/// AWS Access Key ID
/// AWS Secret Access Key
/// AWS Session Token
public AmazonEC2InstanceConnectClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken)
: this(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, new AmazonEC2InstanceConnectConfig())
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Access Key ID and AWS Secret Key
///
/// AWS Access Key ID
/// AWS Secret Access Key
/// AWS Session Token
/// The region to connect.
public AmazonEC2InstanceConnectClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, RegionEndpoint region)
: this(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, new AmazonEC2InstanceConnectConfig{RegionEndpoint = region})
{
}
///
/// Constructs AmazonEC2InstanceConnectClient with AWS Access Key ID, AWS Secret Key and an
/// AmazonEC2InstanceConnectClient Configuration object.
///
/// AWS Access Key ID
/// AWS Secret Access Key
/// AWS Session Token
/// The AmazonEC2InstanceConnectClient Configuration Object
public AmazonEC2InstanceConnectClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonEC2InstanceConnectConfig clientConfig)
: base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig)
{
}
#endregion
#region Overrides
///
/// Creates the signer for the service.
///
protected override AbstractAWSSigner CreateSigner()
{
return new AWS4Signer();
}
///
/// Customize the pipeline
///
///
protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
{
pipeline.RemoveHandler();
pipeline.AddHandlerAfter(new AmazonEC2InstanceConnectEndpointResolver());
}
///
/// Capture metadata for the service.
///
protected override IServiceMetadata ServiceMetadata
{
get
{
return serviceMetadata;
}
}
#endregion
#region Dispose
///
/// Disposes the service client.
///
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
#endregion
#region SendSerialConsoleSSHPublicKey
///
/// Pushes an SSH public key to the specified EC2 instance. The key remains for 60 seconds,
/// which gives you 60 seconds to establish a serial console connection to the instance
/// using SSH. For more information, see EC2
/// Serial Console in the Amazon EC2 User Guide.
///
/// Container for the necessary parameters to execute the SendSerialConsoleSSHPublicKey service method.
///
/// The response from the SendSerialConsoleSSHPublicKey service method, as returned by EC2InstanceConnect.
///
/// Either your AWS credentials are not valid or you do not have access to the EC2 instance.
///
///
/// The specified instance was not found.
///
///
/// Unable to connect because the instance is not in a valid state. Connecting to a stopped
/// or terminated instance is not supported. If the instance is stopped, start your instance,
/// and try to connect again.
///
///
/// The instance type is not supported for connecting via the serial console. Only Nitro
/// instance types are currently supported.
///
///
/// The instance is currently unavailable. Wait a few minutes and try again.
///
///
/// One of the parameters is not valid.
///
///
/// Your account is not authorized to use the EC2 Serial Console. To authorize your account,
/// run the EnableSerialConsoleAccess API. For more information, see EnableSerialConsoleAccess
/// in the Amazon EC2 API Reference.
///
///
/// The instance currently has 1 active serial console session. Only 1 session is supported
/// at a time.
///
///
/// Unable to start a serial console session. Please try again.
///
///
/// The service encountered an error. Follow the instructions in the error message and
/// try again.
///
///
/// The requests were made too frequently and have been throttled. Wait a while and try
/// again. To increase the limit on your request frequency, contact AWS Support.
///
/// REST API Reference for SendSerialConsoleSSHPublicKey Operation
public virtual SendSerialConsoleSSHPublicKeyResponse SendSerialConsoleSSHPublicKey(SendSerialConsoleSSHPublicKeyRequest request)
{
var options = new InvokeOptions();
options.RequestMarshaller = SendSerialConsoleSSHPublicKeyRequestMarshaller.Instance;
options.ResponseUnmarshaller = SendSerialConsoleSSHPublicKeyResponseUnmarshaller.Instance;
return Invoke(request, options);
}
///
/// Pushes an SSH public key to the specified EC2 instance. The key remains for 60 seconds,
/// which gives you 60 seconds to establish a serial console connection to the instance
/// using SSH. For more information, see EC2
/// Serial Console in the Amazon EC2 User Guide.
///
/// Container for the necessary parameters to execute the SendSerialConsoleSSHPublicKey service method.
///
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
///
///
/// The response from the SendSerialConsoleSSHPublicKey service method, as returned by EC2InstanceConnect.
///
/// Either your AWS credentials are not valid or you do not have access to the EC2 instance.
///
///
/// The specified instance was not found.
///
///
/// Unable to connect because the instance is not in a valid state. Connecting to a stopped
/// or terminated instance is not supported. If the instance is stopped, start your instance,
/// and try to connect again.
///
///
/// The instance type is not supported for connecting via the serial console. Only Nitro
/// instance types are currently supported.
///
///
/// The instance is currently unavailable. Wait a few minutes and try again.
///
///
/// One of the parameters is not valid.
///
///
/// Your account is not authorized to use the EC2 Serial Console. To authorize your account,
/// run the EnableSerialConsoleAccess API. For more information, see EnableSerialConsoleAccess
/// in the Amazon EC2 API Reference.
///
///
/// The instance currently has 1 active serial console session. Only 1 session is supported
/// at a time.
///
///
/// Unable to start a serial console session. Please try again.
///
///
/// The service encountered an error. Follow the instructions in the error message and
/// try again.
///
///
/// The requests were made too frequently and have been throttled. Wait a while and try
/// again. To increase the limit on your request frequency, contact AWS Support.
///
/// REST API Reference for SendSerialConsoleSSHPublicKey Operation
public virtual Task SendSerialConsoleSSHPublicKeyAsync(SendSerialConsoleSSHPublicKeyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
{
var options = new InvokeOptions();
options.RequestMarshaller = SendSerialConsoleSSHPublicKeyRequestMarshaller.Instance;
options.ResponseUnmarshaller = SendSerialConsoleSSHPublicKeyResponseUnmarshaller.Instance;
return InvokeAsync(request, options, cancellationToken);
}
#endregion
#region SendSSHPublicKey
///
/// Pushes an SSH public key to the specified EC2 instance for use by the specified user.
/// The key remains for 60 seconds. For more information, see Connect
/// to your Linux instance using EC2 Instance Connect in the Amazon EC2 User Guide.
///
/// Container for the necessary parameters to execute the SendSSHPublicKey service method.
///
/// The response from the SendSSHPublicKey service method, as returned by EC2InstanceConnect.
///
/// Either your AWS credentials are not valid or you do not have access to the EC2 instance.
///
///
/// The specified instance was not found.
///
///
/// Unable to connect because the instance is not in a valid state. Connecting to a stopped
/// or terminated instance is not supported. If the instance is stopped, start your instance,
/// and try to connect again.
///
///
/// The instance is currently unavailable. Wait a few minutes and try again.
///
///
/// One of the parameters is not valid.
///
///
/// The service encountered an error. Follow the instructions in the error message and
/// try again.
///
///
/// The requests were made too frequently and have been throttled. Wait a while and try
/// again. To increase the limit on your request frequency, contact AWS Support.
///
/// REST API Reference for SendSSHPublicKey Operation
public virtual SendSSHPublicKeyResponse SendSSHPublicKey(SendSSHPublicKeyRequest request)
{
var options = new InvokeOptions();
options.RequestMarshaller = SendSSHPublicKeyRequestMarshaller.Instance;
options.ResponseUnmarshaller = SendSSHPublicKeyResponseUnmarshaller.Instance;
return Invoke(request, options);
}
///
/// Pushes an SSH public key to the specified EC2 instance for use by the specified user.
/// The key remains for 60 seconds. For more information, see Connect
/// to your Linux instance using EC2 Instance Connect in the Amazon EC2 User Guide.
///
/// Container for the necessary parameters to execute the SendSSHPublicKey service method.
///
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
///
///
/// The response from the SendSSHPublicKey service method, as returned by EC2InstanceConnect.
///
/// Either your AWS credentials are not valid or you do not have access to the EC2 instance.
///
///
/// The specified instance was not found.
///
///
/// Unable to connect because the instance is not in a valid state. Connecting to a stopped
/// or terminated instance is not supported. If the instance is stopped, start your instance,
/// and try to connect again.
///
///
/// The instance is currently unavailable. Wait a few minutes and try again.
///
///
/// One of the parameters is not valid.
///
///
/// The service encountered an error. Follow the instructions in the error message and
/// try again.
///
///
/// The requests were made too frequently and have been throttled. Wait a while and try
/// again. To increase the limit on your request frequency, contact AWS Support.
///
/// REST API Reference for SendSSHPublicKey Operation
public virtual Task SendSSHPublicKeyAsync(SendSSHPublicKeyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
{
var options = new InvokeOptions();
options.RequestMarshaller = SendSSHPublicKeyRequestMarshaller.Instance;
options.ResponseUnmarshaller = SendSSHPublicKeyResponseUnmarshaller.Instance;
return InvokeAsync(request, options, cancellationToken);
}
#endregion
}
}