Ejemplo n.º 1
0
        /// <summary>
        /// Updates the mutable properties of a Pool.
        /// </summary>
        /// <param name="pool">The edit pool.</param>
        /// <returns>The async task of <see cref="ResponseType"/></returns>
        public async Task <ResponseType> EditPool(EditPoolType pool)
        {
            if (pool.healthMonitorId == null || pool.healthMonitorId.Length == 0)
            {
                pool.healthMonitorId = new string[] { null };
            }

            return(await _api.PostAsync <EditPoolType, ResponseType>(ApiUris.EditPool(_api.OrganizationId), pool));
        }
        /// <summary>
        ///     The process record method.
        /// </summary>
        protected override void ProcessRecord()
        {
            ResponseType response = null;

            base.ProcessRecord();
            try
            {
                var editPool = new EditPoolType
                {
                    id                = VipPool.id,
                    description       = Description,
                    healthMonitorId   = HealthMonitorId,
                    loadBalanceMethod = LoadBalanceMethod,
                    serviceDownAction = ServiceDownAction,
                    slowRampTime      = SlowRampTime
                };

                response = Connection.ApiClient.Networking.VipPool.EditPool(editPool).Result;
            }
            catch (AggregateException ae)
            {
                ae.Handle(
                    e =>
                {
                    if (e is ComputeApiException)
                    {
                        WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection));
                    }
                    else
                    {
                        // if (e is HttpRequestException)
                        ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection));
                    }

                    return(true);
                });
            }

            WriteObject(response);
        }