private static void UnmarshallResult(XmlUnmarshallerContext context, DisableAvailabilityZonesForLoadBalancerResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("AvailabilityZones/member", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.AvailabilityZones.Add(item);
                        continue;
                    }
                }
            }

            return;
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DisableAvailabilityZonesForLoadBalancerResponse response = new DisableAvailabilityZonesForLoadBalancerResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("DisableAvailabilityZonesForLoadBalancerResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, DisableAvailabilityZonesForLoadBalancerResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("AvailabilityZones/member", targetDepth))
                    {
                        response.AvailabilityZones.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }
コード例 #4
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);
        }
        /// <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);
            }
        }
コード例 #6
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DisableAvailabilityZonesForLoadBalancerResponse response = new DisableAvailabilityZonesForLoadBalancerResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("DisableAvailabilityZonesForLoadBalancerResult", 2))
                    {
                        response.DisableAvailabilityZonesForLoadBalancerResult = DisableAvailabilityZonesForLoadBalancerResultUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context);
                    }
                }
            }


            return(response);
        }