private static void UnmarshallResult(XmlUnmarshallerContext context, RegisterInstancesWithLoadBalancerResponse 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("Instances/member", targetDepth))
                    {
                        var unmarshaller = InstanceUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.Instances.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)
        {
            RegisterInstancesWithLoadBalancerResponse response = new RegisterInstancesWithLoadBalancerResponse();

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

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

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

            return(response);
        }
示例#3
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, RegisterInstancesWithLoadBalancerResponse 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("Instances/member", targetDepth))
                    {
                        response.Instances.Add(InstanceUnmarshaller.GetInstance().Unmarshall(context));

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



            return;
        }
示例#4
0
        /// <summary>
        /// <para> Adds new instances to the LoadBalancer. </para> <para> Once the instance is registered, it starts receiving traffic and requests from
        /// the LoadBalancer. Any instance that is not in any of the Availability Zones registered for the LoadBalancer will be moved to the
        /// <i>OutOfService</i> state. It will move to the <i>InService</i> state when the Availability Zone is added to the LoadBalancer. </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> <para><b>NOTE:</b> Completion of this API does not guarantee
        /// that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly. </para>
        /// </summary>
        ///
        /// <param name="registerInstancesWithLoadBalancerRequest">Container for the necessary parameters to execute the
        ///           RegisterInstancesWithLoadBalancer service method on AmazonElasticLoadBalancing.</param>
        ///
        /// <returns>The response from the RegisterInstancesWithLoadBalancer service method, as returned by AmazonElasticLoadBalancing.</returns>
        ///
        /// <exception cref="InvalidInstanceException"/>
        /// <exception cref="LoadBalancerNotFoundException"/>
        public RegisterInstancesWithLoadBalancerResponse RegisterInstancesWithLoadBalancer(RegisterInstancesWithLoadBalancerRequest registerInstancesWithLoadBalancerRequest)
        {
            IRequest <RegisterInstancesWithLoadBalancerRequest> request  = new RegisterInstancesWithLoadBalancerRequestMarshaller().Marshall(registerInstancesWithLoadBalancerRequest);
            RegisterInstancesWithLoadBalancerResponse           response = Invoke <RegisterInstancesWithLoadBalancerRequest, RegisterInstancesWithLoadBalancerResponse> (request, this.signer, RegisterInstancesWithLoadBalancerResponseUnmarshaller.GetInstance());

            return(response);
        }
        /// <summary>
        /// Adds new instances to the load balancer.
        /// Once the instance is registered, it starts receiving traffic and requests from the load balancer.
        /// Any instance that is not in any of the Availability Zones registered for the load balancer will be moved to the OutOfService state.
        /// It will move to the InService state when the Availability Zone is added to the load balancer.
        /// </summary>
        /// <param name="loadBalancer">The name associated with the load balancer.</param>
        /// <param name="instances">A list of instance IDs that should be registered with 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> RegisterInstances(string loadBalancer, IList <string> instances, LoadBalancingSettings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(loadBalancer))
            {
                throw new ArgumentNullException("loadBalancer");
            }
            if ((instances == null) || (instances.Count == 0))
            {
                throw new ArgumentNullException("instances");
            }



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

            request.LoadBalancerName = loadBalancer;

            foreach (string instance in instances)
            {
                request.Instances.Add(new Instance(instance));
            }



            //Check Response
            RegisterInstancesWithLoadBalancerResponse response = await client.RegisterInstancesWithLoadBalancerAsync(request, cancellationToken);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                _Log.Verbose("Successfully registered instances '{0}'", string.Join(",", instances));
                return(true);
            }
            else
            {
                _Log.Error("Failed to register instances '{0}'", string.Join(",", instances));
                return(false);
            }
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            RegisterInstancesWithLoadBalancerResponse response = new RegisterInstancesWithLoadBalancerResponse();

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


            return(response);
        }