/// <summary>
        /// Update the specified service properties according to the input
        /// </summary>
        /// <param name="serviceProperties">Service properties</param>
        internal void UpdateServiceProperties(MetricsProperties metrics)
        {
            if (Version != null)
            {
                metrics.Version = Version.ToString();
            }

            if (RetentionDays != null)
            {
                if (RetentionDays == -1)
                {
                    //Disable metrics retention policy
                    metrics.RetentionDays = null;
                }
                else if (RetentionDays < 1 || RetentionDays > 365)
                {
                    throw new ArgumentException(string.Format(Resources.InvalidRetentionDay, RetentionDays));
                }
                else
                {
                    metrics.RetentionDays = RetentionDays;
                }
            }

            if (MetricsLevel != null)
            {
                MetricsLevel metricsLevel = MetricsLevel.Value;
                metrics.MetricsLevel = metricsLevel;
                // Set default metrics version
                if (string.IsNullOrEmpty(metrics.Version))
                {
                    string defaultMetricsVersion = StorageNouns.DefaultMetricsVersion;
                    metrics.Version = defaultMetricsVersion;
                }
            }
        }
        /// <summary>
        /// Generates XML representing the given metrics properties.
        /// </summary>
        /// <param name="metrics">The metrics properties.</param>
        /// <param name="metricsName">The XML name for these metrics.</param>
        /// <returns>An XML metrics element.</returns>
        private static XElement GenerateMetricsXml(MetricsProperties metrics, string metricsName)
        {
            if (!Enum.IsDefined(typeof(MetricsLevel), metrics.MetricsLevel))
            {
                throw new InvalidOperationException(SR.InvalidMetricsLevel);
            }

            if (string.IsNullOrEmpty(metrics.Version))
            {
                throw new InvalidOperationException(SR.MetricVersionNull);
            }

            bool enabled = metrics.MetricsLevel != MetricsLevel.None;

            XElement xml = new XElement(
                metricsName,
                new XElement(VersionName, metrics.Version),
                new XElement(EnabledName, enabled),
                GenerateRetentionPolicyXml(metrics.RetentionDays));

            if (enabled)
            {
                xml.Add(new XElement(IncludeApisName, metrics.MetricsLevel == MetricsLevel.ServiceAndApi));
            }

            return xml;
        }
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null)
 {
     this.Logging = logging;
     this.HourMetrics = hourMetrics;
     this.MinuteMetrics = minuteMetrics;
     this.Cors = cors;
 }
        private static MetricsProperties Clone(MetricsProperties metrics)
        {
            if (metrics == null)
            {
                return null;
            }

            return new MetricsProperties
            {
                MetricsLevel = metrics.MetricsLevel,
                RetentionDays = metrics.RetentionDays,
                Version = metrics.Version
            };
        }
 public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null)
 {
     throw new System.NotImplementedException();
 }
 private static XElement GenerateMetricsXml(MetricsProperties metrics, string metricsName)
 {
     throw new System.NotImplementedException();
 }
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging, MetricsProperties hourMetrics, MetricsProperties minuteMetrics, CorsProperties cors, DeleteRetentionPolicy deleteRetentionPolicy, StaticWebsiteProperties staticWebsite = null)
 {
     this.Logging               = logging;
     this.HourMetrics           = hourMetrics;
     this.MinuteMetrics         = minuteMetrics;
     this.Cors                  = cors;
     this.DeleteRetentionPolicy = deleteRetentionPolicy;
     this.StaticWebsite         = staticWebsite;
 }
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null, DeleteRetentionPolicy deleteRetentionPolicy = null)
     : this(logging, hourMetrics, minuteMetrics, cors, deleteRetentionPolicy, staticWebsite : null)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FileServiceProperties"/> class.
 /// </summary>
 public FileServiceProperties(MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null)
 {
     this.serviceProperties = new ServiceProperties(null, hourMetrics, minuteMetrics, cors);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null, DeleteRetentionPolicy deleteRetentionPolicy = null)
 {
     this.Logging               = logging;
     this.HourMetrics           = hourMetrics;
     this.MinuteMetrics         = minuteMetrics;
     this.Cors                  = cors;
     this.DeleteRetentionPolicy = deleteRetentionPolicy;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null)
 {
     this.Logging       = logging;
     this.HourMetrics   = hourMetrics;
     this.MinuteMetrics = minuteMetrics;
     this.Cors          = cors;
 }