/// <summary>
        /// Initializes a new instance of the <see cref="ScalingGroupConfiguration{TPolicyConfiguration}"/>
        /// class with the specified configuration.
        /// </summary>
        /// <param name="groupConfiguration">The group configuration for the scaling group.</param>
        /// <param name="launchConfiguration">The launch configuration for the scaling group.</param>
        /// <param name="scalingPolicies">A collection of scaling policies to initially create with the scaling group.</param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="groupConfiguration"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="launchConfiguration"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="scalingPolicies"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">If <paramref name="scalingPolicies"/> contains any <see langword="null"/> values.</exception>
        protected ScalingGroupConfiguration(GroupConfiguration groupConfiguration, LaunchConfiguration launchConfiguration, IEnumerable <TPolicyConfiguration> scalingPolicies)
        {
            if (groupConfiguration == null)
            {
                throw new ArgumentNullException("groupConfiguration");
            }
            if (launchConfiguration == null)
            {
                throw new ArgumentNullException("launchConfiguration");
            }
            if (scalingPolicies == null)
            {
                throw new ArgumentNullException("scalingPolicies");
            }
            if (scalingPolicies.Contains(null))
            {
                throw new ArgumentException("scalingPolicies cannot contain any null values", "scalingPolicies");
            }

            _groupConfiguration  = groupConfiguration;
            _launchConfiguration = JObject.FromObject(launchConfiguration);
            _scalingPolicies     = scalingPolicies.ToArray();
        }
        public static void SetLaunchConfiguration(this IAutoScaleService service, ScalingGroupId groupId, LaunchConfiguration configuration)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            try
            {
                service.SetLaunchConfigurationAsync(groupId, configuration, CancellationToken.None).Wait();
            }
            catch (AggregateException ex)
            {
                ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions;
                if (innerExceptions.Count == 1)
                    throw innerExceptions[0];

                throw;
            }
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScalingGroupConfiguration"/> class with the specified
 /// configurations.
 /// </summary>
 /// <param name="groupConfiguration">The group configuration for the scaling group.</param>
 /// <param name="launchConfiguration">The launch configuration for the scaling group.</param>
 /// <param name="scalingPolicies">A collection of scaling policies to initially create with the scaling group.</param>
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="groupConfiguration"/> is <see langword="null"/>.
 /// <para>-or-</para>
 /// <para>If <paramref name="launchConfiguration"/> is <see langword="null"/>.</para>
 /// <para>-or-</para>
 /// <para>If <paramref name="scalingPolicies"/> is <see langword="null"/>.</para>
 /// </exception>
 /// <exception cref="ArgumentException">If <paramref name="scalingPolicies"/> contains any <see langword="null"/> values.</exception>
 public ScalingGroupConfiguration(GroupConfiguration groupConfiguration, LaunchConfiguration launchConfiguration, IEnumerable <PolicyConfiguration> scalingPolicies)
     : base(groupConfiguration, launchConfiguration, scalingPolicies)
 {
 }