예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataFeed"/> class for mocking
 /// purposes.
 /// </summary>
 internal DataFeed(string id, DataFeedStatus?status, DateTimeOffset?createdOn, string creator, bool?isAdministrator,
                   IReadOnlyDictionary <string, string> metricIds, string name, DataFeedSource dataSource, DataFeedSchema schema,
                   DataFeedGranularity granularity, DataFeedIngestionSettings ingestionSettings, string description, string actionLinkTemplate,
                   DataFeedAccessMode?accessMode, DataFeedRollupSettings rollupSettings, DataFeedMissingDataPointFillSettings missingDataPointFillSettings,
                   IList <string> administrators, IList <string> viewers)
 {
     Id                           = id;
     Status                       = status;
     CreatedOn                    = createdOn;
     Creator                      = creator;
     IsAdministrator              = isAdministrator;
     MetricIds                    = metricIds;
     Name                         = name;
     DataSource                   = dataSource;
     Schema                       = schema;
     Granularity                  = granularity;
     IngestionSettings            = ingestionSettings;
     Description                  = description;
     ActionLinkTemplate           = actionLinkTemplate;
     AccessMode                   = accessMode;
     RollupSettings               = rollupSettings;
     MissingDataPointFillSettings = missingDataPointFillSettings;
     Administrators               = administrators;
     Viewers                      = viewers;
 }
예제 #2
0
 internal DataFeed(DataFeedDetail dataFeedDetail)
 {
     Id                = dataFeedDetail.DataFeedId;
     Status            = dataFeedDetail.Status;
     CreatedTime       = dataFeedDetail.CreatedTime;
     IsAdministrator   = dataFeedDetail.IsAdmin;
     MetricIds         = dataFeedDetail.Metrics.Select(metric => metric.MetricId).ToList();
     Name              = dataFeedDetail.DataFeedName;
     SourceType        = dataFeedDetail.DataSourceType;
     Schema            = new DataFeedSchema(dataFeedDetail);
     Granularity       = new DataFeedGranularity(dataFeedDetail);
     IngestionSettings = new DataFeedIngestionSettings(dataFeedDetail);
     Options           = new DataFeedOptions(dataFeedDetail);
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataFeed"/> class.
        /// </summary>
        /// <param name="dataFeedName">A custom name for the <see cref="DataFeed"/>.</param>
        /// <param name="dataSource">The source from which data is consumed.</param>
        /// <param name="dataFeedGranularity">The frequency with which ingestion from the data source occurs.</param>
        /// <param name="dataFeedSchema">Defines how this <see cref="DataFeed"/> structures the data ingested from the data source in terms of metrics and dimensions.</param>
        /// <param name="dataFeedIngestionSettings">Configures how a <see cref="DataFeed"/> behaves during data ingestion from its data source.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dataFeedName"/>, <paramref name="dataSource"/>, <paramref name="dataFeedGranularity"/>, <paramref name="dataFeedSchema"/>, or <paramref name="dataFeedIngestionSettings"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="dataFeedName"/> is empty.</exception>
        public DataFeed(string dataFeedName, DataFeedSource dataSource, DataFeedGranularity dataFeedGranularity, DataFeedSchema dataFeedSchema, DataFeedIngestionSettings dataFeedIngestionSettings)
        {
            Argument.AssertNotNullOrEmpty(dataFeedName, nameof(dataFeedName));
            Argument.AssertNotNull(dataSource, nameof(dataSource));
            Argument.AssertNotNull(dataFeedGranularity, nameof(dataFeedGranularity));
            Argument.AssertNotNull(dataFeedSchema, nameof(dataFeedSchema));
            Argument.AssertNotNull(dataFeedIngestionSettings, nameof(dataFeedIngestionSettings));

            Name              = dataFeedName;
            DataSource        = dataSource;
            SourceType        = dataSource.Type;
            Granularity       = dataFeedGranularity;
            Schema            = dataFeedSchema;
            IngestionSettings = dataFeedIngestionSettings;
            Administrators    = new ChangeTrackingList <string>();
            Viewers           = new ChangeTrackingList <string>();
        }
예제 #4
0
 internal DataFeed(DataFeedDetail dataFeedDetail)
 {
     Id                           = dataFeedDetail.DataFeedId;
     Status                       = dataFeedDetail.Status;
     CreatedTime                  = dataFeedDetail.CreatedTime;
     Creator                      = dataFeedDetail.Creator;
     IsAdministrator              = dataFeedDetail.IsAdmin;
     MetricIds                    = dataFeedDetail.Metrics.ToDictionary(metric => metric.MetricName, metric => metric.MetricId);
     Name                         = dataFeedDetail.DataFeedName;
     DataSource                   = DataFeedSource.GetDataFeedSource(dataFeedDetail);
     Schema                       = new DataFeedSchema(dataFeedDetail);
     Granularity                  = new DataFeedGranularity(dataFeedDetail);
     IngestionSettings            = new DataFeedIngestionSettings(dataFeedDetail);
     Description                  = dataFeedDetail.DataFeedDescription;
     ActionLinkTemplate           = dataFeedDetail.ActionLinkTemplate;
     AccessMode                   = dataFeedDetail.ViewMode;
     RollupSettings               = new DataFeedRollupSettings(dataFeedDetail);
     MissingDataPointFillSettings = new DataFeedMissingDataPointFillSettings(dataFeedDetail);
     Administrators               = dataFeedDetail.Admins;
     Viewers                      = dataFeedDetail.Viewers;
 }
예제 #5
0
        /// <summary> Initializes a new instance of a data source specific DataFeedDetail. </summary>
        /// <param name="dataFeedName"> data feed name. </param>
        /// <param name="dataFeedGranularity"></param>
        /// <param name="dataFeedSchema"></param>
        /// <param name="dataFeedIngestionSettings"></param>
        /// <param name="dataFeedOptions"></param>
        internal void SetDetail(string dataFeedName, DataFeedGranularity dataFeedGranularity, DataFeedSchema dataFeedSchema, DataFeedIngestionSettings dataFeedIngestionSettings, DataFeedOptions dataFeedOptions)
        {
            dataFeedIngestionSettings.IngestionStartTime = ClientCommon.NormalizeDateTimeOffset(dataFeedIngestionSettings.IngestionStartTime);

            DataFeedDetail = Parameter switch
            {
                AzureApplicationInsightsParameter p => new AzureApplicationInsightsDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                AzureBlobParameter p => new AzureBlobDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                AzureCosmosDBParameter p => new AzureCosmosDBDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                AzureDataLakeStorageGen2Parameter p => new AzureDataLakeStorageGen2DataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                AzureTableParameter p => new AzureTableDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                ElasticsearchParameter p => new ElasticsearchDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                HttpRequestParameter p => new HttpRequestDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                InfluxDBParameter p => new InfluxDBDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                SqlSourceParameter p when DataFeedSourceType == DataFeedSourceType.AzureDataExplorer => new AzureDataExplorerDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                SqlSourceParameter p when DataFeedSourceType == DataFeedSourceType.MySql => new MySqlDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                SqlSourceParameter p when DataFeedSourceType == DataFeedSourceType.PostgreSql => new PostgreSqlDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                SqlSourceParameter p when DataFeedSourceType == DataFeedSourceType.SqlServer => new SQLServerDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                MongoDBParameter p => new MongoDBDataFeed(dataFeedName, dataFeedGranularity.GranularityType, dataFeedSchema.MetricColumns, dataFeedIngestionSettings.IngestionStartTime, p),
                _ => throw new InvalidOperationException("Invalid DataFeedDetail type")
            };

            DataFeedDetail.GranularityAmount = dataFeedGranularity.CustomGranularityValue;
            foreach (var column in dataFeedSchema.DimensionColumns)
            {
                DataFeedDetail.Dimension.Add(column);
            }
            DataFeedDetail.TimestampColumn           = dataFeedSchema.TimestampColumn;
            DataFeedDetail.MaxConcurrency            = dataFeedIngestionSettings.DataSourceRequestConcurrency;
            DataFeedDetail.MinRetryIntervalInSeconds = (long?)dataFeedIngestionSettings.IngestionRetryDelay?.TotalSeconds;
            DataFeedDetail.StartOffsetInSeconds      = (long?)dataFeedIngestionSettings.IngestionStartOffset?.TotalSeconds;
            DataFeedDetail.StopRetryAfterInSeconds   = (long?)dataFeedIngestionSettings.StopRetryAfter?.TotalSeconds;
            if (dataFeedOptions != null)
            {
                foreach (var admin in dataFeedOptions.Administrators)
                {
                    DataFeedDetail.Admins.Add(admin);
                }
                foreach (var viewer in dataFeedOptions.Viewers)
                {
                    DataFeedDetail.Viewers.Add(viewer);
                }
                DataFeedDetail.DataFeedDescription = dataFeedOptions.Description;
                DataFeedDetail.ViewMode            = dataFeedOptions.AccessMode;
                if (dataFeedOptions.RollupSettings != null)
                {
                    foreach (var columnName in dataFeedOptions.RollupSettings.AutoRollupGroupByColumnNames)
                    {
                        DataFeedDetail.RollUpColumns.Add(columnName);
                    }
                    DataFeedDetail.RollUpMethod = dataFeedOptions.RollupSettings.RollupMethod;
                    DataFeedDetail.NeedRollup   = dataFeedOptions.RollupSettings.RollupType;
                }
                if (dataFeedOptions.MissingDataPointFillSettings != null)
                {
                    DataFeedDetail.FillMissingPointType  = dataFeedOptions.MissingDataPointFillSettings.FillType;
                    DataFeedDetail.FillMissingPointValue = dataFeedOptions.MissingDataPointFillSettings.CustomFillValue;
                }
                DataFeedDetail.ActionLinkTemplate = dataFeedOptions.ActionLinkTemplate;
            }
        }
    }
        /// <summary>
        /// Initializes a new instance of <see cref="Models.DataFeed"/> for mocking purposes.
        /// </summary>
        /// <param name="id">Sets the <see cref="DataFeed.Id"/> property.</param>
        /// <param name="status">Sets the <see cref="DataFeed.Status"/> property.</param>
        /// <param name="createdOn">Sets the <see cref="DataFeed.CreatedOn"/> property.</param>
        /// <param name="creator">Sets the <see cref="DataFeed.Creator"/> property.</param>
        /// <param name="isAdministrator">Sets the <see cref="DataFeed.IsAdministrator"/> property.</param>
        /// <param name="metricIds">Sets the <see cref="DataFeed.MetricIds"/> property.</param>
        /// <param name="name">Sets the <see cref="DataFeed.Name"/> property.</param>
        /// <param name="dataSource">Sets the <see cref="DataFeed.DataSource"/> property.</param>
        /// <param name="schema">Sets the <see cref="DataFeed.Schema"/> property.</param>
        /// <param name="granularity">Sets the <see cref="DataFeed.Granularity"/> property.</param>
        /// <param name="ingestionSettings">Sets the <see cref="DataFeed.IngestionSettings"/> property.</param>
        /// <param name="description">Sets the <see cref="DataFeed.Description"/> property.</param>
        /// <param name="actionLinkTemplate">Sets the <see cref="DataFeed.ActionLinkTemplate"/> property.</param>
        /// <param name="accessMode">Sets the <see cref="DataFeed.AccessMode"/> property.</param>
        /// <param name="rollupSettings">Sets the <see cref="DataFeed.RollupSettings"/> property.</param>
        /// <param name="missingDataPointFillSettings">Sets the <see cref="DataFeed.MissingDataPointFillSettings"/> property.</param>
        /// <param name="administrators">Sets the <see cref="DataFeed.Administrators"/> property.</param>
        /// <param name="viewers">Sets the <see cref="DataFeed.Viewers"/> property.</param>
        /// <returns>A new instance of <see cref="Models.AnomalyIncident"/> for mocking purposes.</returns>
        public static DataFeed DataFeed(string id = null, DataFeedStatus?status = null, DateTimeOffset?createdOn = null, string creator = null, bool?isAdministrator = null, IReadOnlyDictionary <string, string> metricIds = null, string name = null, DataFeedSource dataSource = null, DataFeedSchema schema = null, DataFeedGranularity granularity = null, DataFeedIngestionSettings ingestionSettings = null, string description = null, string actionLinkTemplate = null, DataFeedAccessMode?accessMode = null, DataFeedRollupSettings rollupSettings = null, DataFeedMissingDataPointFillSettings missingDataPointFillSettings = null, IEnumerable <string> administrators = null, IEnumerable <string> viewers = null)
        {
            metricIds      = metricIds ?? new Dictionary <string, string>();
            administrators = administrators ?? new List <string>();
            viewers        = viewers ?? new List <string>();

            return(new DataFeed(id, status, createdOn, creator, isAdministrator, metricIds, name, dataSource, schema, granularity, ingestionSettings, description, actionLinkTemplate, accessMode, rollupSettings, missingDataPointFillSettings, administrators.ToList(), viewers.ToList()));
        }