/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { var monitoringType = new EnableServerMonitoringType { id = Server.id, servicePlan = ServicePlan }; response = Connection.ApiClient.ServerManagement.Monitoring.EnableServerMonitoring(monitoringType).Result; } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { // if (e is HttpRequestException) ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return(true); }); } WriteObject(response); }
/// <summary> /// Enables server monitoring. /// </summary> /// <param name="enableServerMonitoring">The monitoring settings.</param> /// <returns>The status response</returns> public async Task <ResponseType> EnableServerMonitoring(EnableServerMonitoringType enableServerMonitoring) { return(await _apiClient.PostAsync <EnableServerMonitoringType, ResponseType>( ApiUris.EnableServerMonitoring(_apiClient.OrganizationId), enableServerMonitoring)); }