コード例 #1
0
ファイル: ServerService.cs プロジェクト: jwebs1/clc-net-sdk
 void SetInternalServerProperties(Server server)
 {
     server.ServerService = this;
 }
コード例 #2
0
ファイル: AlertService.cs プロジェクト: jwebs1/clc-net-sdk
        /// <summary>
        /// Gets the alerts for a particular server.
        /// </summary>
        /// <param name="server">The server</param>
        /// <returns>The alerts for the indicated server</returns>
        public async Task<List<Alert>> GetServerAlerts(Server server, CancellationToken cancellationToken)
        {
            var statisticsTask = server.GetStatistics(cancellationToken);
            var alertPoliciesTasks =
                server
                    .Details
                    .AlertPolicies
                    .Select(
                        a =>
                            GetAlertPolicyByLink(string.Format("{0}{1}", Configuration.BaseUri, a.selfLink.Value.Href), cancellationToken));
            await Task.WhenAll(alertPoliciesTasks).ConfigureAwait(false);
            var statistics = await statisticsTask.ConfigureAwait(false);
            var alertPolicies = alertPoliciesTasks.Select(a => a.Result);

            return ScanAlertPoliciesForAlerts(server, alertPolicies, statistics);            
        }
コード例 #3
0
ファイル: AlertService.cs プロジェクト: jwebs1/clc-net-sdk
        /// <summary>
        /// Loops through alert policies to determine if a server needs to be alerted.
        /// </summary>
        /// <param name="serverId"></param>
        /// <param name="alertPolicies"></param>
        /// <param name="statistics"></param>
        /// <returns></returns>
        private List<Alert> ScanAlertPoliciesForAlerts(Server server, IEnumerable<AlertPolicy> alertPolicies, Statistics statistics)
        {
            var alerts = new List<Alert>();

            foreach (var alertPolicy in alertPolicies)
            {
                var statistic = statistics.Stats.FirstOrDefault();

                if (statistic != null)
                {
                    var triggers = alertPolicy.Triggers;
                    if (triggers != null)
                    {
                        foreach (var trigger in triggers)
                        {
                            try
                            {
                                var alert = GetServerAlert(alertPolicy, trigger, statistic, server.Id);

                                if (alert != null)
                                {
                                    alerts.Add(alert);
                                }
                            }
                            catch (Exception ex)
                            {
                                var exception = new CenturyLinkCloudServiceException(Constants.ExceptionMessages.AlertGenerationExceptionMessage, ex);
                                throw exception;
                            }
                        }
                    }
                }
            }

            return alerts;
        }        
コード例 #4
0
ファイル: AlertService.cs プロジェクト: jwebs1/clc-net-sdk
 /// <summary>
 /// Gets the alerts for a particular server.
 /// </summary>
 /// <param name="server">The server</param>
 /// <returns>The alerts for the indicated server</returns>
 public Task<List<Alert>> GetServerAlerts(Server server)
 {
     return GetServerAlerts(server, CancellationToken.None);
 }
コード例 #5
0
ファイル: AccountService.cs プロジェクト: jwebs1/clc-net-sdk
 /// <summary>
 /// Returns the recent activity for the indicated server
 /// </summary>
 /// <param name="s">The server</param>
 /// <param name="recordLimit">The maximum number of records to return</param>
 /// <returns>The server recent activity</returns>
 public Task<IEnumerable<Activity>> GetRecentActivityFor(Server s, int recordLimit, CancellationToken cancellationToken)
 {
     return GetRecentActivity(new[] { s.Id }, recordLimit, cancellationToken);
 }
コード例 #6
0
ファイル: AccountService.cs プロジェクト: jwebs1/clc-net-sdk
 /// <summary>
 /// Returns the recent activity for the indicated server
 /// </summary>
 /// <param name="s">The server</param>
 /// <returns>The server recent activity</returns>
 public Task<IEnumerable<Activity>> GetRecentActivityFor(Server s, CancellationToken cancellationToken)
 {
     return GetRecentActivityFor(s, 10, cancellationToken);
 }
コード例 #7
0
ファイル: AccountService.cs プロジェクト: jwebs1/clc-net-sdk
 /// <summary>
 /// Returns the recent activity for the indicated server
 /// </summary>
 /// <param name="s">The server</param>
 /// <param name="recordLimit">The maximum number of records to return</param>
 /// <returns>The server recent activity</returns>
 public Task<IEnumerable<Activity>> GetRecentActivityFor(Server s, int recordLimit)
 {
     return GetRecentActivityFor(s, recordLimit, CancellationToken.None);
 }
コード例 #8
0
ファイル: AccountService.cs プロジェクト: jwebs1/clc-net-sdk
 /// <summary>
 /// Returns the recent activity for the indicated server
 /// </summary>
 /// <param name="s">The server</param>
 /// <returns>The server recent activity</returns>
 public Task<IEnumerable<Activity>> GetRecentActivityFor(Server s)
 {
     return GetRecentActivityFor(s, CancellationToken.None);
 }