/// <summary>
        /// Modifies the backup client on the specified server.
        /// </summary>
        /// <param name="client">The <see cref="ComputeApiClient"/> object</param>
        /// <param name="serverId">The server id</param>
        /// <param name="backupClient">The backup client to modify</param>
        /// <param name="storagePolicy">The storage policy to modify</param>
        /// <param name="schedulePolicy">The schedule policy to modify</param>
        /// <param name="alertingType">The alerting type to modify</param>
        /// <returns>The status of the request</returns>
        public static async Task <Status> ModifyBackupClientAsync(
            this IComputeApiClient client,
            string serverId,
            BackupClientDetailsType backupClient,
            BackupStoragePolicy storagePolicy,
            BackupSchedulePolicy schedulePolicy,
            AlertingType alertingType)
        {
            if (backupClient == null)
            {
                throw new ArgumentNullException("backupClient", "argument cannot be null!");
            }
            if (storagePolicy == null)
            {
                throw new ArgumentNullException("storagePolicy", "argument cannot be null!");
            }
            if (schedulePolicy == null)
            {
                throw new ArgumentNullException("schedulePolicy", "argument cannot be null!");
            }

            return
                (await
                 client.WebApi.ApiPostAsync <ModifyBackupClient, Status>(
                     ApiUris.ModifyBackupClient(client.Account.OrganizationId, serverId, backupClient.id),
                     new ModifyBackupClient
            {
                schedulePolicyName = schedulePolicy.name,
                storagePolicyName = storagePolicy.name,
                alerting = alertingType
            }));
        }
        /// <summary>
        /// Adds a backup client to the server and returns the download link url
        /// </summary>
        /// <returns>The download link</returns>
        private string AddBackupClient()
        {
            AlertingType alerting = null;

            if (Trigger.HasValue)
            {
                if (EmailAddresses == null || EmailAddresses.Count == 0)
                {
                    ThrowTerminatingError(new ErrorRecord(new ArgumentException("At least one email address must be supploed when setting a trigger type"), "-1", ErrorCategory.NotSpecified, this));
                    return(string.Empty);
                }

                alerting = new AlertingType {
                    emailAddress = EmailAddresses.ToArray(), trigger = Trigger.Value
                };
            }

            var status = CaaS.ApiClient.AddBackupClientAsync(Server.id, ClientType, StoragePolicy, SchedulePolicy, alerting).Result;

            if (status != null)
            {
                WriteDebug(
                    string.Format(
                        "{0} resulted in {1} ({2}): {3}",
                        status.operation,
                        status.result,
                        status.resultCode,
                        status.resultDetail));

                return(status.additionalInformation.Single(ai => ai.name == "backupClient.downloadUrl").value);
            }
            return(string.Empty);
        }
 public static async Task <Status> ModifyBackupClient(
     this IComputeApiClient client,
     string serverId,
     BackupClientDetailsType backupClient,
     BackupStoragePolicy storagePolicy,
     BackupSchedulePolicy schedulePolicy,
     AlertingType alertingType)
 {
     return(await client.Backup.ModifyBackupClient(serverId, backupClient, storagePolicy, schedulePolicy, alertingType));
 }
 public static async Task <Status> AddBackupClient(
     this IComputeApiClient client,
     string serverId,
     BackupClientType clientType,
     BackupStoragePolicy storagePolicy,
     BackupSchedulePolicy schedulePolicy,
     AlertingType alertingType)
 {
     return(await client.Backup.AddBackupClient(serverId, clientType, storagePolicy, schedulePolicy, alertingType));
 }
Esempio n. 5
0
        public AlertingHistory GetLastAlertingHistory(int appId, AlertingType type)
        {
            var collection    = MongoDataBase.GetCollection <AlertingHistory>();
            var filterBuilder = Builders <AlertingHistory> .Filter;
            var filter        = filterBuilder.Gt("ObjId", appId) & filterBuilder.Gt("AlertingType", type);
            var result        = collection.Find(filter)
                                .SortByDescending(x => x.Time)
                                .FirstOrDefaultAsync().Result;

            return(result);
        }
Esempio n. 6
0
 /// <summary>
 /// The modify backup client.
 /// </summary>
 /// <param name="serverId">
 /// The server id.
 /// </param>
 /// <param name="backupClientId">The Backup Client Id.</param>
 /// <param name="schedulePolicyName">The Schedule Policy Name</param>
 /// <param name="alertingType">
 /// The alerting type.
 /// </param>
 /// <param name="storagePolicyName">The Storage Policy Name</param>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 public async Task <Status> ModifyBackupClient(
     string serverId,
     string backupClientId,
     string storagePolicyName,
     string schedulePolicyName,
     AlertingType alertingType)
 {
     return
         (await
          _apiClient.PostAsync <ModifyBackupClient, Status>(
              ApiUris.ModifyBackupClient(_apiClient.OrganizationId, serverId, backupClientId),
              new ModifyBackupClient
     {
         schedulePolicyName = schedulePolicyName,
         storagePolicyName = storagePolicyName,
         alerting = alertingType
     }));
 }
Esempio n. 7
0
 /// <summary>
 /// The add backup client.
 /// </summary>
 /// <param name="serverId">
 /// The server id.
 /// </param>
 /// <param name="clientType">
 /// The client type.
 /// </param>
 /// <param name="storagePolicy">
 /// The storage policy.
 /// </param>
 /// <param name="schedulePolicy">
 /// The schedule policy.
 /// </param>
 /// <param name="alertingType">
 /// The alerting type.
 /// </param>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 public async Task <Status> AddBackupClient(
     string serverId,
     string clientType,
     string storagePolicy,
     string schedulePolicy,
     AlertingType alertingType)
 {
     return
         (await
          _apiClient.PostAsync <NewBackupClient, Status>(
              ApiUris.AddBackupClient(_apiClient.OrganizationId, serverId),
              new NewBackupClient
     {
         schedulePolicyName = schedulePolicy,
         storagePolicyName = storagePolicy,
         type = clientType,
         alerting = alertingType
     }));
 }
Esempio n. 8
0
        /// <summary>
        /// The modify backup client.
        /// </summary>
        /// <param name="serverId">
        /// The server id.
        /// </param>
        /// <param name="backupClient">
        /// The backup client.
        /// </param>
        /// <param name="storagePolicy">
        /// The storage policy.
        /// </param>
        /// <param name="schedulePolicy">
        /// The schedule policy.
        /// </param>
        /// <param name="alertingType">
        /// The alerting type.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <Status> ModifyBackupClient(
            string serverId,
            BackupClientDetailsType backupClient,
            BackupStoragePolicy storagePolicy,
            BackupSchedulePolicy schedulePolicy,
            AlertingType alertingType)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(serverId), "Server cannot be null or empty");
            Contract.Requires(backupClient != null, "Backup client cannot be null");

            return
                (await
                 _apiClient.PostAsync <ModifyBackupClient, Status>(
                     ApiUris.ModifyBackupClient(_apiClient.OrganizationId, serverId, backupClient.id),
                     new ModifyBackupClient
            {
                schedulePolicyName = schedulePolicy.name,
                storagePolicyName = storagePolicy.name,
                alerting = alertingType
            }));
        }
        /// <summary>
        /// Adds a backup client to a specified server.
        /// </summary>
        /// <param name="client">The <see cref="ComputeApiClient"/> object</param>
        /// <param name="serverId">The server id</param>
        /// <param name="clientType">The backup client type to add</param>
        /// <param name="storagePolicy">The backup storage policy</param>
        /// <param name="schedulePolicy">The backup schedule policy</param>
        /// <param name="alertingType">The alerting type</param>
        /// <returns>The status of the request</returns>
        public static async Task <Status> AddBackupClientAsync(
            this IComputeApiClient client,
            string serverId,
            BackupClientType clientType,
            BackupStoragePolicy storagePolicy,
            BackupSchedulePolicy schedulePolicy,
            AlertingType alertingType)
        {
            if (string.IsNullOrWhiteSpace(serverId))
            {
                throw new ArgumentException("argument cannot be null, empty or composed of whitespaces only!", "serverId");
            }
            if (clientType == null)
            {
                throw new ArgumentNullException("clientType", "argument cannot be null!");
            }
            if (storagePolicy == null)
            {
                throw new ArgumentNullException("storagePolicy", "argument cannot be null!");
            }
            if (schedulePolicy == null)
            {
                throw new ArgumentNullException("schedulePolicy", "argument cannot be null!");
            }

            return
                (await
                 client.WebApi.ApiPostAsync <NewBackupClient, Status>(
                     ApiUris.AddBackupClient(client.Account.OrganizationId, serverId),
                     new NewBackupClient
            {
                schedulePolicyName = schedulePolicy.name,
                storagePolicyName = storagePolicy.name,
                type = clientType.type,
                alerting = alertingType
            }));
        }
Esempio n. 10
0
        /// <summary>
        /// The add backup client.
        /// </summary>
        /// <param name="serverId">
        /// The server id.
        /// </param>
        /// <param name="clientType">
        /// The client type.
        /// </param>
        /// <param name="storagePolicy">
        /// The storage policy.
        /// </param>
        /// <param name="schedulePolicy">
        /// The schedule policy.
        /// </param>
        /// <param name="alertingType">
        /// The alerting type.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <Status> AddBackupClient(
            string serverId,
            BackupClientType clientType,
            BackupStoragePolicy storagePolicy,
            BackupSchedulePolicy schedulePolicy,
            AlertingType alertingType)
        {
            Contract.Requires(!string.IsNullOrEmpty(serverId), "Server id cannot be null or empty");
            Contract.Requires(clientType != null, "Client type cannot be null");
            Contract.Requires(storagePolicy != null, "Storage policy cannot be null");
            Contract.Requires(schedulePolicy != null, "Schedule policy cannot be null");

            return
                (await
                 _apiClient.PostAsync <NewBackupClient, Status>(
                     ApiUris.AddBackupClient(_apiClient.OrganizationId, serverId),
                     new NewBackupClient
            {
                schedulePolicyName = schedulePolicy.name,
                storagePolicyName = storagePolicy.name,
                type = clientType.type,
                alerting = alertingType
            }));
        }
Esempio n. 11
0
 public BaseAlerting(AlertingType alertingType)
 {
     this.AlertingType = alertingType;
 }
Esempio n. 12
0
 public AlertingHistory GetLastAlertingHistory(int appId, AlertingType appError)
 {
     throw new NotImplementedException();
 }