/// <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>
		/// 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
						});
		}
		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);
		}
		/// <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};
			}

			Status status =
				Connection.ApiClient.AddBackupClient(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> AddBackupClient(
			this IComputeApiClient client,
			string serverId,
			BackupClientType clientType,
			BackupStoragePolicy storagePolicy,
			BackupSchedulePolicy schedulePolicy,
			AlertingType alertingType)
		{
			return await client.Backup.AddBackupClient(serverId, clientType, storagePolicy, schedulePolicy, alertingType);
		}