Configuration for accessing Amazon ElasticLoadBalancing service
Inheritance: Amazon.Runtime.ClientConfig
        /**
         * Configure HttpClient with set of defaults as well as configuration
         * from AmazonElasticLoadBalancingConfig instance
         */
        private static HttpWebRequest ConfigureWebRequest(int contentLength, AmazonElasticLoadBalancingConfig config)
        {
            HttpWebRequest request = WebRequest.Create(config.ServiceURL) as HttpWebRequest;

            if (request != null)
            {
                if (config.IsSetProxyHost() && config.IsSetProxyPort())
                {
                    WebProxy proxy = new WebProxy(config.ProxyHost, config.ProxyPort);
                    if (config.IsSetProxyUsername())
                    {
                        proxy.Credentials = new NetworkCredential(
                            config.ProxyUsername,
                            config.ProxyPassword ?? String.Empty
                            );
                    }
                    request.Proxy = proxy;
                }
                request.UserAgent     = config.UserAgent;
                request.Method        = "POST";
                request.Timeout       = 50000;
                request.ContentType   = AWSSDKUtils.UrlEncodedContent;
                request.ContentLength = contentLength;
            }

            return(request);
        }
Exemplo n.º 2
0
 public AmazonElasticLoadBalancingClient(string awsAccessKeyId, SecureString awsSecretAccessKey, AmazonElasticLoadBalancingConfig config)
 {
     this.awsAccessKeyId     = awsAccessKeyId;
     this.awsSecretAccessKey = awsSecretAccessKey;
     this.config             = config;
     ServicePointManager.Expect100Continue = false;
     ServicePointManager.UseNagleAlgorithm = false;
 }
Exemplo n.º 3
0
        private static HttpWebRequest ConfigureWebRequest(int contentLength, AmazonElasticLoadBalancingConfig config)
        {
            HttpWebRequest request = WebRequest.Create(config.ServiceURL) as HttpWebRequest;

            if (request != null)
            {
                if (config.IsSetProxyHost() && config.IsSetProxyPort())
                {
                    WebProxy proxy = new WebProxy(config.ProxyHost, config.ProxyPort);
                    if (config.IsSetProxyUsername())
                    {
                        proxy.Credentials = new NetworkCredential(config.ProxyUsername, config.ProxyPassword ?? string.Empty);
                    }
                    request.Proxy = proxy;
                }
                request.UserAgent     = config.UserAgent;
                request.Method        = "POST";
                request.Timeout       = 0xc350;
                request.ContentType   = "application/x-www-form-urlencoded; charset=utf-8";
                request.ContentLength = contentLength;
            }
            return(request);
        }
Exemplo n.º 4
0
 public AmazonElasticLoadBalancingClient(string awsAccessKeyId, string awsSecretAccessKey, AmazonElasticLoadBalancingConfig config)
 {
     if (!string.IsNullOrEmpty(awsSecretAccessKey))
     {
         if (config.UseSecureStringForAwsSecretKey)
         {
             this.awsSecretAccessKey = new SecureString();
             foreach (char ch in awsSecretAccessKey.ToCharArray())
             {
                 this.awsSecretAccessKey.AppendChar(ch);
             }
             this.awsSecretAccessKey.MakeReadOnly();
         }
         else
         {
             this.clearAwsSecretAccessKey = awsSecretAccessKey;
         }
     }
     this.awsAccessKeyId = awsAccessKeyId;
     this.config         = config;
     ServicePointManager.Expect100Continue = false;
     ServicePointManager.UseNagleAlgorithm = false;
 }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient with AWS Credentials and an
 /// AmazonElasticLoadBalancingClient Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="clientConfig">The AmazonElasticLoadBalancingClient Configuration Object</param>
 public AmazonElasticLoadBalancingClient(AWSCredentials credentials, AmazonElasticLoadBalancingConfig clientConfig)
     : base(credentials, clientConfig)
 {
 }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonElasticLoadBalancingClient Configuration object. 
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="awsSessionToken">AWS Session Token</param>
 /// <param name="clientConfig">The AmazonElasticLoadBalancingClient Configuration Object</param>
 public AmazonElasticLoadBalancingClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonElasticLoadBalancingConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Create a client for the Amazon ElasticLoadBalancing Service with AWSCredentials and an AmazonElasticLoadBalancing Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param>
 /// <returns>An Amazon ElasticLoadBalancing client</returns>
 /// <remarks>
 /// </remarks>
 public static IAmazonElasticLoadBalancing CreateAmazonElasticLoadBalancingClient(AWSCredentials credentials, AmazonElasticLoadBalancingConfig config)
 {
     return new AmazonElasticLoadBalancingClient(credentials, config);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create a client for the Amazon ElasticLoadBalancing Service with the specified configuration
 /// </summary>
 /// <param name="awsAccessKey">The AWS Access Key associated with the account</param>
 /// <param name="awsSecretAccessKey">The AWS Secret Access Key associated with the account</param>
 /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc
 /// </param>
 /// <returns>An Amazon ElasticLoadBalancing client</returns>
 /// <remarks>
 /// </remarks>
 public static IAmazonElasticLoadBalancing CreateAmazonElasticLoadBalancingClient(
     string awsAccessKey,
     string awsSecretAccessKey, AmazonElasticLoadBalancingConfig config
     )
 {
     return new AmazonElasticLoadBalancingClient(awsAccessKey, awsSecretAccessKey, config);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Create a client for the Amazon ElasticLoadBalancing Service 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. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 /// </summary>
 /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param>
 /// <returns>An Amazon ElasticLoadBalancing client</returns>
 public static AmazonElasticLoadBalancing CreateAmazonElasticLoadBalancingClient(AmazonElasticLoadBalancingConfig config)
 {
     return new AmazonElasticLoadBalancingClient(config);
 }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient 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. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSProfileName" value="AWS Default"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonElasticLoadBalancingClient Configuration Object</param>
 public AmazonElasticLoadBalancingClient(AmazonElasticLoadBalancingConfig config)
     : base(FallbackCredentialsFactory.GetCredentials(), config) { }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient with the credentials defined in the App.config.
 /// 
 /// Example App.config with credentials set. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonElasticLoadBalancing Configuration Object</param>
 public AmazonElasticLoadBalancingClient(AmazonElasticLoadBalancingConfig config)
     : base(new EnvironmentAWSCredentials(), config, true, AuthenticationTypes.User)
 {
 }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonElasticLoadBalancingClient Configuration object. If the config object's
 /// UseSecureStringForAwsSecretKey is false, the AWS Secret Key
 /// is stored as a clear-text string. Please use this option only
 /// if the application environment doesn't allow the use of SecureStrings.
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="clientConfig">The AmazonElasticLoadBalancingClient Configuration Object</param>
 public AmazonElasticLoadBalancingClient(string awsAccessKeyId, string awsSecretAccessKey, AmazonElasticLoadBalancingConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, clientConfig, AuthenticationTypes.User)
 {
 }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient with AWS Credentials and an
 /// AmazonElasticLoadBalancingClient Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="clientConfig">The AmazonElasticLoadBalancingClient Configuration Object</param>
 public AmazonElasticLoadBalancingClient(AWSCredentials credentials, AmazonElasticLoadBalancingConfig clientConfig)
     : base(credentials, clientConfig, false, AuthenticationTypes.User)
 {
 }
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient 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. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonElasticLoadBalancing Configuration Object</param>
 public AmazonElasticLoadBalancingClient(AmazonElasticLoadBalancingConfig config)
     : base(FallbackCredentialsFactory.GetCredentials(), config, AuthenticationTypes.User | AuthenticationTypes.Session) { }
        /// <summary>
        /// Creates AWS Elastic Load Balancing client
        /// </summary>
        /// <returns>AmazonElasticLoadBalancingClient</returns>
        private AmazonElasticLoadBalancingClient GetElbClient()
        {
            if (vm.Region == null)
            {
                throw new InvalidRegionException("No region defined when creating elastic load balancing client");
            }

            AmazonElasticLoadBalancingConfig config = new AmazonElasticLoadBalancingConfig();
            config.ServiceURL = vm.Region.ElbUrl;

            AmazonElasticLoadBalancingClient client = new AmazonElasticLoadBalancingClient(config);

            return client;
        }
Exemplo n.º 16
0
 /// <summary>
 /// Constructs AmazonElasticLoadBalancingClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonElasticLoadBalancingClient Configuration object. If the config object's
 /// UseSecureStringForAwsSecretKey is false, the AWS Secret Key
 /// is stored as a clear-text string. Please use this option only
 /// if the application environment doesn't allow the use of SecureStrings.
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="clientConfig">The AmazonElasticLoadBalancingClient Configuration Object</param>
 public AmazonElasticLoadBalancingClient(string awsAccessKeyId, string awsSecretAccessKey, AmazonElasticLoadBalancingConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, clientConfig)
 {
 }