/// <summary>
        /// Removes the specified Availability Zones from the set of Availability Zones for the specified load balancer.
        /// There must be at least one Availability Zone registered with a load balancer at all times. After an Availability Zone is removed,
        /// all instances registered with the load balancer that are in the removed Availability Zone go into the OutOfService state.
        /// Then, the load balancer attempts to equally balance the traffic among its remaining Availability Zones.
        /// </summary>
        /// <param name="loadBalancer">The name associated with the load balancer.</param>
        /// <param name="zones">The Availability Zones to remove from the load balancer.</param>
        /// <param name="settings">The <see cref="LoadBalancingSettings"/> used during the request to AWS.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async Task <bool> DisableAvailabilityZones(string loadBalancer, IList <string> zones, LoadBalancingSettings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(loadBalancer))
            {
                throw new ArgumentNullException("loadBalancer");
            }
            if ((zones == null) || (zones.Count == 0))
            {
                throw new ArgumentNullException("zones");
            }



            //Create Request
            AmazonElasticLoadBalancingClient client = this.CreateClient(settings);
            DisableAvailabilityZonesForLoadBalancerRequest request = new DisableAvailabilityZonesForLoadBalancerRequest();

            request.LoadBalancerName = loadBalancer;

            foreach (string zone in zones)
            {
                request.AvailabilityZones.Add(zone);
            }



            //Check Response
            DisableAvailabilityZonesForLoadBalancerResponse response = await client.DisableAvailabilityZonesForLoadBalancerAsync(request, cancellationToken);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                _Log.Verbose("Successfully disabled zones '{0}'", string.Join(",", zones));
                return(true);
            }
            else
            {
                _Log.Error("Failed to disabled zones '{0}'", string.Join(",", zones));
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// <para> Removes the specified EC2 Availability Zones from the set of configured Availability Zones for the LoadBalancer. </para> <para> There
        /// must be at least one Availability Zone registered with a LoadBalancer at all times. A client cannot remove all the Availability Zones from a
        /// LoadBalancer. Once an Availability Zone is removed, all the instances registered with the LoadBalancer that are in the removed Availability
        /// Zone go into the OutOfService state. Upon Availability Zone removal, the LoadBalancer attempts to equally balance the traffic among its
        /// remaining usable Availability Zones. Trying to remove an Availability Zone that was not associated with the LoadBalancer does nothing.
        /// </para> <para><b>NOTE:</b> In order for this call to be successful, the client must have created the LoadBalancer. The client must provide
        /// the same account credentials as those that were used to create the LoadBalancer. </para>
        /// </summary>
        ///
        /// <param name="disableAvailabilityZonesForLoadBalancerRequest">Container for the necessary parameters to execute the
        ///           DisableAvailabilityZonesForLoadBalancer service method on AmazonElasticLoadBalancing.</param>
        ///
        /// <returns>The response from the DisableAvailabilityZonesForLoadBalancer service method, as returned by AmazonElasticLoadBalancing.</returns>
        ///
        /// <exception cref="InvalidConfigurationRequestException"/>
        /// <exception cref="LoadBalancerNotFoundException"/>
        public DisableAvailabilityZonesForLoadBalancerResponse DisableAvailabilityZonesForLoadBalancer(DisableAvailabilityZonesForLoadBalancerRequest disableAvailabilityZonesForLoadBalancerRequest)
        {
            IRequest <DisableAvailabilityZonesForLoadBalancerRequest> request  = new DisableAvailabilityZonesForLoadBalancerRequestMarshaller().Marshall(disableAvailabilityZonesForLoadBalancerRequest);
            DisableAvailabilityZonesForLoadBalancerResponse           response = Invoke <DisableAvailabilityZonesForLoadBalancerRequest, DisableAvailabilityZonesForLoadBalancerResponse> (request, this.signer, DisableAvailabilityZonesForLoadBalancerResponseUnmarshaller.GetInstance());

            return(response);
        }
Пример #3
0
        private static IDictionary <string, string> ConvertDisableAvailabilityZonesForLoadBalancer(DisableAvailabilityZonesForLoadBalancerRequest request)
        {
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["Action"] = "DisableAvailabilityZonesForLoadBalancer";
            if (request.IsSetLoadBalancerName())
            {
                dictionary["LoadBalancerName"] = request.LoadBalancerName;
            }
            List <string> availabilityZones = request.AvailabilityZones;
            int           num = 1;

            foreach (string str in availabilityZones)
            {
                dictionary["AvailabilityZones" + ".member." + num] = str;
                num++;
            }
            return(dictionary);
        }
Пример #4
0
 public DisableAvailabilityZonesForLoadBalancerResponse DisableAvailabilityZonesForLoadBalancer(DisableAvailabilityZonesForLoadBalancerRequest request)
 {
     return(this.Invoke <DisableAvailabilityZonesForLoadBalancerResponse>(ConvertDisableAvailabilityZonesForLoadBalancer(request)));
 }
        /**
         * Convert DisableAvailabilityZonesForLoadBalancerRequest to name value pairs
         */
        private static IDictionary <string, string> ConvertDisableAvailabilityZonesForLoadBalancer(DisableAvailabilityZonesForLoadBalancerRequest request)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["Action"] = "DisableAvailabilityZonesForLoadBalancer";
            if (request.IsSetLoadBalancerName())
            {
                parameters["LoadBalancerName"] = request.LoadBalancerName;
            }
            List <string> disableAvailabilityZonesForLoadBalancerRequestAvailabilityZonesList      = request.AvailabilityZones;
            int           disableAvailabilityZonesForLoadBalancerRequestAvailabilityZonesListIndex = 1;

            foreach (string disableAvailabilityZonesForLoadBalancerRequestAvailabilityZones in disableAvailabilityZonesForLoadBalancerRequestAvailabilityZonesList)
            {
                parameters[String.Concat("AvailabilityZones", ".member.", disableAvailabilityZonesForLoadBalancerRequestAvailabilityZonesListIndex)] = disableAvailabilityZonesForLoadBalancerRequestAvailabilityZones;
                disableAvailabilityZonesForLoadBalancerRequestAvailabilityZonesListIndex++;
            }

            return(parameters);
        }